@n8n/ai-workflow-builder 0.31.2 → 0.32.1

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 (68) hide show
  1. package/dist/ai-workflow-builder-agent.service.d.ts +6 -2
  2. package/dist/ai-workflow-builder-agent.service.js +45 -3
  3. package/dist/ai-workflow-builder-agent.service.js.map +1 -1
  4. package/dist/build.tsbuildinfo +1 -1
  5. package/dist/tools/best-practices/data-analysis.d.ts +7 -0
  6. package/dist/tools/best-practices/data-analysis.js +367 -0
  7. package/dist/tools/best-practices/data-analysis.js.map +1 -0
  8. package/dist/tools/best-practices/data-extraction.js +7 -0
  9. package/dist/tools/best-practices/data-extraction.js.map +1 -1
  10. package/dist/tools/best-practices/data-transformation.d.ts +7 -0
  11. package/dist/tools/best-practices/data-transformation.js +181 -0
  12. package/dist/tools/best-practices/data-transformation.js.map +1 -0
  13. package/dist/tools/best-practices/document-processing.d.ts +7 -0
  14. package/dist/tools/best-practices/document-processing.js +324 -0
  15. package/dist/tools/best-practices/document-processing.js.map +1 -0
  16. package/dist/tools/best-practices/enrichment.d.ts +7 -0
  17. package/dist/tools/best-practices/enrichment.js +271 -0
  18. package/dist/tools/best-practices/enrichment.js.map +1 -0
  19. package/dist/tools/best-practices/human-in-the-loop.d.ts +7 -0
  20. package/dist/tools/best-practices/human-in-the-loop.js +268 -0
  21. package/dist/tools/best-practices/human-in-the-loop.js.map +1 -0
  22. package/dist/tools/best-practices/index.js +7 -6
  23. package/dist/tools/best-practices/index.js.map +1 -1
  24. package/dist/tools/best-practices/knowledge-base.d.ts +7 -0
  25. package/dist/tools/best-practices/knowledge-base.js +268 -0
  26. package/dist/tools/best-practices/knowledge-base.js.map +1 -0
  27. package/dist/tools/best-practices/monitoring.d.ts +7 -0
  28. package/dist/tools/best-practices/monitoring.js +178 -0
  29. package/dist/tools/best-practices/monitoring.js.map +1 -0
  30. package/dist/tools/best-practices/notification.d.ts +7 -0
  31. package/dist/tools/best-practices/notification.js +229 -0
  32. package/dist/tools/best-practices/notification.js.map +1 -0
  33. package/dist/tools/best-practices/scheduling.d.ts +7 -0
  34. package/dist/tools/best-practices/scheduling.js +281 -0
  35. package/dist/tools/best-practices/scheduling.js.map +1 -0
  36. package/dist/tools/best-practices/triage.d.ts +7 -0
  37. package/dist/tools/best-practices/triage.js +211 -0
  38. package/dist/tools/best-practices/triage.js.map +1 -0
  39. package/dist/tools/categorize-prompt.tool.js +1 -0
  40. package/dist/tools/categorize-prompt.tool.js.map +1 -1
  41. package/dist/tools/helpers/response.js +2 -0
  42. package/dist/tools/helpers/response.js.map +1 -1
  43. package/dist/tools/prompts/main-agent.prompt.js +9 -1
  44. package/dist/tools/prompts/main-agent.prompt.js.map +1 -1
  45. package/dist/tools/validate-workflow.tool.js +12 -0
  46. package/dist/tools/validate-workflow.tool.js.map +1 -1
  47. package/dist/utils/tool-executor.js +19 -0
  48. package/dist/utils/tool-executor.js.map +1 -1
  49. package/dist/validation/checks/agent-prompt.js +2 -0
  50. package/dist/validation/checks/agent-prompt.js.map +1 -1
  51. package/dist/validation/checks/connections.js +8 -0
  52. package/dist/validation/checks/connections.js.map +1 -1
  53. package/dist/validation/checks/from-ai.js +1 -0
  54. package/dist/validation/checks/from-ai.js.map +1 -1
  55. package/dist/validation/checks/tools.js +2 -0
  56. package/dist/validation/checks/tools.js.map +1 -1
  57. package/dist/validation/checks/trigger.js +2 -0
  58. package/dist/validation/checks/trigger.js.map +1 -1
  59. package/dist/validation/types.d.ts +4 -0
  60. package/dist/validation/types.js +18 -0
  61. package/dist/validation/types.js.map +1 -1
  62. package/dist/workflow-builder-agent.d.ts +5 -2
  63. package/dist/workflow-builder-agent.js +4 -3
  64. package/dist/workflow-builder-agent.js.map +1 -1
  65. package/dist/workflow-state.d.ts +3 -1
  66. package/dist/workflow-state.js +8 -0
  67. package/dist/workflow-state.js.map +1 -1
  68. package/package.json +11 -7
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchedulingBestPractices = void 0;
4
+ const categorization_1 = require("../../types/categorization");
5
+ class SchedulingBestPractices {
6
+ technique = categorization_1.WorkflowTechnique.SCHEDULING;
7
+ version = '1.0.0';
8
+ documentation = `# Best Practices: Scheduling Workflows
9
+
10
+ ## Workflow Design
11
+
12
+ Structure scheduled workflows to perform focused, well-defined tasks. Use modular sub-workflows via Execute Workflow node for complex operations (database cleanup, report generation) to isolate failures and improve maintainability.
13
+
14
+ For recurring tasks, use Schedule Trigger node with clear naming (e.g., "Daily 08:00 Trigger", "Every 6h Cron"). Document schedule purpose in workflow description.
15
+
16
+ Prevent overlapping executions by ensuring worst-case execution time < schedule interval. For frequent schedules, implement mutex/lock mechanisms using external systems if needed.
17
+
18
+ CRITICAL: Always save and activate workflows with Schedule Trigger nodes - scheduled workflows only run in active mode. Manual execution works during development but activation is required for automatic runs.
19
+
20
+ ## Scheduling Patterns
21
+
22
+ ### Recurring Schedules
23
+
24
+ Use Schedule Trigger in two modes:
25
+ - **Interval Mode**: User-friendly dropdowns for common schedules (every X minutes, daily at 09:00, weekly on Mondays)
26
+ - **Cron Expression Mode**: Complex patterns using 5-field syntax (m h dom mon dow) with optional seconds field. Example: \`0 9 * * 1\` triggers every Monday at 09:00
27
+
28
+ Multiple schedules can be combined in single Schedule Trigger node using multiple Trigger Rules. Useful when same logic applies to different timings.
29
+
30
+ ### One-Time Events
31
+
32
+ For one-time future runs, use cron expression with exact date/time (e.g., \`0 12 22 10 *\` for Oct 22 at 12:00).
33
+ IMPORTANT: Deactivate workflow after execution to prevent yearly recurrence.
34
+
35
+ For event-relative scheduling, use Wait node to pause workflow until specified time/date. Workflow state persists across n8n restarts.
36
+
37
+ ### Conditional Scheduling
38
+
39
+ Use IF/Switch nodes after Schedule Trigger for runtime conditions:
40
+ - Check if today is last day of month before running monthly reports
41
+ - Skip execution on holidays or based on external data
42
+ - Route different tasks based on conditions
43
+
44
+ Better than complex cron expressions and provides flexibility for dynamic requirements.
45
+
46
+ ## Time Zone Configuration
47
+
48
+ CRITICAL: Explicitly set timezone to avoid scheduling confusion.
49
+
50
+ By default n8n will:
51
+ - Attempts to detect local timezone at signup, defaults to GMT if unsure
52
+ - Set instance timezone via Admin Panel
53
+ - Override per-workflow as needed
54
+
55
+ Schedule Trigger uses workflow timezone if set, otherwise instance timezone. Cron schedules automatically adjust for DST when using region timezones (Europe/London, America/New_York).
56
+
57
+ WARNING: Wait node uses server system time, ignoring workflow timezone settings. Account for this when using Wait with specific clock times.
58
+
59
+ ## Error Handling & Monitoring
60
+
61
+ Build robust error handling for unattended execution:
62
+ - Use Error Trigger for global error workflow
63
+ - Implement retry logic with Wait node for transient failures
64
+ - Add email/Slack notifications for failures
65
+ - Log timestamps with Console node to detect timing issues
66
+
67
+ Monitor Executions list regularly for:
68
+ - Expected trigger times
69
+ - Duplicates or gaps
70
+ - Failed executions
71
+ - Long-running workflows
72
+
73
+ ## Recommended Nodes
74
+
75
+ ### Schedule Trigger (n8n-nodes-base.scheduleTrigger)
76
+
77
+ Purpose: Primary node for running workflows on schedule
78
+
79
+ Modes:
80
+ - Interval: Simple recurring schedules via UI
81
+ - Cron: Complex patterns via expressions
82
+
83
+ Best Practices:
84
+ - Activate workflow for schedule to work
85
+ - Use descriptive names including schedule
86
+ - Test with manual execution during development
87
+ - Consider DST impacts for region timezones
88
+
89
+ ### Wait (n8n-nodes-base.wait)
90
+
91
+ Purpose: Pause workflow execution until specified time
92
+
93
+ Use Cases:
94
+ - Delay actions relative to events
95
+ - One-off timers per data item
96
+ - Follow-up actions after specific duration
97
+
98
+ Best Practices:
99
+ - Use external database (PostgreSQL) for long waits
100
+ - Avoid extremely long wait times
101
+ - Remember Wait uses server time, not workflow timezone
102
+ - State persists across n8n restarts
103
+
104
+ ### IF (n8n-nodes-base.if)
105
+
106
+ Purpose: Add conditional logic to scheduled workflows
107
+
108
+ Use Cases:
109
+ - Check date conditions (last day of month)
110
+ - Skip execution based on external data
111
+ - Route to different actions conditionally
112
+
113
+ Best Practices:
114
+ - Enable "Convert types where required" for comparisons
115
+ - Document condition logic clearly
116
+ - Prefer IF nodes over complex cron expressions
117
+
118
+ ### Switch (n8n-nodes-base.switch)
119
+
120
+ Purpose: Multiple conditional branches for complex routing
121
+
122
+ Use Cases:
123
+ - Different actions based on day of week
124
+ - Time-based routing within workflow
125
+ - Multi-path conditional execution
126
+
127
+ ### Error Trigger (n8n-nodes-base.errorTrigger)
128
+
129
+ Purpose: Global error handling for failed scheduled executions
130
+
131
+ Use Cases:
132
+ - Send notifications on workflow failure
133
+ - Log errors to external systems
134
+ - Implement global retry logic
135
+
136
+ Best Practices:
137
+ - Create dedicated error workflow
138
+ - Include workflow name and timestamp in notifications
139
+ - Consider severity levels for different failures
140
+
141
+ ### Execute Workflow (n8n-nodes-base.executeWorkflow)
142
+
143
+ Purpose: Call sub-workflows for modular scheduling
144
+
145
+ Use Cases:
146
+ - Break complex scheduled tasks into modules
147
+ - Reuse common scheduled operations
148
+ - Isolate failures to specific components
149
+
150
+ Best Practices:
151
+ - Pass parameters for configuration
152
+ - Handle sub-workflow errors appropriately
153
+ - Use for maintainable, focused workflows
154
+
155
+ ### Database Nodes
156
+
157
+ Purpose: Check pending tasks or store execution history
158
+
159
+ - MySQL (n8n-nodes-base.mySql)
160
+ - Postgres (n8n-nodes-base.postgres)
161
+ - MongoDB (n8n-nodes-base.mongoDb)
162
+
163
+ Use Cases:
164
+ - Store list of pending one-time tasks
165
+ - Log execution history
166
+ - Implement custom scheduling queue
167
+
168
+ Best Practices:
169
+ - Query efficiently with proper indexes
170
+ - Clean up old execution logs periodically
171
+ - Use for dynamic scheduling requirements
172
+
173
+ ### HTTP Request (n8n-nodes-base.httpRequest)
174
+
175
+ Purpose: Call external APIs or monitoring services
176
+
177
+ Use Cases:
178
+ - Send heartbeat to monitoring service
179
+ - Check external conditions before execution
180
+ - Trigger external scheduled jobs
181
+
182
+ ### Email/Slack
183
+
184
+ - Email (n8n-nodes-base.emailSend)
185
+ - Slack (n8n-nodes-base.slack)
186
+
187
+ Purpose: Send notifications for scheduled workflow events
188
+
189
+ Use Cases:
190
+ - Daily report delivery
191
+ - Failure notifications
192
+ - Completion confirmations
193
+
194
+ ## Common Pitfalls to Avoid
195
+
196
+ ### Time Zone Mismatch
197
+
198
+ **Problem**: Workflows run at wrong time due to incorrect timezone configuration. Schedule set for 08:00 runs at 07:00 or 09:00.
199
+
200
+ **Solution**:
201
+ - Explicitly set workflow or instance timezone
202
+ - Verify timezone after DST changes
203
+ - Use UTC for consistency if timezone complexity is problematic
204
+ - Remember self-hosted defaults to America/New_York
205
+
206
+ ### Daylight Saving Time Issues
207
+
208
+ **Problem**: Missed or duplicate executions during DST transitions. Jobs may not run or run twice when clocks change.
209
+
210
+ **Solution**:
211
+ - Use region timezones for automatic DST handling
212
+ - Test critical schedules around DST dates
213
+ - Consider fixed-offset timezone for year-round consistency
214
+ - Update n8n version for latest timezone database
215
+
216
+ ### Duplicate Trigger Executions
217
+
218
+ **Problem**: Workflows triggering multiple times at scheduled time, especially in multi-instance setups.
219
+
220
+ **Solution**:
221
+ - Upgrade to n8n ≥1.107.0 (fixes duplicate cron registrations)
222
+ - Configure N8N_MULTI_MAIN_PROCESS=true for multi-instance setups
223
+ - Disable and re-enable workflow if duplicates persist
224
+ - Restart n8n process if issues occur after editing
225
+
226
+ ### Missed Schedules During Downtime
227
+
228
+ **Problem**: Scheduled runs missed when n8n instance is down. No automatic catch-up for missed triggers.
229
+
230
+ **Solution**:
231
+ - Ensure high availability for critical schedules
232
+ - Design idempotent workflows that check for missed work
233
+ - Use daily check pattern instead of exact timing when possible
234
+ - Implement external monitoring for uptime
235
+
236
+ ### Overlapping Executions
237
+
238
+ **Problem**: Next scheduled run starts before previous completes, causing race conditions or resource conflicts.
239
+
240
+ **Solution**:
241
+ - Increase interval to exceed worst-case execution time
242
+ - Implement mutex/lock using database or external system
243
+ - Add execution check at workflow start
244
+ - Configure single worker for workflow in queue mode
245
+
246
+ ### Wait Node Timezone Confusion
247
+
248
+ **Problem**: Wait node uses server system time, ignoring workflow timezone setting. Wait until "10:00" may not match expected timezone.
249
+
250
+ **Solution**:
251
+ - Account for server timezone when setting Wait times
252
+ - Use UTC timestamps for clarity
253
+ - Run server in target timezone if possible
254
+ - Prefer Schedule Trigger for timezone-aware scheduling
255
+
256
+ ### First Execution Timing
257
+
258
+ **Problem**: First execution after activation doesn't match expected schedule. Activation time affects next run calculation.
259
+
260
+ **Solution**:
261
+ - Plan activation timing carefully
262
+ - Use manual execution for immediate first run
263
+ - Understand that schedule recalculates from activation moment
264
+ - Document expected first run time
265
+
266
+ ### Cron Syntax Errors
267
+
268
+ **Problem**: Invalid cron expression prevents trigger activation. Missing fields or incorrect format causes silent failures.
269
+
270
+ **Solution**:
271
+ - Use crontab.guru to validate expressions
272
+ - Remember n8n supports 5 or 6 field syntax
273
+ - n8n supports both 5-field and 6-field (with seconds) cron syntax; use 6 fields if you want to specify seconds (e.g., prefix with 0 for seconds: \`0 0 * * * *\`)
274
+ - Use interval mode for simple schedules
275
+ `;
276
+ getDocumentation() {
277
+ return this.documentation;
278
+ }
279
+ }
280
+ exports.SchedulingBestPractices = SchedulingBestPractices;
281
+ //# sourceMappingURL=scheduling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduling.js","sourceRoot":"","sources":["../../../src/tools/best-practices/scheduling.ts"],"names":[],"mappings":";;;AACA,2DAA2D;AAE3D,MAAa,uBAAuB;IAC1B,SAAS,GAAG,kCAAiB,CAAC,UAAU,CAAC;IACzC,OAAO,GAAG,OAAO,CAAC;IAEV,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2QjC,CAAC;IAED,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AApRD,0DAoRC"}
@@ -0,0 +1,7 @@
1
+ import type { BestPracticesDocument } from '../../types/best-practices';
2
+ export declare class TriageBestPractices implements BestPracticesDocument {
3
+ readonly technique: "triage";
4
+ readonly version = "1.0.0";
5
+ private readonly documentation;
6
+ getDocumentation(): string;
7
+ }
@@ -0,0 +1,211 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TriageBestPractices = void 0;
4
+ const categorization_1 = require("../../types/categorization");
5
+ class TriageBestPractices {
6
+ technique = categorization_1.WorkflowTechnique.TRIAGE;
7
+ version = '1.0.0';
8
+ documentation = `# Best Practices: Triage Workflows
9
+
10
+ ## Workflow Design
11
+
12
+ Triage workflows automatically classify incoming data and route it based on priority or category. Common use cases include sorting support tickets by urgency, categorizing emails for follow-up, or scoring leads for sales routing.
13
+
14
+ Define clear categories and outcomes before building. Design in logical stages:
15
+
16
+ 1. **Trigger & Input**: Capture incoming items (webhook, email trigger, form submission, schedule)
17
+ 2. **Preprocessing**: Fetch additional data if needed (CRM lookup, field normalization)
18
+ 3. **Classification**: Assign categories via rules or AI
19
+ 4. **Routing**: Direct items to appropriate branches using Switch node
20
+ 5. **Actions**: Execute category-specific tasks (create tasks, send alerts, update records)
21
+ 6. **Logging**: Track outcomes for monitoring and analysis
22
+
23
+ CRITICAL: Always include a default/fallback path to catch unclassified items. Never allow data to drop silently.
24
+
25
+ ## Classification Strategies
26
+
27
+ ### Rule-Based Classification
28
+ Use IF/Switch nodes for keyword detection, sender addresses, or numeric thresholds. Chain multiple conditions or use Switch for multi-way branching.
29
+
30
+ Example: IF email contains "urgent" → High Priority branch
31
+
32
+ ### AI-Powered Classification
33
+ For unstructured text or nuanced decisions, use AI nodes with clear prompts and defined output labels.
34
+
35
+ Example prompt: "Classify this email as INTERESTED, NOT_INTERESTED, or QUESTION"
36
+
37
+ Best practices:
38
+ - Use structured output format (JSON with specific fields)
39
+ - Set low temperature (0-0.2) for consistency
40
+ - Include few-shot examples for accuracy
41
+ - Implement error handling for unexpected outputs
42
+
43
+ ## Routing & Branching
44
+
45
+ Use Switch node as primary traffic controller:
46
+ - Configure cases for each classification value
47
+ - Always define Default case for unexpected values
48
+ - Each item follows exactly one branch
49
+ - Keep branches modular using Execute Workflow node for complex logic
50
+
51
+ Avoid parallel IF nodes that could match multiple conditions - use Switch or chain IF nodes with Execute Once setting.
52
+
53
+ ## Recommended Nodes
54
+
55
+ ### Trigger Nodes
56
+
57
+ **Webhook** (n8n-nodes-base.webhook):
58
+ - Purpose: Capture incoming items for triage via HTTP requests
59
+ - Best for: Form submissions, webhook integrations
60
+
61
+ **Gmail Trigger** (n8n-nodes-base.gmailTrigger):
62
+ - Purpose: Automatically process new emails
63
+ - Best for: Email-based triage workflows
64
+
65
+ **Schedule Trigger** (n8n-nodes-base.scheduleTrigger):
66
+ - Purpose: Periodic batch processing of items
67
+ - Best for: Regular review of database records or API data
68
+
69
+ ### Classification Nodes
70
+
71
+ **IF** (n8n-nodes-base.if):
72
+ - Purpose: Simple binary decisions
73
+ - Use when: Two-way branching based on conditions
74
+ - Example: Check if priority field equals "high"
75
+
76
+ **Switch** (n8n-nodes-base.switch):
77
+ - Purpose: Multi-way branching based on field values
78
+ - Use when: Multiple categories (3+ outcomes)
79
+ - CRITICAL: Always configure Default output for unmatched items
80
+
81
+ **OpenAI** (@n8n/n8n-nodes-langchain.openAi):
82
+ - Purpose: AI-powered text classification
83
+ - Best practices:
84
+ - Use structured output format
85
+ - Set low temperature (0-0.2) for consistency
86
+ - Include few-shot examples
87
+
88
+ **AI Agent** (@n8n/n8n-nodes-langchain.agent):
89
+ - Purpose: Complex classification requiring multiple steps or tool use
90
+ - Use when: Classification needs context lookup or multi-step reasoning
91
+
92
+ ### Data Processing
93
+
94
+ **Set** (n8n-nodes-base.set):
95
+ - Purpose: Normalize fields, add metadata, store classification results
96
+ - Use early: Standardize incoming data structure
97
+
98
+ **Function** (n8n-nodes-base.function):
99
+ - Purpose: Custom classification logic using JavaScript
100
+ - Use when: Complex rules that can't be expressed in IF/Switch
101
+
102
+ **HTTP Request** (n8n-nodes-base.httpRequest):
103
+ - Purpose: Fetch additional context (CRM data, user history)
104
+ - Use before: Classification to enrich decision context
105
+
106
+ ### Integration & Action Nodes
107
+
108
+ **Slack** (n8n-nodes-base.slack):
109
+ - Purpose: Send notifications, create channels by category
110
+ - Example: Alert #urgent-tickets channel for high-priority items
111
+
112
+ **HubSpot** (n8n-nodes-base.hubspot):
113
+ - Purpose: Update contact records, create tasks, set lead scores
114
+ - Example: Tag contacts based on classification
115
+
116
+ **JIRA** (n8n-nodes-base.jira):
117
+ - Purpose: Create issues with appropriate priority/assignee
118
+ - Example: Auto-assign bugs to engineering team
119
+
120
+ **Database Nodes**:
121
+ - Postgres (n8n-nodes-base.postgres)
122
+ - MySQL (n8n-nodes-base.mySql)
123
+ - MongoDB (n8n-nodes-base.mongoDb)
124
+
125
+ Purpose: Log triage outcomes, track metrics, store classification history
126
+
127
+ **Google Sheets** (n8n-nodes-base.googleSheets):
128
+ - Purpose: Simple logging and reporting
129
+ - Example: Track daily triage volumes by category
130
+
131
+ ### Workflow Control
132
+
133
+ **Execute Workflow** (n8n-nodes-base.executeWorkflow):
134
+ - Purpose: Modular branch logic
135
+ - Use when: Category-specific actions are complex
136
+ - Pattern: Switch → Execute Workflow (per category)
137
+
138
+ **Error Trigger** (n8n-nodes-base.errorTrigger):
139
+ - Purpose: Catch and handle classification failures
140
+ - CRITICAL: Always implement for production triage workflows
141
+
142
+ **Merge** (n8n-nodes-base.merge):
143
+ - Purpose: Consolidate branches for unified logging
144
+ - Use after: Category-specific actions before final logging step
145
+
146
+ ## Common Pitfalls to Avoid
147
+
148
+ ### No Default Path
149
+ **Problem**: Every Switch must have a Default output. Unmatched items should go to manual review or logging, never drop silently.
150
+
151
+ **Solution**: Always configure Default case to route unclassified items to a fallback action (e.g., manual review queue, admin notification)
152
+
153
+ ### Overlapping Conditions
154
+ **Problem**: Categories must be mutually exclusive. Items matching multiple conditions cause unpredictable routing.
155
+
156
+ **Solution**:
157
+ - Order checks from most specific to general
158
+ - Use Switch with distinct values instead of multiple IF nodes
159
+ - Test edge cases thoroughly
160
+
161
+ ### Costly API Overuse
162
+ **Problem**: Calling AI APIs multiple times for same item wastes resources.
163
+
164
+ **Solution**:
165
+ - Use pin data feature during development
166
+ - Classify each item only once, store result in variable for reuse
167
+ - Enable caching where available
168
+ - Batch similar items when possible
169
+
170
+ ### Missing Error Handling
171
+ **Problem**: AI calls can fail or return unexpected formats, breaking the workflow.
172
+
173
+ **Solution**:
174
+ - Implement Error Trigger workflow to catch failures
175
+ - Add validation after AI classification
176
+ - Handle unexpected outputs gracefully with default categorization
177
+ - Log all errors for review
178
+
179
+ ### Poor Documentation
180
+ **Problem**: Generic node names make workflows hard to maintain.
181
+
182
+ **Solution**:
183
+ - Name nodes clearly (e.g., "Classify with OpenAI", "Route by Priority")
184
+ - Use Sticky Notes for complex sections
185
+ - Store constants in Set nodes or environment variables
186
+ - Document classification criteria
187
+
188
+ ### Relying 100% on AI
189
+ **Problem**: AI can misclassify critical items, leading to wrong actions.
190
+
191
+ **Solution**:
192
+ - For critical decisions, combine AI with rule validation
193
+ - Monitor accuracy metrics
194
+ - Implement human verification for high-risk categories
195
+ - Use confidence thresholds to route uncertain items to manual review
196
+
197
+ ### No Monitoring
198
+ **Problem**: Can't track accuracy, volume trends, or system health.
199
+
200
+ **Solution**:
201
+ - Log all triage outcomes to database/sheets
202
+ - Track metrics: category volumes, error rates, processing times
203
+ - Set up alerts for anomalies (e.g., sudden spike in unclassified items)
204
+ - Review misclassifications regularly to improve rules/prompts
205
+ `;
206
+ getDocumentation() {
207
+ return this.documentation;
208
+ }
209
+ }
210
+ exports.TriageBestPractices = TriageBestPractices;
211
+ //# sourceMappingURL=triage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triage.js","sourceRoot":"","sources":["../../../src/tools/best-practices/triage.ts"],"names":[],"mappings":";;;AACA,2DAA2D;AAE3D,MAAa,mBAAmB;IACtB,SAAS,GAAG,kCAAiB,CAAC,MAAM,CAAC;IACrC,OAAO,GAAG,OAAO,CAAC;IAEV,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqMjC,CAAC;IAED,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AA9MD,kDA8MC"}
@@ -46,6 +46,7 @@ function createCategorizePromptTool(llm, logger) {
46
46
  reporter.complete(output);
47
47
  return (0, response_1.createSuccessResponse)(config, buildCategorizationMessage(categorization), {
48
48
  categorization,
49
+ techniqueCategories: categorization.techniques,
49
50
  });
50
51
  }
51
52
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"categorize-prompt.tool.js","sourceRoot":"","sources":["../../src/tools/categorize-prompt.tool.ts"],"names":[],"mappings":";;;AAsCA,gEAwEC;AA7GD,iDAA6C;AAE7C,6BAAwB;AAExB,0EAA2E;AAC3E,qCAA+D;AAC/D,uDAAkE;AAClE,uDAAsF;AAKtF,MAAM,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC;CACnE,CAAC,CAAC;AAEH,SAAS,0BAA0B,CAAC,cAAoC;IACvE,MAAM,KAAK,GAAa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eAAe,CAAC,CAAC;YACrD,CAAC;YAED,MAAM,SAAS,GAAG,IAAI,2BAAkB,CACvC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,EACjE;gBACC,QAAQ,EAAE,8BAAsB,CAAC,QAAQ;gBACzC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;aACjD,CACD,CAAC;YACF,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC1B,OAAO,IAAA,8BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC,EACD;QACC,IAAI,EAAE,8BAAsB,CAAC,QAAQ;QACrC,WAAW,EAAE;;;;;;;;4HAQ4G;QACzH,MAAM,EAAE,sBAAsB;KAC9B,CACD,CAAC;IAEF,OAAO;QACN,IAAI,EAAE,WAAW;QACjB,GAAG,8BAAsB;KACzB,CAAC;AACH,CAAC"}
@@ -10,6 +10,7 @@ function createSuccessResponse(config, message, stateUpdates) {
10
10
  new messages_1.ToolMessage({
11
11
  content: message,
12
12
  tool_call_id: toolCallId,
13
+ name: config.toolCall?.name,
13
14
  }),
14
15
  ];
15
16
  const update = { messages };
@@ -24,6 +25,7 @@ function createErrorResponse(config, error) {
24
25
  new messages_1.ToolMessage({
25
26
  content: `Error: ${error.message}`,
26
27
  tool_call_id: toolCallId,
28
+ name: config.toolCall?.name,
27
29
  }),
28
30
  ];
29
31
  return new langgraph_1.Command({ update: { messages } });
@@ -1 +1 @@
1
- {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/tools/helpers/response.ts"],"names":[],"mappings":";;AAWA,sDAqBC;AAKD,kDAWC;AAhDD,uDAAuD;AAEvD,oDAA+C;AAS/C,SAAgB,qBAAqB,CACpC,MAA0B,EAC1B,OAAe,EACf,YAAmC;IAEnC,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ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;QAClB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,IAAI,mBAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAChC,CAAC;AAKD,SAAgB,mBAAmB,CAAC,MAA0B,EAAE,KAAgB;IAC/E,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,EAAY,CAAC;IAEjD,MAAM,QAAQ,GAAG;QAChB,IAAI,sBAAW,CAAC;YACf,OAAO,EAAE,UAAU,KAAK,CAAC,OAAO,EAAE;YAClC,YAAY,EAAE,UAAU;YACxB,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI;SAC3B,CAAC;KACF,CAAC;IAEF,OAAO,IAAI,mBAAO,CAAC,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC"}
@@ -38,7 +38,7 @@ Follow this proven sequence for creating robust workflows:
38
38
  - Why: Best practices help to inform which nodes to search for and use to build the workflow plus mistakes to avoid
39
39
 
40
40
  2. **Discovery Phase** (parallel execution)
41
- - Search for all required node types simultaneously
41
+ - Search for all required node types simultaneously, review the <node_selection> section for tips and best practices
42
42
  - Why: Ensures you work with actual available nodes, not assumptions
43
43
 
44
44
  3. **Analysis Phase** (parallel execution)
@@ -67,6 +67,14 @@ Follow this proven sequence for creating robust workflows:
67
67
  - Review <workflow_validation_report> and resolve any violations before finalizing
68
68
  - Why: Ensures structural issues are surfaced early; rerun validation after major updates
69
69
 
70
+ <node_selection>
71
+ When building AI workflows prefer the AI agent node to other text LLM nodes, unless the user specifies them by name. Summarization, analysis, information
72
+ extraction and classification can all be carried out by an AI agent node, correct system prompt, and structured output parser.
73
+ For the purposes of this section provider specific nodes can be described as nodes like @n8n/n8n-nodes-langchain.openAi.
74
+ Do not use provider specific nodes for text operations - instead use an AI agent node.
75
+ For generation/analysis of content other than text (images, video, audio) provider specific nodes should be used.
76
+ </node_selection>
77
+
70
78
  <best_practices_compliance>
71
79
  Enforcing best practice compliance is MANDATORY
72
80
 
@@ -1 +1 @@
1
- {"version":3,"file":"main-agent.prompt.js","sourceRoot":"","sources":["../../../src/tools/prompts/main-agent.prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA6D;AAE7D,oEAAsE;AAEtE,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAudpB,CAAC;AAEF,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCxB,CAAC;AAEF,MAAM,2BAA2B,GAAG;;;oBAGhB,CAAC;AAER,QAAA,eAAe,GAAG,4BAAkB,CAAC,YAAY,CAAC;IAC9D;QACC,QAAQ;QACR;YACC;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,YAAY;aAClB;YACD;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,gCAAiB;aACvB;YACD;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,gBAAgB;aACtB;YACD;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,2BAA2B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,gBAAgB;aACtB;YACD;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,2BAA2B;gBACjC,aAAa,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;aACpC;SACD;KACD;IACD,CAAC,aAAa,EAAE,YAAY,CAAC;CAC7B,CAAC,CAAC"}
@@ -5,6 +5,7 @@ exports.createValidateWorkflowTool = createValidateWorkflowTool;
5
5
  const tools_1 = require("@langchain/core/tools");
6
6
  const zod_1 = require("zod");
7
7
  const programmatic_1 = require("../validation/programmatic");
8
+ const types_1 = require("../validation/types");
8
9
  const errors_1 = require("../errors");
9
10
  const workflow_validation_1 = require("../utils/workflow-validation");
10
11
  const progress_1 = require("./helpers/progress");
@@ -15,6 +16,15 @@ exports.VALIDATE_WORKFLOW_TOOL = {
15
16
  toolName: 'validate_workflow',
16
17
  displayTitle: 'Validating workflow',
17
18
  };
19
+ function collectValidationResultForTelemetry(results) {
20
+ const status = Object.fromEntries(types_1.PROGRAMMATIC_VIOLATION_NAMES.map((name) => [name, 'pass']));
21
+ Object.values(results).forEach((violations) => {
22
+ violations?.forEach((violation) => {
23
+ status[violation.name] = 'fail';
24
+ });
25
+ });
26
+ return status;
27
+ }
18
28
  function createValidateWorkflowTool(parsedNodeTypes, logger) {
19
29
  const dynamicTool = (0, tools_1.tool)(async (input, config) => {
20
30
  const reporter = (0, progress_1.createProgressReporter)(config, exports.VALIDATE_WORKFLOW_TOOL.toolName, exports.VALIDATE_WORKFLOW_TOOL.displayTitle);
@@ -26,10 +36,12 @@ function createValidateWorkflowTool(parsedNodeTypes, logger) {
26
36
  const violations = (0, programmatic_1.programmaticValidation)({
27
37
  generatedWorkflow: state.workflowJSON,
28
38
  }, parsedNodeTypes);
39
+ const validationResultForTelemetry = collectValidationResultForTelemetry(violations);
29
40
  const message = (0, workflow_validation_1.formatWorkflowValidation)(violations);
30
41
  reporter.complete({ message });
31
42
  return (0, response_1.createSuccessResponse)(config, message, {
32
43
  workflowValidation: violations,
44
+ validationHistory: [validationResultForTelemetry],
33
45
  });
34
46
  }
35
47
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"validate-workflow.tool.js","sourceRoot":"","sources":["../../src/tools/validate-workflow.tool.ts"],"names":[],"mappings":";;;AAqBA,gEAoEC;AAzFD,iDAA6C;AAG7C,6BAAwB;AAGxB,4DAAmE;AAEnE,sCAAgE;AAChE,sEAAwE;AACxE,iDAA4E;AAC5E,iDAAgF;AAChF,2CAAmD;AAEnD,MAAM,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAEpD,QAAA,sBAAsB,GAAoB;IACtD,QAAQ,EAAE,mBAAmB;IAC7B,YAAY,EAAE,qBAAqB;CACnC,CAAC;AAEF,SAAgB,0BAA0B,CACzC,eAAuC,EACvC,MAAe;IAEf,MAAM,WAAW,GAAG,IAAA,YAAI,EACvB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,IAAA,iCAAsB,EACtC,MAAM,EACN,8BAAsB,CAAC,QAAQ,EAC/B,8BAAsB,CAAC,YAAY,CACnC,CAAC;QAEF,IAAI,CAAC;YACJ,MAAM,cAAc,GAAG,sBAAsB,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YACjE,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;YAE/B,MAAM,KAAK,GAAG,IAAA,wBAAgB,GAAE,CAAC;YACjC,IAAA,yBAAc,EAAC,QAAQ,EAAE,6BAA6B,CAAC,CAAC;YAExD,MAAM,UAAU,GAAG,IAAA,qCAAsB,EACxC;gBACC,iBAAiB,EAAE,KAAK,CAAC,YAAY;aACrC,EACD,eAAe,CACf,CAAC;YAEF,MAAM,OAAO,GAAG,IAAA,8CAAwB,EAAC,UAAU,CAAC,CAAC;YAErD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE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