-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy pathAgent_Node_Sample_Agent.json
324 lines (324 loc) · 9.01 KB
/
Agent_Node_Sample_Agent.json
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
{
"name": "Agent Node Sample Agent",
"nodes": [
{
"parameters": {
"respondWith": "allIncomingItems",
"options": {
"responseHeaders": {
"entries": [
{
"name": "X-n8n-Signature",
"value": "EvtIS^EBVISeie6svB@6ev"
}
]
}
}
},
"id": "c92dfb4d-571a-4e08-ba92-4216404ec455",
"name": "Respond to Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
1700,
400
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "ee2bcd57-3b4c-43f9-b4b7-3a25687b9a68",
"name": "query",
"value": "={{ $json.body.query }}",
"type": "string"
},
{
"id": "63f23e51-af2b-47c4-a288-5abaf9b6c357",
"name": "user_id",
"value": "={{ $json.body.user_id }}",
"type": "string"
},
{
"id": "b97a3670-8a87-481b-8695-db44624be7d8",
"name": "request_id",
"value": "={{ $json.body.request_id }}",
"type": "string"
},
{
"id": "7d3fa06d-08f7-4517-b9c5-3c46ff476f55",
"name": "session_id",
"value": "={{ $json.body.session_id }}",
"type": "string"
}
]
},
"options": {}
},
"id": "e423ed64-4664-4e34-b7c2-d71148963a24",
"name": "Prep Input Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
760,
400
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "b5eaa2a2-a6bc-40ab-af5e-baa8a5dda1a7",
"name": "success",
"value": "=true",
"type": "boolean"
}
]
},
"options": {}
},
"id": "5881a308-ab65-4034-a449-9c1f0d90743e",
"name": "Prep Output Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
1460,
400
]
},
{
"parameters": {
"model": "claude-3-5-haiku-20241022",
"options": {}
},
"id": "66920cf0-b301-4d0e-80ec-204696fdbf76",
"name": "Anthropic Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
"typeVersion": 1.2,
"position": [
980,
620
],
"credentials": {
"anthropicApi": {
"id": "AiDvkdxUFBeRQmnE",
"name": "Anthropic account"
}
}
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{$('Prep Input Fields').item.json.session_id}}",
"tableName": "messages",
"contextWindowLength": 10
},
"id": "1c06de3a-8fc4-4ccf-9dc7-b9f1f5bf692a",
"name": "Postgres Chat Memory",
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"typeVersion": 1.3,
"position": [
1100,
620
],
"credentials": {
"postgres": {
"id": "erIa9T64hNNeDuvB",
"name": "Prod Postgres account"
}
}
},
{
"parameters": {
"httpMethod": "POST",
"path": "d9fec84b-86f0-4230-9fd4-c1cb392ff8b5",
"authentication": "headerAuth",
"responseMode": "responseNode",
"options": {}
},
"id": "d6540989-6349-47aa-8c2a-8dd93b262b6e",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
500,
400
],
"webhookId": "d9fec84b-86f0-4230-9fd4-c1cb392ff8b5",
"credentials": {
"httpHeaderAuth": {
"id": "o5akNgXQQR74Sezh",
"name": "Header Auth account"
}
}
},
{
"parameters": {
"content": "# Agent Node Sample Agent\n\nAuthor: [Cole Medin](https://www.youtube.com/@ColeMedin)\n\nThis is a sample n8n workflow that demonstrates the minimal required components to build an agent for the oTTomator Live Agent Studio using the \"Agent\" node in n8n. The \"Agent\" node manages conversation history itself and is compatible with the Live Agent Studio.\n\n## Core Components\n\n1. **Webhook Endpoint**\n - Accepts POST requests with authentication\n - Processes incoming queries with user and session information\n - Provides secure communication via header authentication\n\n2. **Input Processing**\n - Extracts key fields from incoming requests:\n - query: The user's question or command\n - user_id: Unique identifier for the user\n - request_id: Request tracking ID\n - session_id: Current session identifier\n\n3. **Database Integration**\n - Uses Supabase for message storage\n - Records both user messages and AI responses\n - Maintains conversation history with metadata\n\n4. **Response Handling**\n - Structured response format for consistency\n - Includes success/failure status\n - Returns formatted responses via webhook",
"height": 763.4375,
"width": 589.875,
"color": 6
},
"id": "19bfc66c-0bfa-414c-b234-057b05873c75",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-160,
200
]
},
{
"parameters": {
"promptType": "define",
"text": "={{$('Prep Input Fields').item.json.query}}",
"options": {
"systemMessage": "=Enter your system message here..."
}
},
"id": "24599191-6cd2-4b7b-aade-cf45dd1ccbb6",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.7,
"position": [
1040,
400
]
},
{
"parameters": {
"content": "## Add your own agent tools and feel free to use any provider and LLM.",
"height": 100.31395348837148,
"width": 422.59302325581405,
"color": 6
},
"id": "0376123d-d772-4e74-a217-b1bac0e365fb",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
940,
760
]
}
],
"pinData": {
"Webhook": [
{
"json": {
"headers": {
"host": "n8n.[your n8n url].com",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
"content-length": "192",
"accept": "*/*",
"accept-encoding": "deflate, gzip",
"authorization": "Bearer YOUR BEARER TOKEN",
"content-type": "application/json",
"x-forwarded-for": "64.227.21.251",
"x-forwarded-host": "n8n.[your n8n url].com",
"x-forwarded-proto": "https",
"x-real-ip": "2601:441:4380:40b0:b4b3:724b:27e1:c4ba"
},
"params": {},
"query": {},
"body": {
"query": "Supabase",
"user_id": "google-oauth2|116467443974012389959",
"request_id": "f98asdyf987yasd0f987asdf8",
"session_id": "google-oauth2|116467443974012389959~2~8dfbddbe603d"
},
"webhookUrl": "https://n8n.[your n8n url].com/webhook-test/invoke-agent",
"executionMode": "test"
}
}
]
},
"connections": {
"Prep Output Fields": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"Anthropic Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Postgres Chat Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Prep Input Fields": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "Prep Input Fields",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Prep Output Fields",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "8e077fe3-9da1-496b-a2e5-18ae1676f71c",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "f65a08c0adc90a3cde2c633d24c6daecde3817033b75588ee10a781b0b7aa3f5"
},
"id": "a4lg63apQMOxsg5A",
"tags": [
{
"createdAt": "2024-12-10T13:21:06.912Z",
"updatedAt": "2024-12-10T13:21:06.912Z",
"id": "0tXJXfH2daB7QdK5",
"name": "studio-test"
}
]
}