@n8n/ai-workflow-builder 0.31.2 → 0.32.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.
- package/dist/ai-workflow-builder-agent.service.d.ts +6 -2
- package/dist/ai-workflow-builder-agent.service.js +45 -3
- package/dist/ai-workflow-builder-agent.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/tools/best-practices/data-analysis.d.ts +7 -0
- package/dist/tools/best-practices/data-analysis.js +367 -0
- package/dist/tools/best-practices/data-analysis.js.map +1 -0
- package/dist/tools/best-practices/data-extraction.js +7 -0
- package/dist/tools/best-practices/data-extraction.js.map +1 -1
- package/dist/tools/best-practices/data-transformation.d.ts +7 -0
- package/dist/tools/best-practices/data-transformation.js +181 -0
- package/dist/tools/best-practices/data-transformation.js.map +1 -0
- package/dist/tools/best-practices/document-processing.d.ts +7 -0
- package/dist/tools/best-practices/document-processing.js +324 -0
- package/dist/tools/best-practices/document-processing.js.map +1 -0
- package/dist/tools/best-practices/enrichment.d.ts +7 -0
- package/dist/tools/best-practices/enrichment.js +271 -0
- package/dist/tools/best-practices/enrichment.js.map +1 -0
- package/dist/tools/best-practices/human-in-the-loop.d.ts +7 -0
- package/dist/tools/best-practices/human-in-the-loop.js +268 -0
- package/dist/tools/best-practices/human-in-the-loop.js.map +1 -0
- package/dist/tools/best-practices/index.js +7 -6
- package/dist/tools/best-practices/index.js.map +1 -1
- package/dist/tools/best-practices/knowledge-base.d.ts +7 -0
- package/dist/tools/best-practices/knowledge-base.js +268 -0
- package/dist/tools/best-practices/knowledge-base.js.map +1 -0
- package/dist/tools/best-practices/monitoring.d.ts +7 -0
- package/dist/tools/best-practices/monitoring.js +178 -0
- package/dist/tools/best-practices/monitoring.js.map +1 -0
- package/dist/tools/best-practices/notification.d.ts +7 -0
- package/dist/tools/best-practices/notification.js +229 -0
- package/dist/tools/best-practices/notification.js.map +1 -0
- package/dist/tools/best-practices/scheduling.d.ts +7 -0
- package/dist/tools/best-practices/scheduling.js +281 -0
- package/dist/tools/best-practices/scheduling.js.map +1 -0
- package/dist/tools/best-practices/triage.d.ts +7 -0
- package/dist/tools/best-practices/triage.js +211 -0
- package/dist/tools/best-practices/triage.js.map +1 -0
- package/dist/tools/categorize-prompt.tool.js +1 -0
- package/dist/tools/categorize-prompt.tool.js.map +1 -1
- package/dist/tools/helpers/response.js +2 -0
- package/dist/tools/helpers/response.js.map +1 -1
- package/dist/tools/prompts/main-agent.prompt.js +9 -1
- package/dist/tools/prompts/main-agent.prompt.js.map +1 -1
- package/dist/tools/validate-workflow.tool.js +12 -0
- package/dist/tools/validate-workflow.tool.js.map +1 -1
- package/dist/utils/tool-executor.js +19 -0
- package/dist/utils/tool-executor.js.map +1 -1
- package/dist/validation/checks/agent-prompt.js +2 -0
- package/dist/validation/checks/agent-prompt.js.map +1 -1
- package/dist/validation/checks/connections.js +8 -0
- package/dist/validation/checks/connections.js.map +1 -1
- package/dist/validation/checks/from-ai.js +1 -0
- package/dist/validation/checks/from-ai.js.map +1 -1
- package/dist/validation/checks/tools.js +2 -0
- package/dist/validation/checks/tools.js.map +1 -1
- package/dist/validation/checks/trigger.js +2 -0
- package/dist/validation/checks/trigger.js.map +1 -1
- package/dist/validation/types.d.ts +4 -0
- package/dist/validation/types.js +18 -0
- package/dist/validation/types.js.map +1 -1
- package/dist/workflow-builder-agent.d.ts +5 -2
- package/dist/workflow-builder-agent.js +4 -3
- package/dist/workflow-builder-agent.js.map +1 -1
- package/dist/workflow-state.d.ts +3 -1
- package/dist/workflow-state.js +8 -0
- package/dist/workflow-state.js.map +1 -1
- package/package.json +11 -7
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MonitoringBestPractices = void 0;
|
|
4
|
+
const categorization_1 = require("../../types/categorization");
|
|
5
|
+
class MonitoringBestPractices {
|
|
6
|
+
technique = categorization_1.WorkflowTechnique.MONITORING;
|
|
7
|
+
version = '1.0.0';
|
|
8
|
+
documentation = `# Best Practices: Monitoring Workflows
|
|
9
|
+
|
|
10
|
+
## Workflow Design
|
|
11
|
+
|
|
12
|
+
Structure monitoring workflows with a Schedule Trigger for periodic checks, HTTP Request or appropriate check nodes for service status, and IF/Switch nodes for conditional alerting. Always enable error handling to prevent workflow crashes when services are down.
|
|
13
|
+
|
|
14
|
+
CRITICAL: Enable "Continue On Fail" or "Never Error" mode on check nodes - otherwise the workflow stops exactly when you need alerts. This is the most common monitoring mistake.
|
|
15
|
+
|
|
16
|
+
Example pattern for website monitoring:
|
|
17
|
+
- Schedule Trigger (every 5 minutes) → HTTP Request (check status) → IF (status != 200?) → Send alert
|
|
18
|
+
- Always test both success and failure paths during development
|
|
19
|
+
|
|
20
|
+
For monitoring multiple services, store URLs/endpoints in Google Sheets or databases and loop through them rather than duplicating workflows.
|
|
21
|
+
|
|
22
|
+
## Scheduling & Activation
|
|
23
|
+
|
|
24
|
+
Always activate the workflow after configuration - forgetting this means no monitoring occurs. Test schedules with manual execution before relying on them in production.
|
|
25
|
+
|
|
26
|
+
Configure appropriate check intervals based on criticality:
|
|
27
|
+
- Critical services: 1-5 minutes
|
|
28
|
+
- Important services: 10-15 minutes
|
|
29
|
+
- Non-critical: 30-60 minutes
|
|
30
|
+
|
|
31
|
+
Set correct time zones in Workflow Settings for daily/weekly schedules. Use crontab.guru to verify complex Cron expressions.
|
|
32
|
+
|
|
33
|
+
## Service Status Checking
|
|
34
|
+
|
|
35
|
+
Configure HTTP Request nodes with:
|
|
36
|
+
- Timeout: Set to a few seconds to prevent hanging
|
|
37
|
+
- Include Headers & Status: Access response codes for condition evaluation
|
|
38
|
+
- Retry on Fail: 2-3 retries with 1s delay to filter transient failures
|
|
39
|
+
- Authentication: Use credential system, never hardcode secrets
|
|
40
|
+
|
|
41
|
+
For non-HTTP monitoring:
|
|
42
|
+
- Databases: Use Query nodes (MySQL, Postgres) for health checks
|
|
43
|
+
- Systems: Execute Command node for ping or custom scripts
|
|
44
|
+
- APIs: Check specific endpoints, not just base URLs
|
|
45
|
+
|
|
46
|
+
## Alert Configuration
|
|
47
|
+
|
|
48
|
+
Implement multi-channel alerting for critical services to ensure visibility. Configure notifications with useful context.
|
|
49
|
+
|
|
50
|
+
Message content should include:
|
|
51
|
+
- Service name/URL
|
|
52
|
+
- Failure time: {{$now}}
|
|
53
|
+
- Error details: {{$json["statusCode"]}}
|
|
54
|
+
- Example: "⚠️ Website XYZ DOWN (status 500) at {{new Date().toISOString()}}"
|
|
55
|
+
|
|
56
|
+
Avoid alert storms by:
|
|
57
|
+
- Tracking state changes (only alert when status changes)
|
|
58
|
+
- Throttling repeated alerts (e.g., re-alert after 30 minutes)
|
|
59
|
+
- Storing last known status in Google Sheets or database
|
|
60
|
+
|
|
61
|
+
## Error Handling & Failsafes
|
|
62
|
+
|
|
63
|
+
Implement multiple layers of error handling:
|
|
64
|
+
|
|
65
|
+
1. Node-level: Enable "Continue On Fail" on check nodes
|
|
66
|
+
2. Workflow-level: Create Error Trigger workflow to catch monitoring failures
|
|
67
|
+
3. Heartbeat: Ping external service (healthchecks.io) to verify monitoring is running
|
|
68
|
+
|
|
69
|
+
Configure Error Workflow in settings to alert when monitoring itself fails - otherwise you have blind spots.
|
|
70
|
+
|
|
71
|
+
## Logging & State Management
|
|
72
|
+
|
|
73
|
+
Log check results for trend analysis and uptime calculation. Store in Google Sheets (append row) or database with:
|
|
74
|
+
- Timestamp
|
|
75
|
+
- Service identifier
|
|
76
|
+
- Status (up/down)
|
|
77
|
+
- Response time
|
|
78
|
+
- Error details if applicable
|
|
79
|
+
|
|
80
|
+
Maintain current status dashboard by updating a status table/sheet that shows at-a-glance health of all monitored services.
|
|
81
|
+
|
|
82
|
+
## Recommended Nodes
|
|
83
|
+
|
|
84
|
+
### Schedule Trigger (n8n-nodes-base.scheduleTrigger)
|
|
85
|
+
|
|
86
|
+
Purpose: Periodic workflow execution at fixed intervals or Cron schedules
|
|
87
|
+
|
|
88
|
+
Configuration:
|
|
89
|
+
- Set appropriate intervals based on service criticality
|
|
90
|
+
- Always activate the workflow after configuration
|
|
91
|
+
|
|
92
|
+
### HTTP Request (n8n-nodes-base.httpRequest)
|
|
93
|
+
|
|
94
|
+
Purpose: Check website/API availability and response codes
|
|
95
|
+
|
|
96
|
+
Critical settings:
|
|
97
|
+
- Enable "Continue On Fail" to handle errors gracefully
|
|
98
|
+
- Set timeout to prevent hanging (2-5 seconds typical)
|
|
99
|
+
- Configure retries for transient failure filtering
|
|
100
|
+
|
|
101
|
+
### IF (n8n-nodes-base.if)
|
|
102
|
+
|
|
103
|
+
Purpose: Evaluate service health and route to appropriate action
|
|
104
|
+
|
|
105
|
+
Common conditions:
|
|
106
|
+
- {{$json["statusCode"]}} equals 200 (service up)
|
|
107
|
+
- {{$json["statusCode"]}} not equals 200 (service down)
|
|
108
|
+
|
|
109
|
+
### Send Email (n8n-nodes-base.emailSend)
|
|
110
|
+
|
|
111
|
+
Purpose: Email alerts for service issues
|
|
112
|
+
|
|
113
|
+
Configure with SMTP credentials and clear subject lines for quick issue identification.
|
|
114
|
+
|
|
115
|
+
### Messaging Integration Nodes
|
|
116
|
+
|
|
117
|
+
- Slack (n8n-nodes-base.slack)
|
|
118
|
+
- Microsoft Teams (n8n-nodes-base.microsoftTeams)
|
|
119
|
+
- Telegram (n8n-nodes-base.telegram)
|
|
120
|
+
- Discord (n8n-nodes-base.discord)
|
|
121
|
+
|
|
122
|
+
Purpose: Real-time alerts to team communication channels
|
|
123
|
+
|
|
124
|
+
### Twilio (n8n-nodes-base.twilio)
|
|
125
|
+
|
|
126
|
+
Purpose: SMS/phone alerts for critical system failures requiring immediate attention
|
|
127
|
+
|
|
128
|
+
### Database & Storage Nodes
|
|
129
|
+
|
|
130
|
+
- Google Sheets (n8n-nodes-base.googleSheets)
|
|
131
|
+
- MySQL (n8n-nodes-base.mySql)
|
|
132
|
+
- PostgreSQL (n8n-nodes-base.postgres)
|
|
133
|
+
|
|
134
|
+
Purpose: Store monitoring configuration, log results, track state changes
|
|
135
|
+
|
|
136
|
+
### Execute Workflow (n8n-nodes-base.executeWorkflow)
|
|
137
|
+
|
|
138
|
+
Purpose: Modular monitoring design with sub-workflows for different service types
|
|
139
|
+
|
|
140
|
+
## Common Pitfalls to Avoid
|
|
141
|
+
|
|
142
|
+
### Forgetting to Activate Workflow
|
|
143
|
+
|
|
144
|
+
The #1 monitoring failure - creating the perfect monitoring workflow but forgetting to activate it. Always verify the workflow is active (toggle in top-right of editor).
|
|
145
|
+
|
|
146
|
+
### No Error Handling on Check Nodes
|
|
147
|
+
|
|
148
|
+
Without "Continue On Fail", the workflow crashes when services are down - exactly when you need alerts. This makes monitoring useless at the critical moment.
|
|
149
|
+
|
|
150
|
+
### Alert Storms
|
|
151
|
+
|
|
152
|
+
Sending alerts every check interval creates fatigue. Implement state tracking to alert only on status changes, not every failed check.
|
|
153
|
+
|
|
154
|
+
### Incorrect Schedule Configuration
|
|
155
|
+
|
|
156
|
+
Cron expression mistakes can cause workflows to run at wrong times or not at all. A Cron like "* * * * *" runs every minute (not every hour!). Always test schedules.
|
|
157
|
+
|
|
158
|
+
### Hardcoded Credentials
|
|
159
|
+
|
|
160
|
+
Never hardcode API keys, passwords, or sensitive URLs directly in nodes. Use n8n's credential manager for security and maintainability.
|
|
161
|
+
|
|
162
|
+
### Missing Recovery Notifications
|
|
163
|
+
|
|
164
|
+
Not sending "service recovered" messages leaves teams uncertain about incident resolution. Track state changes bidirectionally.
|
|
165
|
+
|
|
166
|
+
### Resource Exhaustion
|
|
167
|
+
|
|
168
|
+
Monitoring too many services in one workflow or setting intervals too frequent can overload n8n. Split large monitoring lists across multiple workflows.
|
|
169
|
+
|
|
170
|
+
### No Monitoring of Monitoring
|
|
171
|
+
|
|
172
|
+
If the monitoring workflow fails, you're blind to service issues. Implement Error Trigger workflows and external heartbeat monitoring for the monitoring system itself.`;
|
|
173
|
+
getDocumentation() {
|
|
174
|
+
return this.documentation;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.MonitoringBestPractices = MonitoringBestPractices;
|
|
178
|
+
//# sourceMappingURL=monitoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitoring.js","sourceRoot":"","sources":["../../../src/tools/best-practices/monitoring.ts"],"names":[],"mappings":";;;AACA,2DAA2D;AAE3D,MAAa,uBAAuB;IAC1B,SAAS,GAAG,kCAAiB,CAAC,UAAU,CAAC;IACzC,OAAO,GAAG,OAAO,CAAC;IAEV,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wKAoKsI,CAAC;IAExK,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AA7KD,0DA6KC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BestPracticesDocument } from '../../types/best-practices';
|
|
2
|
+
export declare class NotificationBestPractices implements BestPracticesDocument {
|
|
3
|
+
readonly technique: "notification";
|
|
4
|
+
readonly version = "1.0.0";
|
|
5
|
+
private readonly documentation;
|
|
6
|
+
getDocumentation(): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotificationBestPractices = void 0;
|
|
4
|
+
const categorization_1 = require("../../types/categorization");
|
|
5
|
+
class NotificationBestPractices {
|
|
6
|
+
technique = categorization_1.WorkflowTechnique.NOTIFICATION;
|
|
7
|
+
version = '1.0.0';
|
|
8
|
+
documentation = `# Best Practices: Notification Workflows
|
|
9
|
+
|
|
10
|
+
## Workflow Design
|
|
11
|
+
|
|
12
|
+
Structure notification workflows in a clear sequence: Trigger → Data Retrieval/Processing → Condition Check → Notification Action → Post-Notification (logging/tracking). Keep each part modular with nodes dedicated to specific purposes.
|
|
13
|
+
|
|
14
|
+
Choose between event-based triggers (webhooks, form submissions, CRM events) for immediate notifications or scheduled triggers (Cron) for periodic condition monitoring. Test Cron triggers in manual mode first to avoid unintended executions.
|
|
15
|
+
|
|
16
|
+
CRITICAL: Multi-channel notifications should branch from a single condition check to multiple notification nodes in parallel, not duplicate the entire workflow. This enables easy extension and maintenance.
|
|
17
|
+
|
|
18
|
+
Example pattern:
|
|
19
|
+
- Webhook/Schedule Trigger → Fetch Data → IF (threshold exceeded) → [Email + Slack + SMS nodes in parallel]
|
|
20
|
+
- Result: Single workflow handles all channels efficiently with consistent logic
|
|
21
|
+
|
|
22
|
+
## Condition Logic & Filtering
|
|
23
|
+
|
|
24
|
+
Use IF nodes for simple threshold checks without code. For complex conditions (multiple fields, array filtering), use Function nodes to script the logic and filter items that need alerts.
|
|
25
|
+
|
|
26
|
+
Always include empty notification prevention - check that alert-worthy items exist (items.length > 0) before proceeding to notification nodes. Route the false branch to end the workflow or log "no alert needed".
|
|
27
|
+
|
|
28
|
+
Store threshold values in environment variables or external sources (Google Sheets, database) rather than hardcoding. This enables adjustment without workflow modification.
|
|
29
|
+
|
|
30
|
+
## Message Construction
|
|
31
|
+
|
|
32
|
+
Use expressions to inject dynamic data into messages. The expression \`{{ $json.fieldName }}\` pulls data from input items. For email subjects and bodies, include key details like metric names, values, and timestamps.
|
|
33
|
+
|
|
34
|
+
Format messages appropriately for each channel:
|
|
35
|
+
- Email: Support HTML or plain text, use clear subject lines
|
|
36
|
+
- Slack: Use markdown-like formatting, \\n for newlines
|
|
37
|
+
- SMS: Keep concise due to character limits, plain text only
|
|
38
|
+
|
|
39
|
+
## Authentication & Permissions
|
|
40
|
+
|
|
41
|
+
Configure proper credentials for each service:
|
|
42
|
+
- Email: SMTP settings with correct host/port/auth (use App Passwords for Gmail)
|
|
43
|
+
- Slack: Bot token with chat:write scope, bot must be invited to target channel
|
|
44
|
+
- SMS (Twilio): Account SID, Auth Token, verified phone numbers
|
|
45
|
+
|
|
46
|
+
Store sensitive information in n8n credentials system or environment variables, never hardcode in workflows.
|
|
47
|
+
|
|
48
|
+
## Alert Management
|
|
49
|
+
|
|
50
|
+
Implement cooldown mechanisms to prevent notification floods. Record last alert time and check before sending duplicates. Consider alert aggregation - send one message listing multiple items rather than individual alerts.
|
|
51
|
+
|
|
52
|
+
Add logging nodes to track sent notifications for audit trails and duplicate prevention. Consider using error handling paths with Continue on Fail settings for redundancy.
|
|
53
|
+
|
|
54
|
+
## Recommended Nodes
|
|
55
|
+
|
|
56
|
+
### Trigger Nodes
|
|
57
|
+
|
|
58
|
+
**Webhook** (n8n-nodes-base.webhook):
|
|
59
|
+
- Purpose: Event-based notifications triggered by external systems
|
|
60
|
+
- Use cases: Form submissions, CRM events, API webhooks
|
|
61
|
+
- Best practice: Validate incoming data before processing
|
|
62
|
+
|
|
63
|
+
**Schedule Trigger** (n8n-nodes-base.scheduleTrigger):
|
|
64
|
+
- Purpose: Periodic monitoring and batch notifications
|
|
65
|
+
- Use cases: Daily reports, threshold monitoring, scheduled alerts
|
|
66
|
+
- Best practice: Test in manual mode first to avoid unintended executions
|
|
67
|
+
|
|
68
|
+
**Email Trigger IMAP** (n8n-nodes-base.emailReadImap):
|
|
69
|
+
- Purpose: Email-triggered alerts and auto-responses
|
|
70
|
+
- Use cases: Support ticket creation, email monitoring
|
|
71
|
+
- Best practice: Use filters to avoid processing every email
|
|
72
|
+
|
|
73
|
+
### Notification Nodes
|
|
74
|
+
|
|
75
|
+
**Send Email** (n8n-nodes-base.emailSend):
|
|
76
|
+
- Purpose: Detailed alerts with attachments and HTML formatting
|
|
77
|
+
- Use cases: Reports, detailed notifications, formal communications
|
|
78
|
+
- Configuration: SMTP settings, use App Passwords for Gmail
|
|
79
|
+
- Best practice: Use clear subject lines with key information
|
|
80
|
+
|
|
81
|
+
**Slack** (n8n-nodes-base.slack):
|
|
82
|
+
- Purpose: Team notifications in channels or direct messages
|
|
83
|
+
- Use cases: Team alerts, status updates, incident notifications
|
|
84
|
+
- Configuration: Bot token with chat:write scope, bot must be invited to channel
|
|
85
|
+
- Best practice: Use markdown formatting, channel IDs (starting with C) not names
|
|
86
|
+
|
|
87
|
+
**Telegram** (n8n-nodes-base.telegram):
|
|
88
|
+
- Purpose: Instant messaging alerts to individuals or groups
|
|
89
|
+
- Use cases: Personal notifications, bot interactions
|
|
90
|
+
- Configuration: Bot token from BotFather
|
|
91
|
+
- Best practice: Use chat ID for direct messages
|
|
92
|
+
|
|
93
|
+
**Twilio** (n8n-nodes-base.twilio):
|
|
94
|
+
- Purpose: SMS/WhatsApp critical alerts
|
|
95
|
+
- Use cases: High-priority alerts, two-factor authentication, critical incidents
|
|
96
|
+
- Configuration: Account SID, Auth Token, verified phone numbers
|
|
97
|
+
- Best practice: Keep messages concise, use international format (+1234567890)
|
|
98
|
+
|
|
99
|
+
**HTTP Request** (n8n-nodes-base.httpRequest):
|
|
100
|
+
- Purpose: Custom webhooks (Microsoft Teams, Discord, custom APIs)
|
|
101
|
+
- Use cases: Integration with services without dedicated nodes
|
|
102
|
+
- Best practice: Test webhook URLs before production
|
|
103
|
+
|
|
104
|
+
### Logic & Processing
|
|
105
|
+
|
|
106
|
+
**IF** (n8n-nodes-base.if):
|
|
107
|
+
- Purpose: Simple threshold checks and condition routing
|
|
108
|
+
- Use cases: Check if metric exceeds threshold, validate data
|
|
109
|
+
- Best practice: Include empty notification prevention (items.length > 0)
|
|
110
|
+
|
|
111
|
+
**Switch** (n8n-nodes-base.switch):
|
|
112
|
+
- Purpose: Route notifications based on severity/type
|
|
113
|
+
- Use cases: Different channels for different alert levels
|
|
114
|
+
- Best practice: Always define Default case for unexpected values
|
|
115
|
+
|
|
116
|
+
**Function** (n8n-nodes-base.function):
|
|
117
|
+
- Purpose: Complex filtering and data transformation
|
|
118
|
+
- Use cases: Array filtering, complex conditions, message formatting
|
|
119
|
+
- Best practice: Keep logic focused and well-documented
|
|
120
|
+
|
|
121
|
+
**Merge** (n8n-nodes-base.merge):
|
|
122
|
+
- Purpose: Combine parallel notification branches
|
|
123
|
+
- Use cases: Track all notification attempts, consolidate logs
|
|
124
|
+
- Best practice: Use after parallel notification nodes
|
|
125
|
+
|
|
126
|
+
### Data Sources
|
|
127
|
+
|
|
128
|
+
**Database Nodes**:
|
|
129
|
+
- Postgres (n8n-nodes-base.postgres)
|
|
130
|
+
- MySQL (n8n-nodes-base.mySql)
|
|
131
|
+
- MongoDB (n8n-nodes-base.mongoDb)
|
|
132
|
+
|
|
133
|
+
Purpose: Fetch metrics, thresholds, and historical data
|
|
134
|
+
Best practice: Use queries with proper indexing for performance
|
|
135
|
+
|
|
136
|
+
**Google Sheets** (n8n-nodes-base.googleSheets):
|
|
137
|
+
- Purpose: Configuration storage and logging
|
|
138
|
+
- Use cases: Store thresholds, log notifications, track cooldowns
|
|
139
|
+
- Best practice: Use for non-critical configurations that need easy updates
|
|
140
|
+
|
|
141
|
+
**HTTP Request** (n8n-nodes-base.httpRequest):
|
|
142
|
+
- Purpose: API data retrieval
|
|
143
|
+
- Use cases: Fetch metrics from monitoring APIs, get user preferences
|
|
144
|
+
- Best practice: Handle API errors gracefully
|
|
145
|
+
|
|
146
|
+
### Utility Nodes
|
|
147
|
+
|
|
148
|
+
**Set** (n8n-nodes-base.set):
|
|
149
|
+
- Purpose: Prepare alert messages and structure data
|
|
150
|
+
- Use cases: Format notification content, add metadata
|
|
151
|
+
- Best practice: Use to centralize message construction logic
|
|
152
|
+
|
|
153
|
+
**Wait** (n8n-nodes-base.wait):
|
|
154
|
+
- Purpose: Delays between notifications
|
|
155
|
+
- Use cases: Rate limiting, cooldown periods, retry logic
|
|
156
|
+
- Best practice: Use for preventing notification floods
|
|
157
|
+
|
|
158
|
+
**Split In Batches** (n8n-nodes-base.splitInBatches):
|
|
159
|
+
- Purpose: Handle large datasets without overwhelming recipients
|
|
160
|
+
- Use cases: Bulk notifications with rate limiting
|
|
161
|
+
- Best practice: Combine with Wait node for controlled sending
|
|
162
|
+
|
|
163
|
+
## Common Pitfalls to Avoid
|
|
164
|
+
|
|
165
|
+
### Authentication Failures
|
|
166
|
+
**Problem**: Invalid or expired credentials are the most common cause of failed notifications.
|
|
167
|
+
|
|
168
|
+
**Solution**:
|
|
169
|
+
- Regularly verify API keys, OAuth tokens, and SMTP passwords
|
|
170
|
+
- Ensure bots have proper permissions (Slack bots need channel membership)
|
|
171
|
+
- Use n8n credentials system, never hardcode sensitive data
|
|
172
|
+
- Test authentication in isolation before deploying
|
|
173
|
+
|
|
174
|
+
### Notification Floods
|
|
175
|
+
**Problem**: Without proper controls, a threshold breach can trigger hundreds of identical alerts.
|
|
176
|
+
|
|
177
|
+
**Solution**:
|
|
178
|
+
- Implement cooldown periods using Wait node or tracking last alert time
|
|
179
|
+
- Use alert aggregation - send one message listing multiple items
|
|
180
|
+
- Use deduplication logic to prevent identical alerts
|
|
181
|
+
- Consider exponential backoff for repeated alerts
|
|
182
|
+
- Store last notification timestamp in database/sheets
|
|
183
|
+
|
|
184
|
+
### Incorrect Channel Configuration
|
|
185
|
+
**Problem**: Notifications fail due to misconfigured channels.
|
|
186
|
+
|
|
187
|
+
**Solution**:
|
|
188
|
+
- Slack requires channel IDs (starting with C) not names
|
|
189
|
+
- Email requires verified sender addresses
|
|
190
|
+
- SMS needs international format (+1234567890)
|
|
191
|
+
- Test each channel with sample data before production
|
|
192
|
+
- Validate configuration in node settings
|
|
193
|
+
|
|
194
|
+
### Data Type Mismatches
|
|
195
|
+
**Problem**: String-to-number comparisons fail silently ("5" > "10" is lexicographically true).
|
|
196
|
+
|
|
197
|
+
**Solution**:
|
|
198
|
+
- Always convert data types before comparisons
|
|
199
|
+
- Use Number() or parseInt() for numeric comparisons
|
|
200
|
+
- Escape special characters in messages to prevent formatting breaks
|
|
201
|
+
- Validate data types early in the workflow
|
|
202
|
+
|
|
203
|
+
### Missing Error Handling
|
|
204
|
+
**Problem**: A single failed notification can stop the entire workflow.
|
|
205
|
+
|
|
206
|
+
**Solution**:
|
|
207
|
+
- Configure error workflows using Error Trigger node
|
|
208
|
+
- Use "Continue on Fail" setting for redundancy
|
|
209
|
+
- Implement fallback channels (if Slack fails, send email)
|
|
210
|
+
- Log failed notification attempts for debugging
|
|
211
|
+
- Add retry logic with exponential backoff
|
|
212
|
+
|
|
213
|
+
### Rate Limit Violations
|
|
214
|
+
**Problem**: External services have posting limits that can block notifications.
|
|
215
|
+
|
|
216
|
+
**Solution**:
|
|
217
|
+
- Add delays between bulk sends using Wait node
|
|
218
|
+
- Monitor API quotas and adjust trigger frequency
|
|
219
|
+
- Use BCC for bulk emails when appropriate
|
|
220
|
+
- Implement batch processing with Split In Batches
|
|
221
|
+
- Check service documentation for rate limits
|
|
222
|
+
- Use webhook aggregation where possible
|
|
223
|
+
`;
|
|
224
|
+
getDocumentation() {
|
|
225
|
+
return this.documentation;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
exports.NotificationBestPractices = NotificationBestPractices;
|
|
229
|
+
//# sourceMappingURL=notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../../src/tools/best-practices/notification.ts"],"names":[],"mappings":";;;AACA,2DAA2D;AAE3D,MAAa,yBAAyB;IAC5B,SAAS,GAAG,kCAAiB,CAAC,YAAY,CAAC;IAC3C,OAAO,GAAG,OAAO,CAAC;IAEV,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuNjC,CAAC;IAED,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;CACD;AAhOD,8DAgOC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BestPracticesDocument } from '../../types/best-practices';
|
|
2
|
+
export declare class SchedulingBestPractices implements BestPracticesDocument {
|
|
3
|
+
readonly technique: "scheduling";
|
|
4
|
+
readonly version = "1.0.0";
|
|
5
|
+
private readonly documentation;
|
|
6
|
+
getDocumentation(): string;
|
|
7
|
+
}
|