n8n-mcp 2.96.1 → 2.97.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/http-server.d.ts.map +1 -1
  2. package/dist/http-server.js +3 -1
  3. package/dist/http-server.js.map +1 -1
  4. package/dist/mcp/native-first.d.ts +5 -0
  5. package/dist/mcp/native-first.d.ts.map +1 -0
  6. package/dist/mcp/native-first.js +28 -0
  7. package/dist/mcp/native-first.js.map +1 -0
  8. package/dist/mcp/server.d.ts +2 -1
  9. package/dist/mcp/server.d.ts.map +1 -1
  10. package/dist/mcp/server.js +50 -48
  11. package/dist/mcp/server.js.map +1 -1
  12. package/dist/mcp/tool-docs/discovery/search-nodes.d.ts.map +1 -1
  13. package/dist/mcp/tool-docs/discovery/search-nodes.js +5 -4
  14. package/dist/mcp/tool-docs/discovery/search-nodes.js.map +1 -1
  15. package/dist/mcp/tool-docs/guides/expression-helpers.d.ts +20 -0
  16. package/dist/mcp/tool-docs/guides/expression-helpers.d.ts.map +1 -0
  17. package/dist/mcp/tool-docs/guides/expression-helpers.js +164 -0
  18. package/dist/mcp/tool-docs/guides/expression-helpers.js.map +1 -0
  19. package/dist/mcp/tool-docs/system/tools-documentation.d.ts.map +1 -1
  20. package/dist/mcp/tool-docs/system/tools-documentation.js +6 -4
  21. package/dist/mcp/tool-docs/system/tools-documentation.js.map +1 -1
  22. package/dist/mcp/tools-documentation.d.ts.map +1 -1
  23. package/dist/mcp/tools-documentation.js +11 -7
  24. package/dist/mcp/tools-documentation.js.map +1 -1
  25. package/dist/mcp-tools-engine.js +3 -2
  26. package/dist/mcp-tools-engine.js.map +1 -1
  27. package/dist/parsers/version-display-gate.js +2 -0
  28. package/dist/parsers/version-display-gate.js.map +1 -1
  29. package/dist/services/property-filter.d.ts +23 -1
  30. package/dist/services/property-filter.d.ts.map +1 -1
  31. package/dist/services/property-filter.js +273 -17
  32. package/dist/services/property-filter.js.map +1 -1
  33. package/dist/services/search-intents.d.ts +9 -0
  34. package/dist/services/search-intents.d.ts.map +1 -0
  35. package/dist/services/search-intents.js +161 -0
  36. package/dist/services/search-intents.js.map +1 -0
  37. package/dist/services/workflow-validator.d.ts.map +1 -1
  38. package/dist/services/workflow-validator.js +0 -8
  39. package/dist/services/workflow-validator.js.map +1 -1
  40. package/dist/templates/template-repository.d.ts.map +1 -1
  41. package/dist/templates/template-repository.js +22 -26
  42. package/dist/templates/template-repository.js.map +1 -1
  43. package/dist/utils/template-node-resolver.js +2 -2
  44. package/dist/utils/template-node-resolver.js.map +1 -1
  45. package/package.json +2 -2
  46. package/dist/services/example-generator.d.ts +0 -14
  47. package/dist/services/example-generator.d.ts.map +0 -1
  48. package/dist/services/example-generator.js +0 -983
  49. package/dist/services/example-generator.js.map +0 -1
  50. package/dist/services/task-templates.d.ts +0 -27
  51. package/dist/services/task-templates.d.ts.map +0 -1
  52. package/dist/services/task-templates.js +0 -1414
  53. package/dist/services/task-templates.js.map +0 -1
@@ -1,1414 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TaskTemplates = void 0;
4
- class TaskTemplates {
5
- static getAllTasks() {
6
- return Object.keys(this.templates);
7
- }
8
- static getTasksForNode(nodeType) {
9
- return Object.entries(this.templates)
10
- .filter(([_, template]) => template.nodeType === nodeType)
11
- .map(([task, _]) => task);
12
- }
13
- static getTaskTemplate(task) {
14
- return this.templates[task];
15
- }
16
- static getTemplate(task) {
17
- return this.getTaskTemplate(task);
18
- }
19
- static searchTasks(keyword) {
20
- const lower = keyword.toLowerCase();
21
- return Object.entries(this.templates)
22
- .filter(([task, template]) => task.toLowerCase().includes(lower) ||
23
- template.description.toLowerCase().includes(lower) ||
24
- template.nodeType.toLowerCase().includes(lower))
25
- .map(([task, _]) => task);
26
- }
27
- static getTaskCategories() {
28
- return {
29
- 'HTTP/API': ['get_api_data', 'post_json_request', 'call_api_with_auth', 'api_call_with_retry'],
30
- 'Webhooks': ['receive_webhook', 'webhook_with_response', 'webhook_with_error_handling', 'process_webhook_data'],
31
- 'Database': ['query_postgres', 'insert_postgres_data', 'database_transaction_safety'],
32
- 'AI/LangChain': ['chat_with_ai', 'ai_agent_workflow', 'multi_tool_ai_agent', 'ai_rate_limit_handling'],
33
- 'Data Processing': ['transform_data', 'filter_data', 'fault_tolerant_processing', 'process_webhook_data'],
34
- 'Communication': ['send_slack_message', 'send_email'],
35
- 'AI Tool Usage': ['use_google_sheets_as_tool', 'use_slack_as_tool', 'multi_tool_ai_agent'],
36
- 'Error Handling': ['modern_error_handling_patterns', 'api_call_with_retry', 'fault_tolerant_processing', 'webhook_with_error_handling', 'database_transaction_safety', 'ai_rate_limit_handling']
37
- };
38
- }
39
- }
40
- exports.TaskTemplates = TaskTemplates;
41
- TaskTemplates.templates = {
42
- 'get_api_data': {
43
- task: 'get_api_data',
44
- description: 'Make a simple GET request to retrieve data from an API',
45
- nodeType: 'nodes-base.httpRequest',
46
- configuration: {
47
- method: 'GET',
48
- url: '',
49
- authentication: 'none',
50
- onError: 'continueRegularOutput',
51
- retryOnFail: true,
52
- maxTries: 3,
53
- waitBetweenTries: 1000,
54
- alwaysOutputData: true
55
- },
56
- userMustProvide: [
57
- {
58
- property: 'url',
59
- description: 'The API endpoint URL',
60
- example: 'https://api.example.com/users'
61
- }
62
- ],
63
- optionalEnhancements: [
64
- {
65
- property: 'authentication',
66
- description: 'Add authentication if the API requires it',
67
- when: 'API requires authentication'
68
- },
69
- {
70
- property: 'sendHeaders',
71
- description: 'Add custom headers if needed',
72
- when: 'API requires specific headers'
73
- },
74
- {
75
- property: 'alwaysOutputData',
76
- description: 'Set to true to capture error responses',
77
- when: 'Need to debug API errors'
78
- }
79
- ]
80
- },
81
- 'post_json_request': {
82
- task: 'post_json_request',
83
- description: 'Send JSON data to an API endpoint',
84
- nodeType: 'nodes-base.httpRequest',
85
- configuration: {
86
- method: 'POST',
87
- url: '',
88
- sendBody: true,
89
- contentType: 'json',
90
- specifyBody: 'json',
91
- jsonBody: '',
92
- onError: 'continueRegularOutput',
93
- retryOnFail: true,
94
- maxTries: 2,
95
- waitBetweenTries: 1000,
96
- alwaysOutputData: true
97
- },
98
- userMustProvide: [
99
- {
100
- property: 'url',
101
- description: 'The API endpoint URL',
102
- example: 'https://api.example.com/users'
103
- },
104
- {
105
- property: 'jsonBody',
106
- description: 'The JSON data to send',
107
- example: '{\n "name": "John Doe",\n "email": "john@example.com"\n}'
108
- }
109
- ],
110
- optionalEnhancements: [
111
- {
112
- property: 'authentication',
113
- description: 'Add authentication if required'
114
- },
115
- {
116
- property: 'onError',
117
- description: 'Set to "continueRegularOutput" for non-critical operations',
118
- when: 'Failure should not stop the workflow'
119
- }
120
- ],
121
- notes: [
122
- 'Make sure jsonBody contains valid JSON',
123
- 'Content-Type header is automatically set to application/json',
124
- 'Be careful with retries on non-idempotent operations'
125
- ]
126
- },
127
- 'call_api_with_auth': {
128
- task: 'call_api_with_auth',
129
- description: 'Make an authenticated API request',
130
- nodeType: 'nodes-base.httpRequest',
131
- configuration: {
132
- method: 'GET',
133
- url: '',
134
- authentication: 'genericCredentialType',
135
- genericAuthType: 'headerAuth',
136
- sendHeaders: true,
137
- onError: 'continueErrorOutput',
138
- retryOnFail: true,
139
- maxTries: 3,
140
- waitBetweenTries: 2000,
141
- alwaysOutputData: true,
142
- headerParameters: {
143
- parameters: [
144
- {
145
- name: '',
146
- value: ''
147
- }
148
- ]
149
- }
150
- },
151
- userMustProvide: [
152
- {
153
- property: 'url',
154
- description: 'The API endpoint URL'
155
- },
156
- {
157
- property: 'headerParameters.parameters[0].name',
158
- description: 'The header name for authentication',
159
- example: 'Authorization'
160
- },
161
- {
162
- property: 'headerParameters.parameters[0].value',
163
- description: 'The authentication value',
164
- example: 'Bearer YOUR_API_KEY'
165
- }
166
- ],
167
- optionalEnhancements: [
168
- {
169
- property: 'method',
170
- description: 'Change to POST/PUT/DELETE as needed'
171
- }
172
- ]
173
- },
174
- 'receive_webhook': {
175
- task: 'receive_webhook',
176
- description: 'Set up a webhook to receive data from external services',
177
- nodeType: 'nodes-base.webhook',
178
- configuration: {
179
- httpMethod: 'POST',
180
- path: 'webhook',
181
- responseMode: 'lastNode',
182
- responseData: 'allEntries',
183
- onError: 'continueRegularOutput',
184
- alwaysOutputData: true
185
- },
186
- userMustProvide: [
187
- {
188
- property: 'path',
189
- description: 'The webhook path (will be appended to your n8n URL)',
190
- example: 'github-webhook'
191
- }
192
- ],
193
- optionalEnhancements: [
194
- {
195
- property: 'httpMethod',
196
- description: 'Change if the service sends GET/PUT/etc'
197
- },
198
- {
199
- property: 'responseCode',
200
- description: 'Set custom response code (default 200)'
201
- }
202
- ],
203
- notes: [
204
- 'The full webhook URL will be: https://your-n8n.com/webhook/[path]',
205
- 'Test URL will be different from production URL'
206
- ]
207
- },
208
- 'webhook_with_response': {
209
- task: 'webhook_with_response',
210
- description: 'Receive webhook and send custom response',
211
- nodeType: 'nodes-base.webhook',
212
- configuration: {
213
- httpMethod: 'POST',
214
- path: 'webhook',
215
- responseMode: 'responseNode',
216
- responseData: 'firstEntryJson',
217
- responseCode: 200,
218
- onError: 'continueRegularOutput',
219
- alwaysOutputData: true
220
- },
221
- userMustProvide: [
222
- {
223
- property: 'path',
224
- description: 'The webhook path'
225
- }
226
- ],
227
- notes: [
228
- 'Use with a Respond to Webhook node to send custom response',
229
- 'responseMode: responseNode requires a Respond to Webhook node'
230
- ]
231
- },
232
- 'process_webhook_data': {
233
- task: 'process_webhook_data',
234
- description: 'Process incoming webhook data with Code node (shows correct data access)',
235
- nodeType: 'nodes-base.code',
236
- configuration: {
237
- language: 'javaScript',
238
- jsCode: `// ⚠️ CRITICAL: Webhook data is nested under 'body' property!
239
- // Connect this Code node after a Webhook node
240
-
241
- // Access webhook payload data - it's under .body, not directly under .json
242
- const webhookData = items[0].json.body; // ✅ CORRECT
243
- const headers = items[0].json.headers; // HTTP headers
244
- const query = items[0].json.query; // Query parameters
245
-
246
- // Common mistake to avoid:
247
- // const command = items[0].json.testCommand; // ❌ WRONG - will be undefined!
248
- // const command = items[0].json.body.testCommand; // ✅ CORRECT
249
-
250
- // Process the webhook data
251
- try {
252
- // Validate required fields
253
- if (!webhookData.command) {
254
- throw new Error('Missing required field: command');
255
- }
256
-
257
- // Process based on command
258
- let result = {};
259
- switch (webhookData.command) {
260
- case 'process':
261
- result = {
262
- status: 'processed',
263
- data: webhookData.data,
264
- processedAt: DateTime.now().toISO()
265
- };
266
- break;
267
-
268
- case 'validate':
269
- result = {
270
- status: 'validated',
271
- isValid: true,
272
- validatedFields: Object.keys(webhookData.data || {})
273
- };
274
- break;
275
-
276
- default:
277
- result = {
278
- status: 'unknown_command',
279
- command: webhookData.command
280
- };
281
- }
282
-
283
- // Return processed data
284
- return [{
285
- json: {
286
- ...result,
287
- requestId: headers['x-request-id'] || crypto.randomUUID(),
288
- source: query.source || 'webhook',
289
- originalCommand: webhookData.command,
290
- metadata: {
291
- httpMethod: items[0].json.httpMethod,
292
- webhookPath: items[0].json.webhookPath,
293
- timestamp: DateTime.now().toISO()
294
- }
295
- }
296
- }];
297
-
298
- } catch (error) {
299
- // Return error response
300
- return [{
301
- json: {
302
- status: 'error',
303
- error: error.message,
304
- timestamp: DateTime.now().toISO()
305
- }
306
- }];
307
- }`,
308
- onError: 'continueRegularOutput'
309
- },
310
- userMustProvide: [],
311
- notes: [
312
- '⚠️ WEBHOOK DATA IS AT items[0].json.body, NOT items[0].json',
313
- 'This is the most common webhook processing mistake',
314
- 'Headers are at items[0].json.headers',
315
- 'Query parameters are at items[0].json.query',
316
- 'Connect this Code node directly after a Webhook node'
317
- ]
318
- },
319
- 'query_postgres': {
320
- task: 'query_postgres',
321
- description: 'Query data from PostgreSQL database',
322
- nodeType: 'nodes-base.postgres',
323
- configuration: {
324
- operation: 'executeQuery',
325
- query: '',
326
- onError: 'continueRegularOutput',
327
- retryOnFail: true,
328
- maxTries: 3,
329
- waitBetweenTries: 1000
330
- },
331
- userMustProvide: [
332
- {
333
- property: 'query',
334
- description: 'The SQL query to execute',
335
- example: 'SELECT * FROM users WHERE active = true LIMIT 10'
336
- }
337
- ],
338
- optionalEnhancements: [
339
- {
340
- property: 'additionalFields.queryParams',
341
- description: 'Use parameterized queries for security',
342
- when: 'Using dynamic values'
343
- }
344
- ],
345
- notes: [
346
- 'Always use parameterized queries to prevent SQL injection',
347
- 'Configure PostgreSQL credentials in n8n'
348
- ]
349
- },
350
- 'insert_postgres_data': {
351
- task: 'insert_postgres_data',
352
- description: 'Insert data into PostgreSQL table',
353
- nodeType: 'nodes-base.postgres',
354
- configuration: {
355
- operation: 'insert',
356
- table: '',
357
- columns: '',
358
- returnFields: '*',
359
- onError: 'stopWorkflow',
360
- retryOnFail: true,
361
- maxTries: 2,
362
- waitBetweenTries: 1000
363
- },
364
- userMustProvide: [
365
- {
366
- property: 'table',
367
- description: 'The table name',
368
- example: 'users'
369
- },
370
- {
371
- property: 'columns',
372
- description: 'Comma-separated column names',
373
- example: 'name,email,created_at'
374
- }
375
- ],
376
- notes: [
377
- 'Input data should match the column structure',
378
- 'Use expressions like {{ $json.fieldName }} to map data'
379
- ]
380
- },
381
- 'chat_with_ai': {
382
- task: 'chat_with_ai',
383
- description: 'Send a message to an AI model and get response',
384
- nodeType: 'nodes-base.openAi',
385
- configuration: {
386
- resource: 'chat',
387
- operation: 'message',
388
- modelId: 'gpt-3.5-turbo',
389
- messages: {
390
- values: [
391
- {
392
- role: 'user',
393
- content: ''
394
- }
395
- ]
396
- },
397
- onError: 'continueRegularOutput',
398
- retryOnFail: true,
399
- maxTries: 3,
400
- waitBetweenTries: 5000,
401
- alwaysOutputData: true
402
- },
403
- userMustProvide: [
404
- {
405
- property: 'messages.values[0].content',
406
- description: 'The message to send to the AI',
407
- example: '{{ $json.userMessage }}'
408
- }
409
- ],
410
- optionalEnhancements: [
411
- {
412
- property: 'modelId',
413
- description: 'Change to gpt-4 for better results'
414
- },
415
- {
416
- property: 'options.temperature',
417
- description: 'Adjust creativity (0-1)'
418
- },
419
- {
420
- property: 'options.maxTokens',
421
- description: 'Limit response length'
422
- }
423
- ]
424
- },
425
- 'ai_agent_workflow': {
426
- task: 'ai_agent_workflow',
427
- description: 'Create an AI agent that can use tools',
428
- nodeType: '@n8n/n8n-nodes-langchain.agent',
429
- configuration: {
430
- promptType: 'define',
431
- text: '={{ $json.query }}',
432
- options: {
433
- systemMessage: 'You are a helpful assistant.'
434
- }
435
- },
436
- userMustProvide: [
437
- {
438
- property: 'text',
439
- description: 'The input prompt for the agent',
440
- example: '={{ $json.query }}'
441
- }
442
- ],
443
- optionalEnhancements: [
444
- {
445
- property: 'options.systemMessage',
446
- description: 'Customize the agent\'s behavior'
447
- }
448
- ],
449
- notes: [
450
- 'Connect tool nodes to give the agent capabilities',
451
- 'Configure the AI model credentials'
452
- ]
453
- },
454
- 'transform_data': {
455
- task: 'transform_data',
456
- description: 'Transform data structure using JavaScript',
457
- nodeType: 'nodes-base.code',
458
- configuration: {
459
- language: 'javaScript',
460
- jsCode: `// Transform each item
461
- const results = [];
462
-
463
- for (const item of items) {
464
- results.push({
465
- json: {
466
- // Transform your data here
467
- id: item.json.id,
468
- processedAt: new Date().toISOString()
469
- }
470
- });
471
- }
472
-
473
- return results;`
474
- },
475
- userMustProvide: [],
476
- notes: [
477
- 'Access input data via items array',
478
- 'Each item has a json property with the data',
479
- 'Return array of objects with json property'
480
- ]
481
- },
482
- 'filter_data': {
483
- task: 'filter_data',
484
- description: 'Filter items based on conditions',
485
- nodeType: 'nodes-base.if',
486
- configuration: {
487
- conditions: {
488
- options: {
489
- version: 2,
490
- leftValue: '',
491
- caseSensitive: true,
492
- typeValidation: 'strict'
493
- },
494
- combinator: 'and',
495
- conditions: [
496
- {
497
- id: '1',
498
- leftValue: '',
499
- rightValue: '',
500
- operator: {
501
- type: 'string',
502
- operation: 'equals'
503
- }
504
- }
505
- ]
506
- }
507
- },
508
- userMustProvide: [
509
- {
510
- property: 'conditions.conditions[0].leftValue',
511
- description: 'The value to check',
512
- example: '{{ $json.status }}'
513
- },
514
- {
515
- property: 'conditions.conditions[0].rightValue',
516
- description: 'The value to compare against',
517
- example: 'active'
518
- }
519
- ],
520
- notes: [
521
- 'True output contains matching items',
522
- 'False output contains non-matching items'
523
- ]
524
- },
525
- 'send_slack_message': {
526
- task: 'send_slack_message',
527
- description: 'Send a message to Slack channel',
528
- nodeType: 'nodes-base.slack',
529
- configuration: {
530
- resource: 'message',
531
- operation: 'post',
532
- channel: '',
533
- text: '',
534
- onError: 'continueRegularOutput',
535
- retryOnFail: true,
536
- maxTries: 2,
537
- waitBetweenTries: 2000
538
- },
539
- userMustProvide: [
540
- {
541
- property: 'channel',
542
- description: 'The Slack channel',
543
- example: '#general'
544
- },
545
- {
546
- property: 'text',
547
- description: 'The message text',
548
- example: 'New order received: {{ $json.orderId }}'
549
- }
550
- ],
551
- optionalEnhancements: [
552
- {
553
- property: 'attachments',
554
- description: 'Add rich message attachments'
555
- },
556
- {
557
- property: 'blocks',
558
- description: 'Use Block Kit for advanced formatting'
559
- }
560
- ]
561
- },
562
- 'send_email': {
563
- task: 'send_email',
564
- description: 'Send an email notification',
565
- nodeType: 'nodes-base.emailSend',
566
- configuration: {
567
- fromEmail: '',
568
- toEmail: '',
569
- subject: '',
570
- text: '',
571
- onError: 'continueRegularOutput',
572
- retryOnFail: true,
573
- maxTries: 3,
574
- waitBetweenTries: 3000,
575
- alwaysOutputData: true
576
- },
577
- userMustProvide: [
578
- {
579
- property: 'fromEmail',
580
- description: 'Sender email address',
581
- example: 'notifications@company.com'
582
- },
583
- {
584
- property: 'toEmail',
585
- description: 'Recipient email address',
586
- example: '{{ $json.customerEmail }}'
587
- },
588
- {
589
- property: 'subject',
590
- description: 'Email subject',
591
- example: 'Order Confirmation #{{ $json.orderId }}'
592
- },
593
- {
594
- property: 'text',
595
- description: 'Email body (plain text)',
596
- example: 'Thank you for your order!'
597
- }
598
- ],
599
- optionalEnhancements: [
600
- {
601
- property: 'html',
602
- description: 'Use HTML for rich formatting'
603
- },
604
- {
605
- property: 'attachments',
606
- description: 'Attach files to the email'
607
- }
608
- ]
609
- },
610
- 'use_google_sheets_as_tool': {
611
- task: 'use_google_sheets_as_tool',
612
- description: 'Use Google Sheets as an AI tool for reading/writing data',
613
- nodeType: 'nodes-base.googleSheets',
614
- configuration: {
615
- operation: 'append',
616
- sheetId: '={{ $fromAI("sheetId", "The Google Sheets ID") }}',
617
- range: '={{ $fromAI("range", "The range to append to, e.g. A:Z") }}',
618
- dataMode: 'autoMap'
619
- },
620
- userMustProvide: [
621
- {
622
- property: 'Google Sheets credentials',
623
- description: 'Configure Google Sheets API credentials in n8n'
624
- },
625
- {
626
- property: 'Tool name in AI Agent',
627
- description: 'Give it a descriptive name like "Log Results to Sheet"'
628
- },
629
- {
630
- property: 'Tool description',
631
- description: 'Describe when and how the AI should use this tool'
632
- }
633
- ],
634
- notes: [
635
- 'Connect this node to the ai_tool port of an AI Agent node',
636
- 'The AI can dynamically determine sheetId and range using $fromAI',
637
- 'Works great for logging AI analysis results or reading data for processing'
638
- ]
639
- },
640
- 'use_slack_as_tool': {
641
- task: 'use_slack_as_tool',
642
- description: 'Use Slack as an AI tool for sending notifications',
643
- nodeType: 'nodes-base.slack',
644
- configuration: {
645
- resource: 'message',
646
- operation: 'post',
647
- channel: '={{ $fromAI("channel", "The Slack channel, e.g. #general") }}',
648
- text: '={{ $fromAI("message", "The message to send") }}',
649
- attachments: []
650
- },
651
- userMustProvide: [
652
- {
653
- property: 'Slack credentials',
654
- description: 'Configure Slack OAuth2 credentials in n8n'
655
- },
656
- {
657
- property: 'Tool configuration in AI Agent',
658
- description: 'Name it something like "Send Slack Notification"'
659
- }
660
- ],
661
- notes: [
662
- 'Perfect for AI agents that need to notify teams',
663
- 'The AI determines channel and message content dynamically',
664
- 'Can be enhanced with blocks for rich formatting'
665
- ]
666
- },
667
- 'multi_tool_ai_agent': {
668
- task: 'multi_tool_ai_agent',
669
- description: 'AI agent with multiple tools for complex automation',
670
- nodeType: '@n8n/n8n-nodes-langchain.agent',
671
- configuration: {
672
- promptType: 'define',
673
- text: '={{ $json.query }}',
674
- options: {
675
- systemMessage: 'You are an intelligent assistant with access to multiple tools. Use them wisely to complete tasks.'
676
- }
677
- },
678
- userMustProvide: [
679
- {
680
- property: 'AI model credentials',
681
- description: 'OpenAI, Anthropic, or other LLM credentials'
682
- },
683
- {
684
- property: 'Multiple tool nodes',
685
- description: 'Connect various nodes to the ai_tool port'
686
- },
687
- {
688
- property: 'Tool descriptions',
689
- description: 'Clear descriptions for each connected tool'
690
- }
691
- ],
692
- optionalEnhancements: [
693
- {
694
- property: 'Memory',
695
- description: 'Add memory nodes for conversation context'
696
- },
697
- {
698
- property: 'Custom tools',
699
- description: 'Create Code nodes as custom tools'
700
- }
701
- ],
702
- notes: [
703
- 'Connect multiple nodes: HTTP Request, Slack, Google Sheets, etc.',
704
- 'Each tool should have a clear, specific purpose',
705
- 'Test each tool individually before combining',
706
- 'Set N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true for community nodes'
707
- ]
708
- },
709
- 'api_call_with_retry': {
710
- task: 'api_call_with_retry',
711
- description: 'Resilient API call with automatic retry on failure',
712
- nodeType: 'nodes-base.httpRequest',
713
- configuration: {
714
- method: 'GET',
715
- url: '',
716
- retryOnFail: true,
717
- maxTries: 5,
718
- waitBetweenTries: 2000,
719
- alwaysOutputData: true,
720
- sendHeaders: true,
721
- headerParameters: {
722
- parameters: [
723
- {
724
- name: 'X-Request-ID',
725
- value: '={{ $workflow.id }}-{{ $itemIndex }}'
726
- }
727
- ]
728
- }
729
- },
730
- userMustProvide: [
731
- {
732
- property: 'url',
733
- description: 'The API endpoint to call',
734
- example: 'https://api.example.com/resource/{{ $json.id }}'
735
- }
736
- ],
737
- optionalEnhancements: [
738
- {
739
- property: 'authentication',
740
- description: 'Add API authentication'
741
- },
742
- {
743
- property: 'onError',
744
- description: 'Change to "stopWorkflow" for critical API calls',
745
- when: 'This is a critical API call that must succeed'
746
- }
747
- ],
748
- notes: [
749
- 'Retries help with rate limits and transient network issues',
750
- 'waitBetweenTries prevents hammering the API',
751
- 'alwaysOutputData captures error responses for debugging',
752
- 'Consider exponential backoff for production use'
753
- ]
754
- },
755
- 'fault_tolerant_processing': {
756
- task: 'fault_tolerant_processing',
757
- description: 'Data processing that continues despite individual item failures',
758
- nodeType: 'nodes-base.code',
759
- configuration: {
760
- language: 'javaScript',
761
- jsCode: `// Process items with error handling
762
- const results = [];
763
-
764
- for (const item of items) {
765
- try {
766
- // Your processing logic here
767
- const processed = {
768
- ...item.json,
769
- processed: true,
770
- timestamp: new Date().toISOString()
771
- };
772
-
773
- results.push({ json: processed });
774
- } catch (error) {
775
- // Log error but continue processing
776
- console.error('Processing failed for item:', item.json.id, error);
777
-
778
- // Add error item to results
779
- results.push({
780
- json: {
781
- ...item.json,
782
- error: error.message,
783
- processed: false
784
- }
785
- });
786
- }
787
- }
788
-
789
- return results;`,
790
- onError: 'continueRegularOutput',
791
- alwaysOutputData: true
792
- },
793
- userMustProvide: [
794
- {
795
- property: 'Processing logic',
796
- description: 'Replace the comment with your data transformation logic'
797
- }
798
- ],
799
- optionalEnhancements: [
800
- {
801
- property: 'Error notification',
802
- description: 'Add IF node after to handle error items separately'
803
- }
804
- ],
805
- notes: [
806
- 'Individual item failures won\'t stop processing of other items',
807
- 'Error items are marked and can be handled separately',
808
- 'continueOnFail ensures workflow continues even on total failure'
809
- ]
810
- },
811
- 'webhook_with_error_handling': {
812
- task: 'webhook_with_error_handling',
813
- description: 'Webhook that gracefully handles processing errors',
814
- nodeType: 'nodes-base.webhook',
815
- configuration: {
816
- httpMethod: 'POST',
817
- path: 'resilient-webhook',
818
- responseMode: 'responseNode',
819
- responseData: 'firstEntryJson',
820
- onError: 'continueRegularOutput',
821
- alwaysOutputData: true
822
- },
823
- userMustProvide: [
824
- {
825
- property: 'path',
826
- description: 'Unique webhook path',
827
- example: 'order-processor'
828
- },
829
- {
830
- property: 'Respond to Webhook node',
831
- description: 'Add node to send appropriate success/error responses'
832
- }
833
- ],
834
- optionalEnhancements: [
835
- {
836
- property: 'Validation',
837
- description: 'Add IF node to validate webhook payload'
838
- },
839
- {
840
- property: 'Error logging',
841
- description: 'Add error handler node for failed requests'
842
- }
843
- ],
844
- notes: [
845
- 'onError: continueRegularOutput ensures webhook always sends a response',
846
- 'Use Respond to Webhook node to send appropriate status codes',
847
- 'Log errors but don\'t expose internal errors to webhook callers',
848
- 'Consider rate limiting for public webhooks'
849
- ]
850
- },
851
- 'modern_error_handling_patterns': {
852
- task: 'modern_error_handling_patterns',
853
- description: 'Examples of modern error handling using onError property',
854
- nodeType: 'nodes-base.httpRequest',
855
- configuration: {
856
- method: 'GET',
857
- url: '',
858
- onError: 'continueRegularOutput',
859
- retryOnFail: true,
860
- maxTries: 3,
861
- waitBetweenTries: 2000,
862
- alwaysOutputData: true
863
- },
864
- userMustProvide: [
865
- {
866
- property: 'url',
867
- description: 'The API endpoint'
868
- },
869
- {
870
- property: 'onError',
871
- description: 'Choose error handling strategy',
872
- example: 'continueRegularOutput'
873
- }
874
- ],
875
- notes: [
876
- 'onError replaces the deprecated continueOnFail property',
877
- 'continueRegularOutput: Continue with normal output on error',
878
- 'continueErrorOutput: Route errors to error output for special handling',
879
- 'stopWorkflow: Stop the entire workflow on error',
880
- 'Combine with retryOnFail for resilient workflows'
881
- ]
882
- },
883
- 'database_transaction_safety': {
884
- task: 'database_transaction_safety',
885
- description: 'Database operations with proper error handling',
886
- nodeType: 'nodes-base.postgres',
887
- configuration: {
888
- operation: 'executeQuery',
889
- query: 'BEGIN; INSERT INTO orders ...; COMMIT;',
890
- onError: 'continueErrorOutput',
891
- retryOnFail: false,
892
- alwaysOutputData: true
893
- },
894
- userMustProvide: [
895
- {
896
- property: 'query',
897
- description: 'Your SQL query or transaction'
898
- }
899
- ],
900
- notes: [
901
- 'Transactions should not be retried automatically',
902
- 'Use continueErrorOutput to handle errors separately',
903
- 'Consider implementing compensating transactions',
904
- 'Always log transaction failures for audit'
905
- ]
906
- },
907
- 'ai_rate_limit_handling': {
908
- task: 'ai_rate_limit_handling',
909
- description: 'AI API calls with rate limit handling',
910
- nodeType: 'nodes-base.openAi',
911
- configuration: {
912
- resource: 'chat',
913
- operation: 'message',
914
- modelId: 'gpt-4',
915
- messages: {
916
- values: [
917
- {
918
- role: 'user',
919
- content: ''
920
- }
921
- ]
922
- },
923
- onError: 'continueRegularOutput',
924
- retryOnFail: true,
925
- maxTries: 5,
926
- waitBetweenTries: 5000,
927
- alwaysOutputData: true
928
- },
929
- userMustProvide: [
930
- {
931
- property: 'messages.values[0].content',
932
- description: 'The prompt for the AI'
933
- }
934
- ],
935
- notes: [
936
- 'AI APIs often have rate limits',
937
- 'Longer wait times help avoid hitting limits',
938
- 'Consider implementing exponential backoff in Code node',
939
- 'Monitor usage to stay within quotas'
940
- ]
941
- },
942
- 'custom_ai_tool': {
943
- task: 'custom_ai_tool',
944
- description: 'Create a custom tool for AI agents using Code node',
945
- nodeType: 'nodes-base.code',
946
- configuration: {
947
- language: 'javaScript',
948
- mode: 'runOnceForEachItem',
949
- jsCode: `// Custom AI Tool - Example: Text Analysis
950
- // This code will be called by AI agents with $json containing the input
951
-
952
- // Access the input from the AI agent
953
- const text = $json.text || '';
954
- const operation = $json.operation || 'analyze';
955
-
956
- // Perform the requested operation
957
- let result = {};
958
-
959
- switch (operation) {
960
- case 'wordCount':
961
- result = {
962
- wordCount: text.split(/\\s+/).filter(word => word.length > 0).length,
963
- characterCount: text.length,
964
- lineCount: text.split('\\n').length
965
- };
966
- break;
967
-
968
- case 'extract':
969
- // Extract specific patterns (emails, URLs, etc.)
970
- result = {
971
- emails: text.match(/[\\w.-]+@[\\w.-]+\\.\\w+/g) || [],
972
- urls: text.match(/https?:\\/\\/[^\\s]+/g) || [],
973
- numbers: text.match(/\\b\\d+\\b/g) || []
974
- };
975
- break;
976
-
977
- default:
978
- result = {
979
- error: 'Unknown operation',
980
- availableOperations: ['wordCount', 'extract']
981
- };
982
- }
983
-
984
- return [{
985
- json: {
986
- ...result,
987
- originalText: text,
988
- operation: operation,
989
- processedAt: DateTime.now().toISO()
990
- }
991
- }];`,
992
- onError: 'continueRegularOutput'
993
- },
994
- userMustProvide: [],
995
- notes: [
996
- 'Connect this to AI Agent node\'s tool input',
997
- 'AI will pass data in $json',
998
- 'Use "Run Once for Each Item" mode for AI tools',
999
- 'Return structured data the AI can understand'
1000
- ]
1001
- },
1002
- 'aggregate_data': {
1003
- task: 'aggregate_data',
1004
- description: 'Aggregate data from multiple items into summary statistics',
1005
- nodeType: 'nodes-base.code',
1006
- configuration: {
1007
- language: 'javaScript',
1008
- jsCode: `// Aggregate data from all items
1009
- const stats = {
1010
- count: 0,
1011
- sum: 0,
1012
- min: Infinity,
1013
- max: -Infinity,
1014
- values: [],
1015
- categories: {},
1016
- errors: []
1017
- };
1018
-
1019
- // Process each item
1020
- for (const item of items) {
1021
- try {
1022
- const value = item.json.value || item.json.amount || 0;
1023
- const category = item.json.category || 'uncategorized';
1024
-
1025
- stats.count++;
1026
- stats.sum += value;
1027
- stats.min = Math.min(stats.min, value);
1028
- stats.max = Math.max(stats.max, value);
1029
- stats.values.push(value);
1030
-
1031
- // Count by category
1032
- stats.categories[category] = (stats.categories[category] || 0) + 1;
1033
-
1034
- } catch (error) {
1035
- stats.errors.push({
1036
- item: item.json,
1037
- error: error.message
1038
- });
1039
- }
1040
- }
1041
-
1042
- // Calculate additional statistics
1043
- const average = stats.count > 0 ? stats.sum / stats.count : 0;
1044
- const sorted = [...stats.values].sort((a, b) => a - b);
1045
- const median = sorted.length > 0
1046
- ? sorted[Math.floor(sorted.length / 2)]
1047
- : 0;
1048
-
1049
- return [{
1050
- json: {
1051
- totalItems: stats.count,
1052
- sum: stats.sum,
1053
- average: average,
1054
- median: median,
1055
- min: stats.min === Infinity ? 0 : stats.min,
1056
- max: stats.max === -Infinity ? 0 : stats.max,
1057
- categoryCounts: stats.categories,
1058
- errorCount: stats.errors.length,
1059
- errors: stats.errors,
1060
- processedAt: DateTime.now().toISO()
1061
- }
1062
- }];`,
1063
- onError: 'continueRegularOutput'
1064
- },
1065
- userMustProvide: [],
1066
- notes: [
1067
- 'Assumes items have "value" or "amount" field',
1068
- 'Groups by "category" field if present',
1069
- 'Returns single item with all statistics',
1070
- 'Handles errors gracefully'
1071
- ]
1072
- },
1073
- 'batch_process_with_api': {
1074
- task: 'batch_process_with_api',
1075
- description: 'Process items in batches with API calls',
1076
- nodeType: 'nodes-base.code',
1077
- configuration: {
1078
- language: 'javaScript',
1079
- jsCode: `// Batch process items with API calls
1080
- const BATCH_SIZE = 10;
1081
- const API_URL = 'https://api.example.com/batch-process'; // USER MUST UPDATE
1082
- const results = [];
1083
-
1084
- // Process items in batches
1085
- for (let i = 0; i < items.length; i += BATCH_SIZE) {
1086
- const batch = items.slice(i, i + BATCH_SIZE);
1087
-
1088
- try {
1089
- // Prepare batch data
1090
- const batchData = batch.map(item => ({
1091
- id: item.json.id,
1092
- data: item.json
1093
- }));
1094
-
1095
- // Make API request for batch
1096
- const response = await $helpers.httpRequest({
1097
- method: 'POST',
1098
- url: API_URL,
1099
- body: {
1100
- items: batchData
1101
- },
1102
- headers: {
1103
- 'Content-Type': 'application/json'
1104
- }
1105
- });
1106
-
1107
- // Add results
1108
- if (response.results && Array.isArray(response.results)) {
1109
- response.results.forEach((result, index) => {
1110
- results.push({
1111
- json: {
1112
- ...batch[index].json,
1113
- ...result,
1114
- batchNumber: Math.floor(i / BATCH_SIZE) + 1,
1115
- processedAt: DateTime.now().toISO()
1116
- }
1117
- });
1118
- });
1119
- }
1120
-
1121
- // Add delay between batches to avoid rate limits
1122
- if (i + BATCH_SIZE < items.length) {
1123
- await new Promise(resolve => setTimeout(resolve, 1000));
1124
- }
1125
-
1126
- } catch (error) {
1127
- // Add failed batch items with error
1128
- batch.forEach(item => {
1129
- results.push({
1130
- json: {
1131
- ...item.json,
1132
- error: error.message,
1133
- status: 'failed',
1134
- batchNumber: Math.floor(i / BATCH_SIZE) + 1
1135
- }
1136
- });
1137
- });
1138
- }
1139
- }
1140
-
1141
- return results;`,
1142
- onError: 'continueRegularOutput',
1143
- retryOnFail: true,
1144
- maxTries: 2
1145
- },
1146
- userMustProvide: [
1147
- {
1148
- property: 'jsCode',
1149
- description: 'Update API_URL in the code',
1150
- example: 'https://your-api.com/batch'
1151
- }
1152
- ],
1153
- notes: [
1154
- 'Processes items in batches of 10',
1155
- 'Includes delay between batches',
1156
- 'Handles batch failures gracefully',
1157
- 'Update API_URL and adjust BATCH_SIZE as needed'
1158
- ]
1159
- },
1160
- 'error_safe_transform': {
1161
- task: 'error_safe_transform',
1162
- description: 'Transform data with comprehensive error handling',
1163
- nodeType: 'nodes-base.code',
1164
- configuration: {
1165
- language: 'javaScript',
1166
- jsCode: `// Safe data transformation with validation
1167
- const results = [];
1168
- const errors = [];
1169
-
1170
- for (const item of items) {
1171
- try {
1172
- // Validate required fields
1173
- const required = ['id', 'name']; // USER SHOULD UPDATE
1174
- const missing = required.filter(field => !item.json[field]);
1175
-
1176
- if (missing.length > 0) {
1177
- throw new Error(\`Missing required fields: \${missing.join(', ')}\`);
1178
- }
1179
-
1180
- // Transform data with type checking
1181
- const transformed = {
1182
- // Ensure ID is string
1183
- id: String(item.json.id),
1184
-
1185
- // Clean and validate name
1186
- name: String(item.json.name).trim(),
1187
-
1188
- // Parse numbers safely
1189
- amount: parseFloat(item.json.amount) || 0,
1190
-
1191
- // Parse dates safely
1192
- date: item.json.date
1193
- ? DateTime.fromISO(item.json.date).isValid
1194
- ? DateTime.fromISO(item.json.date).toISO()
1195
- : null
1196
- : null,
1197
-
1198
- // Boolean conversion
1199
- isActive: Boolean(item.json.active || item.json.isActive),
1200
-
1201
- // Array handling
1202
- tags: Array.isArray(item.json.tags)
1203
- ? item.json.tags.filter(tag => typeof tag === 'string')
1204
- : [],
1205
-
1206
- // Nested object handling
1207
- metadata: typeof item.json.metadata === 'object'
1208
- ? item.json.metadata
1209
- : {},
1210
-
1211
- // Add processing info
1212
- processedAt: DateTime.now().toISO(),
1213
- originalIndex: items.indexOf(item)
1214
- };
1215
-
1216
- results.push({
1217
- json: transformed
1218
- });
1219
-
1220
- } catch (error) {
1221
- errors.push({
1222
- json: {
1223
- error: error.message,
1224
- originalData: item.json,
1225
- index: items.indexOf(item),
1226
- status: 'failed'
1227
- }
1228
- });
1229
- }
1230
- }
1231
-
1232
- // Add summary at the end
1233
- results.push({
1234
- json: {
1235
- _summary: {
1236
- totalProcessed: results.length - errors.length,
1237
- totalErrors: errors.length,
1238
- successRate: ((results.length - errors.length) / items.length * 100).toFixed(2) + '%',
1239
- timestamp: DateTime.now().toISO()
1240
- }
1241
- }
1242
- });
1243
-
1244
- // Include errors at the end
1245
- return [...results, ...errors];`,
1246
- onError: 'continueRegularOutput'
1247
- },
1248
- userMustProvide: [
1249
- {
1250
- property: 'jsCode',
1251
- description: 'Update required fields array',
1252
- example: "const required = ['id', 'email', 'name'];"
1253
- }
1254
- ],
1255
- notes: [
1256
- 'Validates all data types',
1257
- 'Handles missing/invalid data gracefully',
1258
- 'Returns both successful and failed items',
1259
- 'Includes processing summary'
1260
- ]
1261
- },
1262
- 'async_data_processing': {
1263
- task: 'async_data_processing',
1264
- description: 'Process data with async operations and proper error handling',
1265
- nodeType: 'nodes-base.code',
1266
- configuration: {
1267
- language: 'javaScript',
1268
- jsCode: `// Async processing with concurrent limits
1269
- const CONCURRENT_LIMIT = 5;
1270
- const results = [];
1271
-
1272
- // Process items with concurrency control
1273
- async function processItem(item, index) {
1274
- try {
1275
- // Simulate async operation (replace with actual logic)
1276
- // Example: API call, database query, file operation
1277
- await new Promise(resolve => setTimeout(resolve, 100));
1278
-
1279
- // Actual processing logic here
1280
- const processed = {
1281
- ...item.json,
1282
- processed: true,
1283
- index: index,
1284
- timestamp: DateTime.now().toISO()
1285
- };
1286
-
1287
- // Example async operation - external API call
1288
- if (item.json.needsEnrichment) {
1289
- const enrichment = await $helpers.httpRequest({
1290
- method: 'GET',
1291
- url: \`https://api.example.com/enrich/\${item.json.id}\`
1292
- });
1293
- processed.enrichment = enrichment;
1294
- }
1295
-
1296
- return { json: processed };
1297
-
1298
- } catch (error) {
1299
- return {
1300
- json: {
1301
- ...item.json,
1302
- error: error.message,
1303
- status: 'failed',
1304
- index: index
1305
- }
1306
- };
1307
- }
1308
- }
1309
-
1310
- // Process in batches with concurrency limit
1311
- for (let i = 0; i < items.length; i += CONCURRENT_LIMIT) {
1312
- const batch = items.slice(i, i + CONCURRENT_LIMIT);
1313
- const batchPromises = batch.map((item, batchIndex) =>
1314
- processItem(item, i + batchIndex)
1315
- );
1316
-
1317
- const batchResults = await Promise.all(batchPromises);
1318
- results.push(...batchResults);
1319
- }
1320
-
1321
- return results;`,
1322
- onError: 'continueRegularOutput',
1323
- retryOnFail: true,
1324
- maxTries: 2
1325
- },
1326
- userMustProvide: [],
1327
- notes: [
1328
- 'Processes 5 items concurrently',
1329
- 'Prevents overwhelming external services',
1330
- 'Each item processed independently',
1331
- 'Errors don\'t affect other items'
1332
- ]
1333
- },
1334
- 'python_data_analysis': {
1335
- task: 'python_data_analysis',
1336
- description: 'Analyze data using Python with statistics',
1337
- nodeType: 'nodes-base.code',
1338
- configuration: {
1339
- language: 'pythonNative',
1340
- pythonCode: `# Native Python (pythonNative): _items is the list of input item dicts.
1341
- # Imports are blocked unless this instance allowlists the module, so the
1342
- # statistics below are computed with builtins only.
1343
- values = []
1344
- categories = {}
1345
- dates = []
1346
-
1347
- for item in _items:
1348
- data = item["json"]
1349
-
1350
- value = data.get("value", data.get("amount"))
1351
- if isinstance(value, (int, float)) and not isinstance(value, bool):
1352
- values.append(value)
1353
-
1354
- category = data.get("category", "uncategorized")
1355
- categories[category] = categories.get(category, 0) + 1
1356
-
1357
- if data.get("date"):
1358
- dates.append(data["date"])
1359
-
1360
- ordered = sorted(values)
1361
- count = len(ordered)
1362
- mean = sum(ordered) / count if count else 0
1363
- if count == 0:
1364
- median = 0
1365
- elif count % 2:
1366
- median = ordered[count // 2]
1367
- else:
1368
- median = (ordered[count // 2 - 1] + ordered[count // 2]) / 2
1369
-
1370
- # Sample standard deviation, the same value statistics.stdev returned
1371
- if count > 1:
1372
- stdev = (sum((x - mean) ** 2 for x in ordered) / (count - 1)) ** 0.5
1373
- else:
1374
- stdev = 0
1375
-
1376
- result = {
1377
- "itemCount": len(_items),
1378
- "values": {
1379
- "count": count,
1380
- "sum": sum(ordered),
1381
- "mean": mean,
1382
- "median": median,
1383
- "min": ordered[0] if ordered else 0,
1384
- "max": ordered[-1] if ordered else 0,
1385
- "stdev": stdev
1386
- },
1387
- "categories": categories,
1388
- "dateRange": {
1389
- "earliest": min(dates) if dates else None,
1390
- "latest": max(dates) if dates else None,
1391
- "count": len(dates)
1392
- },
1393
- "analysis": {
1394
- "hasNumericData": count > 0,
1395
- "hasCategoricalData": len(categories) > 0,
1396
- "hasTemporalData": len(dates) > 0,
1397
- "dataQuality": "good" if count > len(_items) * 0.8 else "partial"
1398
- }
1399
- }
1400
-
1401
- # Return a single summary item
1402
- return [{"json": result}]`,
1403
- onError: 'continueRegularOutput'
1404
- },
1405
- userMustProvide: [],
1406
- notes: [
1407
- 'Import-free: computes mean and median with builtins',
1408
- 'Analyzes numeric, categorical, and date data',
1409
- 'Returns comprehensive summary',
1410
- 'Handles missing data gracefully'
1411
- ]
1412
- }
1413
- };
1414
- //# sourceMappingURL=task-templates.js.map