forked from restackio/examples-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduleWorkflow.ts
43 lines (35 loc) · 1021 Bytes
/
scheduleWorkflow.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { client } from "./src/client";
import { endEvent, feedbackEvent } from "./src/events";
async function scheduleWorkflow() {
try {
const workflowId = `${Date.now()}-HumanLoopWorkflow`;
const runId = await client.scheduleWorkflow({
workflowName: "humanLoopWorkflow",
workflowId,
});
const feedback = await client.sendWorkflowEvent({
workflow: {
workflowId,
runId,
},
event: {
name: feedbackEvent.name,
input: { feedback: "Hello, how are you?" },
},
});
console.log("Feedback:", feedback);
const end = await client.sendWorkflowEvent({
workflow: {
workflowId,
runId,
},
event: { name: endEvent.name, input: { end: true } },
});
console.log("End:", end);
process.exit(0); // Exit the process successfully
} catch (error) {
console.error("Error scheduling workflow:", error);
process.exit(1); // Exit the process with an error code
}
}
scheduleWorkflow();