Skip to content

Commit 472fe5d

Browse files
committed
screenshots
1 parent 5902b7a commit 472fe5d

File tree

5 files changed

+112
-3
lines changed

5 files changed

+112
-3
lines changed

agent-reactflow/README.md

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,91 @@ pnpm i
2929
pnpm run dev
3030
```
3131

32-
Leveraging turborepo, this will start both frontend and backend.
32+
Leveraging TurboRepo, this will start both frontend and backend.
3333
Your code will be running and syncing with Restack to execute agents.
3434

3535
## Run agents
3636

37-
### from frontend
37+
### From frontend
3838

39-
![Run agents from frontend](./agent-reactflow.png)
39+
![Run agents from frontend](./agent-reactflow.png)
40+
41+
### from UI
42+
43+
You can run agents from the UI by clicking the "Run" button.
44+
45+
![Run agents from UI](./agent-post.png)
46+
47+
### from API
48+
49+
You can run agents from the API by using the generated endpoint:
50+
51+
`POST http://localhost:6233/api/agents/agentFlow`
52+
53+
### from any client
54+
55+
You can run agents with any client connected to Restack, for example:
56+
57+
```bash
58+
pnpm schedule-agent
59+
```
60+
61+
executes `scheduleAgent.ts` which will connect to Restack and execute the `agentFlow` agent.
62+
63+
## Send events to the Agent
64+
65+
### from Backend Developer UI
66+
67+
You can send events like or end from the UI.
68+
69+
![Send events from UI](./agent-event.png)
70+
71+
And see the events in the run:
72+
73+
![See events in UI](./agent-run.png)
74+
75+
### from API
76+
77+
You can send events to the agent by using the following endpoint:
78+
79+
`PUT http://localhost:6233/api/agents/agentFlow/:agentId/:runId`
80+
81+
with the payload:
82+
83+
```json
84+
{
85+
"name": "idVerification",
86+
"input": {
87+
"type": "id",
88+
"documentNumber": "1234567890"
89+
}
90+
}
91+
```
92+
93+
to send messages to the agent.
94+
95+
or
96+
97+
```json
98+
{
99+
"eventName": "end"
100+
}
101+
```
102+
103+
to end the conversation with the agent.
104+
105+
### from any client
106+
107+
You can send event to the agent with any client connected to Restack, for example:
108+
109+
Modify agentId and runId in eventAgent.ts and then run:
110+
111+
```bash
112+
pnpm event-agent
113+
```
114+
115+
It will connect to Restack and send an events to the agent.
116+
117+
## Deploy on Restack Cloud
118+
119+
To deploy the application on Restack, you can create an account at [https://console.restack.io](https://console.restack.io)

agent-reactflow/agent-event.png

73.2 KB
Loading

agent-reactflow/agent-post.png

53 KB
Loading

agent-reactflow/agent-run.png

486 KB
Loading
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { client } from "./src/client";
2+
3+
export type InputSchedule = {
4+
name: string;
5+
};
6+
7+
async function scheduleAgent(input: InputSchedule) {
8+
try {
9+
const agentId = `${Date.now()}-agentFlow`;
10+
const runId = await client.scheduleAgent({
11+
agentName: "agentFlow",
12+
agentId,
13+
input,
14+
});
15+
16+
const result = await client.getAgentResult({ agentId, runId });
17+
18+
console.log("Agent result:", result);
19+
20+
process.exit(0); // Exit the process successfully
21+
} catch (error) {
22+
console.error("Error scheduling agent:", error);
23+
process.exit(1); // Exit the process with an error code
24+
}
25+
}
26+
27+
scheduleAgent({
28+
name: "test",
29+
});

0 commit comments

Comments
 (0)