Skip to content

Commit f5b9468

Browse files
committed
Merge remote-tracking branch 'origin/master' into issue-14212
2 parents baeb0c7 + 1c1292b commit f5b9468

File tree

9 files changed

+219
-8
lines changed

9 files changed

+219
-8
lines changed

components/cliento/cliento.app.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
type: "app",
3+
app: "cliento",
4+
propDefinitions: {},
5+
methods: {
6+
// this.$auth contains connected account data
7+
authKeys() {
8+
console.log(Object.keys(this.$auth));
9+
},
10+
},
11+
};

components/cliento/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/cliento",
3+
"version": "0.0.1",
4+
"description": "Pipedream Cliento Components",
5+
"main": "cliento.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"cliento"
9+
],
10+
"homepage": "https://pipedream.com/apps/cliento",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import twin from "../../twin.app.mjs";
2+
3+
export default {
4+
key: "twin-browse",
5+
name: "Browse",
6+
description: "Browse the internet with an AI web navigation agent that can find information for you. [See the documentation](https://docs.twin.so/api-reference/endpoint/browse)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
twin,
11+
startUrl: {
12+
type: "string",
13+
label: "Start URL",
14+
description: "The URL where the browsing task should begin",
15+
},
16+
goal: {
17+
type: "string",
18+
label: "Goal",
19+
description: "The goal or objective of the browsing task. Example: \"Find the latest price of AAPL stock.\"",
20+
},
21+
outputType: {
22+
type: "string",
23+
label: "Output Type",
24+
description: "The type of output expected from the task",
25+
options: [
26+
"string",
27+
"url",
28+
"list[url]",
29+
],
30+
default: "string",
31+
optional: true,
32+
},
33+
callbackWithRerun: {
34+
type: "boolean",
35+
label: "Callback With Rerun",
36+
description: "Use the `$.flow.rerun` Node.js helper to rerun the step when the search is completed. This will increase execution time and credit usage as a result. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun/#flow-rerun)",
37+
optional: true,
38+
},
39+
},
40+
async run({ $ }) {
41+
let response, completionCallbackUrl;
42+
const { run } = $.context;
43+
if (run.runs === 1) {
44+
if (this.callbackWithRerun) {
45+
({ resume_url: completionCallbackUrl } = $.flow.rerun(600000, null, 1));
46+
}
47+
response = await this.twin.browse({
48+
$,
49+
data: {
50+
startUrl: this.startUrl,
51+
goal: this.goal,
52+
outputType: this.outputType,
53+
completionCallbackUrl,
54+
},
55+
});
56+
}
57+
58+
if (run.callback_request) {
59+
const { task_id: taskId } = run.callback_request.body;
60+
response = await this.twin.getTask({
61+
taskId,
62+
});
63+
}
64+
65+
if (response.status === "COMPLETED") {
66+
$.export("$summary", "Successfully completed browsing");
67+
}
68+
return response;
69+
},
70+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import twin from "../../twin.app.mjs";
2+
3+
export default {
4+
key: "twin-get-task-details",
5+
name: "Get Task Details",
6+
description: "Retrieve details of a specific task. [See the documentation](https://docs.twin.so/api-reference/endpoint/get-task)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
twin,
11+
taskId: {
12+
propDefinition: [
13+
twin,
14+
"taskId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.twin.getTask({
20+
$,
21+
taskId: this.taskId,
22+
});
23+
$.export("$summary", `Successfully retrieved details for task with ID: ${this.taskId}`);
24+
return response;
25+
},
26+
};

components/twin/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/twin",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Twin Components",
55
"main": "twin.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

components/twin/twin.app.mjs

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,64 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "twin",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
taskId: {
8+
type: "string",
9+
label: "Task ID",
10+
description: "Identifier of a task",
11+
async options() {
12+
const tasks = await this.listTasks();
13+
return tasks?.map(({
14+
id: value, goal,
15+
}) => ({
16+
value,
17+
label: `${goal.slice(0, 50)}...`,
18+
})) || [];
19+
},
20+
},
21+
},
522
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
23+
_baseUrl() {
24+
return "https://api.twin.so";
25+
},
26+
_headers() {
27+
return {
28+
"x-api-key": this.$auth.api_key,
29+
};
30+
},
31+
_makeRequest({
32+
$ = this,
33+
path,
34+
...args
35+
}) {
36+
return axios($, {
37+
url: `${this._baseUrl()}${path}`,
38+
headers: this._headers(),
39+
...args,
40+
});
41+
},
42+
browse(args = {}) {
43+
return this._makeRequest({
44+
method: "POST",
45+
path: "/browse",
46+
...args,
47+
});
48+
},
49+
getTask({
50+
taskId, ...args
51+
}) {
52+
return this._makeRequest({
53+
path: `/task/${taskId}`,
54+
...args,
55+
});
56+
},
57+
listTasks(args = {}) {
58+
return this._makeRequest({
59+
path: "/tasks",
60+
...args,
61+
});
962
},
1063
},
11-
};
64+
};

docs-v2/pages/code/nodejs/index.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,27 @@ In general, if you just need to make an HTTP request but don't care about the re
352352

353353
You can return HTTP responses from [HTTP-triggered workflows](/workflows/steps/triggers/#http) using the [`$.respond()` function](/workflows/steps/triggers/#http-responses).
354354

355+
## Invoke another workflow
356+
357+
<Callout type="warning">
358+
This is an alpha feature and is subject to change without prior notice.
359+
</Callout>
360+
361+
You can invoke another workflow in your workspace with `$.flow.trigger`:
362+
363+
```
364+
await $.flow.trigger(
365+
workflowId, // your Pipedream workflow ID, e.g. p_abc123
366+
payload, // any JSON-serializable data
367+
)
368+
```
369+
370+
[Find your workflow's ID here.](/troubleshooting#where-do-i-find-my-workflows-id)
371+
372+
This invokes the workflow directly -- you don't need to configure a trigger, and the request does not leave the platform.
373+
374+
We also provide a [Trigger Workflow](https://pipedream.com/apps/helper-functions/actions/trigger-workflow) action in the [Helper Functions](https://pipedream.com/apps/helper-functions) app so you don't need to do it by code!
375+
355376
## Ending a workflow early
356377

357378
<VideoPlayer title="Conditionally run Workflows" src="https://www.youtube.com/embed/sajgIH3dG58" startAt="205" />

docs-v2/pages/troubleshooting.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ https://pipedream.com/@dylburger/p_abc123/edit
6262

6363
Your workflow's ID is the value that starts with `p_`. In this example: `p_abc123`.
6464

65+
## How do I invoke another workflow?
66+
67+
We provide a [Trigger Workflow](https://pipedream.com/apps/helper-functions/actions/trigger-workflow) action in the [Helper Functions](https://pipedream.com/apps/helper-functions) app. [See more here](/code/nodejs#invoke-another-workflow).
68+
69+
Another option is to make an HTTP request to a Pipedream HTTP webhook trigger.
70+
6571
## Where do I find my event source's ID?
6672

6773
Open [https://pipedream.com/sources](https://pipedream.com/sources) and click on your event source. Copy the URL that appears in your browser's address bar. For example:

pnpm-lock.yaml

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)