Skip to content

Commit 23ebb94

Browse files
committed
init
1 parent 5638de2 commit 23ebb94

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import burstyai from "../../burstyai.app.mjs";
2+
3+
export default {
4+
key: "burstyai-run-workflow",
5+
name: "Run Workflow",
6+
description: "Triggers an AI workflow on BurstyAI. The specific workflow to run and optional parameters for the workflow can be configured. [See the documentation](https://burstyai.readme.io/reference)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
burstyai,
11+
workflow: {
12+
propDefinition: [
13+
burstyai,
14+
"workflow",
15+
],
16+
},
17+
parameters: {
18+
propDefinition: [
19+
burstyai,
20+
"parameters",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.burstyai.triggerWorkflow({
26+
workflow: this.workflow,
27+
parameters: this.parameters,
28+
});
29+
$.export("$summary", `Successfully triggered workflow ${this.workflow}`);
30+
return response;
31+
},
32+
};
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { axios } from "@pipedream/platform";
2+
3+
export default {
4+
type: "app",
5+
app: "burstyai",
6+
propDefinitions: {
7+
workflow: {
8+
type: "string",
9+
label: "Workflow",
10+
description: "The specific workflow to run",
11+
required: true,
12+
async options() {
13+
const workflows = await this.getWorkflows();
14+
return workflows.map((workflow) => ({
15+
label: workflow.name,
16+
value: workflow.id,
17+
}));
18+
},
19+
},
20+
parameters: {
21+
type: "object",
22+
label: "Parameters",
23+
description: "Optional parameters for the workflow",
24+
optional: true,
25+
},
26+
},
27+
methods: {
28+
_baseUrl() {
29+
return "https://app.burstyai.com";
30+
},
31+
async _makeRequest(opts = {}) {
32+
const {
33+
$ = this,
34+
method = "GET",
35+
path,
36+
headers,
37+
...otherOpts
38+
} = opts;
39+
return axios($, {
40+
...otherOpts,
41+
method,
42+
url: this._baseUrl() + path,
43+
headers: {
44+
...headers,
45+
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
46+
},
47+
});
48+
},
49+
async getWorkflows() {
50+
const res = await this._makeRequest({
51+
path: "/burstyai/aiflows",
52+
});
53+
return res;
54+
},
55+
async triggerWorkflow({
56+
workflow, parameters,
57+
}) {
58+
return this._makeRequest({
59+
method: "POST",
60+
path: `/burstyai/aiflows/${workflow}/async_run`,
61+
data: parameters,
62+
});
63+
},
64+
async getWorkflowExecutionResult(jobId) {
65+
return this._makeRequest({
66+
path: `/burstyai/aiflowjobs/${jobId}/result`,
67+
});
68+
},
69+
},
70+
};

0 commit comments

Comments
 (0)