@awesomate/hosting-mcp 0.12.0 → 0.13.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 (58) hide show
  1. package/dist/index.js +204 -8
  2. package/package.json +2 -2
  3. package/skill/awesomate-app-builder/SKILL.md +5 -1
  4. package/skill/awesomate-credentials/SKILL.md +1 -1
  5. package/skill/awesomate-hosting/SKILL.md +50 -159
  6. package/skill/awesomate-hosting/references/connect-troubleshooting.md +77 -0
  7. package/skill/awesomate-hosting/references/multi-account.md +33 -0
  8. package/skill/awesomate-hosting/references/rest-fallback.md +30 -0
  9. package/skill/awesomate-hosting/scripts/bootstrap.mjs +27 -7
  10. package/skill/awesomate-n8n/SKILL.md +153 -147
  11. package/skill/awesomate-n8n/evals/ai-agent-build/graders/grader.md +31 -0
  12. package/skill/awesomate-n8n/evals/ai-agent-build/prompt.md +1 -0
  13. package/skill/awesomate-n8n/evals/build-form-email/graders/grader.md +30 -0
  14. package/skill/awesomate-n8n/evals/build-form-email/prompt.md +1 -0
  15. package/skill/awesomate-n8n/evals/datatable-dedupe/graders/grader.md +32 -0
  16. package/skill/awesomate-n8n/evals/datatable-dedupe/prompt.md +2 -0
  17. package/skill/awesomate-n8n/evals/diagnose-failure/graders/grader.md +27 -0
  18. package/skill/awesomate-n8n/evals/diagnose-failure/prompt.md +2 -0
  19. package/skill/awesomate-n8n/evals/essentials-upsell/graders/grader.md +27 -0
  20. package/skill/awesomate-n8n/evals/essentials-upsell/prompt.md +2 -0
  21. package/skill/awesomate-n8n/evals/live-change-promote/graders/grader.md +35 -0
  22. package/skill/awesomate-n8n/evals/live-change-promote/prompt.md +2 -0
  23. package/skill/awesomate-n8n/evals/possibilities-grounded/graders/grader.md +28 -0
  24. package/skill/awesomate-n8n/evals/possibilities-grounded/prompt.md +1 -0
  25. package/skill/awesomate-n8n/evals/validated-not-done/graders/grader.md +27 -0
  26. package/skill/awesomate-n8n/evals/validated-not-done/prompt.md +2 -0
  27. package/skill/awesomate-n8n/evals/vars-not-env/graders/grader.md +26 -0
  28. package/skill/awesomate-n8n/evals/vars-not-env/prompt.md +2 -0
  29. package/skill/awesomate-n8n/evals/webhook-body-fix/graders/grader.md +26 -0
  30. package/skill/awesomate-n8n/evals/webhook-body-fix/prompt.md +3 -0
  31. package/skill/awesomate-n8n/references/ai-agents.md +135 -0
  32. package/skill/awesomate-n8n/references/datatables.md +105 -0
  33. package/skill/awesomate-n8n/references/{node-recipes.md → platform-notes.md} +56 -7
  34. package/skill/awesomate-n8n/references/possibilities.md +83 -0
  35. package/skill/awesomate-n8n/references/testing-policy.md +115 -0
  36. package/skill/awesomate-n8n/references/troubleshooting.md +69 -0
  37. package/skill/awesomate-n8n/references/upgrade-loop.md +98 -0
  38. package/skill/awesomate-n8n/references/vendor/MANIFEST.json +26 -0
  39. package/skill/awesomate-n8n/references/vendor/code-node/BUILTIN_FUNCTIONS.md +779 -0
  40. package/skill/awesomate-n8n/references/vendor/code-node/COMMON_PATTERNS.md +1123 -0
  41. package/skill/awesomate-n8n/references/vendor/code-node/DATA_ACCESS.md +797 -0
  42. package/skill/awesomate-n8n/references/vendor/code-node/ERROR_PATTERNS.md +776 -0
  43. package/skill/awesomate-n8n/references/vendor/code-node/SKILL.md +703 -0
  44. package/skill/awesomate-n8n/references/vendor/expressions/COMMON_MISTAKES.md +406 -0
  45. package/skill/awesomate-n8n/references/vendor/expressions/EXAMPLES.md +496 -0
  46. package/skill/awesomate-n8n/references/vendor/expressions/SKILL.md +525 -0
  47. package/skill/awesomate-n8n/references/vendor/node-configuration/DEPENDENCIES.md +743 -0
  48. package/skill/awesomate-n8n/references/vendor/node-configuration/OPERATION_PATTERNS.md +926 -0
  49. package/skill/awesomate-n8n/references/vendor/node-configuration/SKILL.md +583 -0
  50. package/skill/awesomate-n8n/references/vendor/validation/ERROR_CATALOG.md +781 -0
  51. package/skill/awesomate-n8n/references/vendor/validation/FALSE_POSITIVES.md +695 -0
  52. package/skill/awesomate-n8n/references/vendor/validation/SKILL.md +414 -0
  53. package/skill/awesomate-n8n/references/vendor/workflow-patterns/SKILL.md +413 -0
  54. package/skill/awesomate-n8n/references/vendor/workflow-patterns/ai_agent_workflow.md +797 -0
  55. package/skill/awesomate-n8n/references/vendor/workflow-patterns/database_operations.md +798 -0
  56. package/skill/awesomate-n8n/references/vendor/workflow-patterns/http_api_integration.md +747 -0
  57. package/skill/awesomate-n8n/references/vendor/workflow-patterns/scheduled_tasks.md +786 -0
  58. package/skill/awesomate-n8n/references/vendor/workflow-patterns/webhook_processing.md +558 -0
@@ -0,0 +1,786 @@
1
+ <!--
2
+ VENDORED from n8n-builder@d293559 (n8n-workflow-patterns/scheduled_tasks.md) — DO NOT EDIT HERE.
3
+ Edit the source in ~/Projects/n8n-builder, then re-run:
4
+ node mcp/scripts/sync-n8n-references.mjs --write
5
+
6
+ Awesomate platform overrides — where this file conflicts with
7
+ ../platform-notes.md, platform-notes wins:
8
+ - $env is BLOCKED fleet-wide → use {{ $vars.key || 'fallback' }}
9
+ - Task runners are ON → no $helpers in Code nodes; use HTTP Request nodes
10
+ - Webhook payloads live at $json.body
11
+ - saveExecutionProgress must stay false
12
+ -->
13
+
14
+ # Scheduled Tasks Pattern
15
+
16
+ **Use Case**: Recurring automation workflows that run automatically on a schedule.
17
+
18
+ ---
19
+
20
+ ## Pattern Structure
21
+
22
+ ```
23
+ Schedule Trigger → [Fetch Data] → [Process] → [Deliver] → [Log/Notify]
24
+ ```
25
+
26
+ **Key Characteristic**: Time-based automated execution
27
+
28
+ ---
29
+
30
+ ## Core Components
31
+
32
+ ### 1. Schedule Trigger
33
+ **Purpose**: Execute workflow at specified times
34
+
35
+ **Modes**:
36
+ - **Interval** - Every X minutes/hours/days
37
+ - **Cron** - Specific times (advanced)
38
+ - **Days & Hours** - Simple recurring schedule
39
+
40
+ ### 2. Data Source
41
+ **Common sources**:
42
+ - HTTP Request (APIs)
43
+ - Database queries
44
+ - File reads
45
+ - Service-specific nodes
46
+
47
+ ### 3. Processing
48
+ **Typical operations**:
49
+ - Filter/transform data
50
+ - Aggregate statistics
51
+ - Generate reports
52
+ - Check conditions
53
+
54
+ ### 4. Delivery
55
+ **Output channels**:
56
+ - Email
57
+ - Slack/Discord/Teams
58
+ - File storage
59
+ - Database writes
60
+
61
+ ### 5. Logging
62
+ **Purpose**: Track execution history
63
+
64
+ **Methods**:
65
+ - Database log entries
66
+ - File append
67
+ - Monitoring service
68
+
69
+ ---
70
+
71
+ ## Schedule Configuration
72
+
73
+ ### Interval Mode
74
+ **Best for**: Simple recurring tasks
75
+
76
+ **Examples**:
77
+ ```javascript
78
+ // Every 15 minutes
79
+ {
80
+ mode: "interval",
81
+ interval: 15,
82
+ unit: "minutes"
83
+ }
84
+
85
+ // Every 2 hours
86
+ {
87
+ mode: "interval",
88
+ interval: 2,
89
+ unit: "hours"
90
+ }
91
+
92
+ // Every day at midnight
93
+ {
94
+ mode: "interval",
95
+ interval: 1,
96
+ unit: "days"
97
+ }
98
+ ```
99
+
100
+ ### Days & Hours Mode
101
+ **Best for**: Specific days and times
102
+
103
+ **Examples**:
104
+ ```javascript
105
+ // Weekdays at 9 AM
106
+ {
107
+ mode: "daysAndHours",
108
+ days: ["monday", "tuesday", "wednesday", "thursday", "friday"],
109
+ hour: 9,
110
+ minute: 0
111
+ }
112
+
113
+ // Every Monday at 6 PM
114
+ {
115
+ mode: "daysAndHours",
116
+ days: ["monday"],
117
+ hour: 18,
118
+ minute: 0
119
+ }
120
+ ```
121
+
122
+ ### Cron Mode (Advanced)
123
+ **Best for**: Complex schedules
124
+
125
+ **Examples**:
126
+ ```javascript
127
+ // Every weekday at 9 AM
128
+ {
129
+ mode: "cron",
130
+ expression: "0 9 * * 1-5"
131
+ }
132
+
133
+ // First day of every month at midnight
134
+ {
135
+ mode: "cron",
136
+ expression: "0 0 1 * *"
137
+ }
138
+
139
+ // Every 15 minutes during business hours (9 AM - 5 PM) on weekdays
140
+ {
141
+ mode: "cron",
142
+ expression: "*/15 9-17 * * 1-5"
143
+ }
144
+ ```
145
+
146
+ **Cron format**: `minute hour day month weekday`
147
+ - `*` = any value
148
+ - `*/15` = every 15 units
149
+ - `1-5` = range (Monday-Friday)
150
+ - `1,15` = specific values
151
+
152
+ **Cron examples**:
153
+ ```
154
+ 0 */6 * * * Every 6 hours
155
+ 0 9,17 * * * At 9 AM and 5 PM daily
156
+ 0 0 * * 0 Every Sunday at midnight
157
+ */30 * * * * Every 30 minutes
158
+ 0 0 1,15 * * 1st and 15th of each month
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Common Use Cases
164
+
165
+ ### 1. Daily Reports
166
+ **Flow**: Schedule → Fetch data → Aggregate → Format → Email
167
+
168
+ **Example** (Sales report):
169
+ ```
170
+ 1. Schedule (daily at 9 AM)
171
+
172
+ 2. Postgres (query yesterday's sales)
173
+ SELECT date, SUM(amount) as total, COUNT(*) as orders
174
+ FROM orders
175
+ WHERE date = CURRENT_DATE - INTERVAL '1 day'
176
+ GROUP BY date
177
+
178
+ 3. Code (calculate metrics)
179
+ - Total revenue
180
+ - Order count
181
+ - Average order value
182
+ - Comparison to previous day
183
+
184
+ 4. Set (format email body)
185
+ Subject: Daily Sales Report - {{$json.date}}
186
+ Body: Formatted HTML with metrics
187
+
188
+ 5. Email (send to team@company.com)
189
+
190
+ 6. Slack (post summary to #sales)
191
+ ```
192
+
193
+ ### 2. Data Synchronization
194
+ **Flow**: Schedule → Fetch from source → Transform → Write to target
195
+
196
+ **Example** (CRM to data warehouse sync):
197
+ ```
198
+ 1. Schedule (every hour)
199
+
200
+ 2. Set (store last sync time)
201
+ SELECT MAX(synced_at) FROM sync_log
202
+
203
+ 3. HTTP Request (fetch new CRM contacts since last sync)
204
+ GET /api/contacts?updated_since={{$json.last_sync}}
205
+
206
+ 4. IF (check if new records exist)
207
+
208
+ 5. Set (transform CRM schema to warehouse schema)
209
+
210
+ 6. Postgres (warehouse - INSERT new contacts)
211
+
212
+ 7. Postgres (UPDATE sync_log SET synced_at = NOW())
213
+
214
+ 8. IF (error occurred)
215
+ └─ Slack (alert #data-team)
216
+ ```
217
+
218
+ ### 3. Monitoring & Health Checks
219
+ **Flow**: Schedule → Check endpoints → Alert if down
220
+
221
+ **Example** (Website uptime monitor):
222
+ ```
223
+ 1. Schedule (every 5 minutes)
224
+
225
+ 2. HTTP Request (GET https://example.com/health)
226
+ - timeout: 10 seconds
227
+ - continueOnFail: true
228
+
229
+ 3. IF (status !== 200 OR response_time > 2000ms)
230
+
231
+ 4. Redis (check alert cooldown - don't spam)
232
+ - Key: alert:website_down
233
+ - TTL: 30 minutes
234
+
235
+ 5. IF (no recent alert sent)
236
+
237
+ 6. [Alert Actions]
238
+ ├─ Slack (notify #ops-team)
239
+ ├─ PagerDuty (create incident)
240
+ ├─ Email (alert@company.com)
241
+ └─ Redis (set alert cooldown)
242
+
243
+ 7. Postgres (log uptime check result)
244
+ ```
245
+
246
+ ### 4. Cleanup & Maintenance
247
+ **Flow**: Schedule → Find old data → Archive/Delete → Report
248
+
249
+ **Example** (Database cleanup):
250
+ ```
251
+ 1. Schedule (weekly on Sunday at 2 AM)
252
+
253
+ 2. Postgres (find old records)
254
+ SELECT * FROM logs
255
+ WHERE created_at < NOW() - INTERVAL '90 days'
256
+ LIMIT 10000
257
+
258
+ 3. IF (records exist)
259
+
260
+ 4. Code (export to JSON for archive)
261
+
262
+ 5. Google Drive (upload archive file)
263
+ - Filename: logs_archive_{{$now.format('YYYY-MM-DD')}}.json
264
+
265
+ 6. Postgres (DELETE archived records)
266
+ DELETE FROM logs
267
+ WHERE id IN ({{$json.archived_ids}})
268
+
269
+ 7. Slack (report: "Archived X records, deleted Y records")
270
+ ```
271
+
272
+ ### 5. Data Enrichment
273
+ **Flow**: Schedule → Find incomplete records → Enrich → Update
274
+
275
+ **Example** (Enrich contacts with company data):
276
+ ```
277
+ 1. Schedule (nightly at 3 AM)
278
+
279
+ 2. Postgres (find contacts without company data)
280
+ SELECT id, email, domain FROM contacts
281
+ WHERE company_name IS NULL
282
+ AND created_at > NOW() - INTERVAL '7 days'
283
+ LIMIT 100
284
+
285
+ 3. Split In Batches (10 contacts per batch)
286
+
287
+ 4. HTTP Request (call Clearbit enrichment API)
288
+ - For each contact domain
289
+ - Rate limit: wait 1 second between batches
290
+
291
+ 5. Set (map API response to database schema)
292
+
293
+ 6. Postgres (UPDATE contacts with company data)
294
+
295
+ 7. Wait (1 second - rate limiting)
296
+
297
+ 8. Loop (back to step 4 until all batches processed)
298
+
299
+ 9. Email (summary: "Enriched X contacts")
300
+ ```
301
+
302
+ ### 6. Backup Automation
303
+ **Flow**: Schedule → Export data → Compress → Store → Verify
304
+
305
+ **Example** (Database backup):
306
+ ```
307
+ 1. Schedule (daily at 2 AM)
308
+
309
+ 2. Code (execute pg_dump)
310
+ const { exec } = require('child_process');
311
+ exec('pg_dump -h db.example.com mydb > backup.sql')
312
+
313
+ 3. Code (compress backup)
314
+ const zlib = require('zlib');
315
+ // Compress backup.sql to backup.sql.gz
316
+
317
+ 4. AWS S3 (upload compressed backup)
318
+ - Bucket: backups
319
+ - Key: db/backup-{{$now.format('YYYY-MM-DD')}}.sql.gz
320
+
321
+ 5. AWS S3 (list old backups)
322
+ - Keep last 30 days only
323
+
324
+ 6. AWS S3 (delete old backups)
325
+
326
+ 7. IF (error occurred)
327
+ ├─ PagerDuty (critical alert)
328
+ └─ Email (backup failed!)
329
+ ELSE
330
+ └─ Slack (#devops: "✅ Backup completed")
331
+ ```
332
+
333
+ ### 7. Content Publishing
334
+ **Flow**: Schedule → Fetch content → Format → Publish
335
+
336
+ **Example** (Automated social media posts):
337
+ ```
338
+ 1. Schedule (every 3 hours during business hours)
339
+ - Cron: 0 9,12,15,18 * * 1-5
340
+
341
+ 2. Google Sheets (read content queue)
342
+ - Sheet: "Scheduled Posts"
343
+ - Filter: status=pending AND publish_time <= NOW()
344
+
345
+ 3. IF (posts available)
346
+
347
+ 4. HTTP Request (shorten URLs in post)
348
+
349
+ 5. HTTP Request (POST to Twitter API)
350
+
351
+ 6. HTTP Request (POST to LinkedIn API)
352
+
353
+ 7. Google Sheets (update status=published)
354
+
355
+ 8. Slack (notify #marketing: "Posted: {{$json.title}}")
356
+ ```
357
+
358
+ ---
359
+
360
+ ## Timezone Considerations
361
+
362
+ ### Set Workflow Timezone
363
+ ```javascript
364
+ // In workflow settings
365
+ {
366
+ timezone: "America/New_York" // EST/EDT
367
+ }
368
+ ```
369
+
370
+ ### Common Timezones
371
+ ```
372
+ America/New_York - Eastern (US)
373
+ America/Chicago - Central (US)
374
+ America/Denver - Mountain (US)
375
+ America/Los_Angeles - Pacific (US)
376
+ Europe/London - GMT/BST
377
+ Europe/Paris - CET/CEST
378
+ Asia/Tokyo - JST
379
+ Australia/Sydney - AEDT
380
+ UTC - Universal Time
381
+ ```
382
+
383
+ ### Handle Daylight Saving
384
+ **Best practice**: Use timezone-aware scheduling
385
+
386
+ ```javascript
387
+ // ❌ Bad: UTC schedule for "9 AM local"
388
+ // Will be off by 1 hour during DST transitions
389
+
390
+ // ✅ Good: Set workflow timezone
391
+ {
392
+ timezone: "America/New_York",
393
+ schedule: {
394
+ mode: "daysAndHours",
395
+ hour: 9 // Always 9 AM Eastern, regardless of DST
396
+ }
397
+ }
398
+ ```
399
+
400
+ ---
401
+
402
+ ## Error Handling
403
+
404
+ ### Pattern 1: Error Trigger Workflow
405
+ **Main workflow**: Normal execution
406
+ **Error workflow**: Alerts and recovery
407
+
408
+ **Main**:
409
+ ```
410
+ Schedule → Fetch → Process → Deliver
411
+ ```
412
+
413
+ **Error**:
414
+ ```
415
+ Error Trigger (for main workflow)
416
+ → Set (extract error details)
417
+ → Slack (#ops-team: "❌ Scheduled job failed")
418
+ → Email (admin alert)
419
+ → Postgres (log error for analysis)
420
+ ```
421
+
422
+ ### Pattern 2: Retry with Backoff
423
+ ```
424
+ Schedule → HTTP Request (continueOnFail: true)
425
+ → IF (error)
426
+ ├─ Wait (5 minutes)
427
+ ├─ HTTP Request (retry 1)
428
+ └─ IF (still error)
429
+ ├─ Wait (15 minutes)
430
+ ├─ HTTP Request (retry 2)
431
+ └─ IF (still error)
432
+ └─ Alert admin
433
+ ```
434
+
435
+ ### Pattern 3: Partial Failure Handling
436
+ ```
437
+ Schedule → Split In Batches
438
+ → Process (continueOnFail: true)
439
+ → Code (track successes and failures)
440
+ → Report:
441
+ "✅ Processed: 95/100"
442
+ "❌ Failed: 5/100"
443
+ ```
444
+
445
+ ---
446
+
447
+ ## Performance Optimization
448
+
449
+ ### 1. Batch Processing
450
+ For large datasets:
451
+
452
+ ```
453
+ Schedule → Query (LIMIT 10000)
454
+ → Split In Batches (100 items)
455
+ → Process batch
456
+ → Loop
457
+ ```
458
+
459
+ ### 2. Parallel Processing
460
+ When operations are independent:
461
+
462
+ ```
463
+ Schedule
464
+ ├─ [Branch 1: Update DB]
465
+ ├─ [Branch 2: Send emails]
466
+ └─ [Branch 3: Generate report]
467
+ → Merge (wait for all) → Final notification
468
+ ```
469
+
470
+ ### 3. Skip if Already Running
471
+ Prevent overlapping executions:
472
+
473
+ ```
474
+ Schedule → Redis (check lock)
475
+ → IF (lock exists)
476
+ └─ End (skip this execution)
477
+ → ELSE
478
+ ├─ Redis (set lock, TTL 30 min)
479
+ ├─ [Execute workflow]
480
+ └─ Redis (delete lock)
481
+ ```
482
+
483
+ ### 4. Early Exit on No Data
484
+ Don't waste time if nothing to process:
485
+
486
+ ```
487
+ Schedule → Query (check if work exists)
488
+ → IF (no results)
489
+ └─ End workflow (exit early)
490
+ → ELSE
491
+ └─ Process data
492
+ ```
493
+
494
+ ---
495
+
496
+ ## Monitoring & Logging
497
+
498
+ ### Pattern 1: Execution Log Table
499
+ ```sql
500
+ CREATE TABLE workflow_executions (
501
+ id SERIAL PRIMARY KEY,
502
+ workflow_name VARCHAR(255),
503
+ started_at TIMESTAMP,
504
+ completed_at TIMESTAMP,
505
+ status VARCHAR(50),
506
+ records_processed INT,
507
+ error_message TEXT
508
+ );
509
+ ```
510
+
511
+ **Log execution**:
512
+ ```
513
+ Schedule
514
+ → Set (record start)
515
+ → [Workflow logic]
516
+ → Postgres (INSERT execution log)
517
+ ```
518
+
519
+ ### Pattern 2: Metrics Collection
520
+ ```
521
+ Schedule → [Execute]
522
+ → Code (calculate metrics)
523
+ - Duration
524
+ - Records processed
525
+ - Success rate
526
+ → HTTP Request (send to monitoring system)
527
+ - Datadog, Prometheus, etc.
528
+ ```
529
+
530
+ ### Pattern 3: Summary Notifications
531
+ Daily/weekly execution summaries:
532
+
533
+ ```
534
+ Schedule (daily at 6 PM) → Query execution logs
535
+ → Code (aggregate today's executions)
536
+ → Email (summary report)
537
+ "Today's Workflow Executions:
538
+ - 24/24 successful
539
+ - 0 failures
540
+ - Avg duration: 2.3 min"
541
+ ```
542
+
543
+ ---
544
+
545
+ ## Testing Scheduled Workflows
546
+
547
+ ### 1. Use Manual Trigger for Testing
548
+ **Development pattern**:
549
+ ```
550
+ Manual Trigger (for testing)
551
+ → [Same workflow logic]
552
+ → [Outputs]
553
+
554
+ // Once tested, replace with Schedule Trigger
555
+ ```
556
+
557
+ ### 2. Test with Different Times
558
+ ```javascript
559
+ // Code node - simulate different times
560
+ const testTime = new Date('2024-01-15T09:00:00Z');
561
+ return [{ json: { currentTime: testTime } }];
562
+ ```
563
+
564
+ ### 3. Dry Run Mode
565
+ ```
566
+ Schedule → Set (dryRun: true)
567
+ → IF (dryRun)
568
+ └─ Log what would happen (don't execute)
569
+ → ELSE
570
+ └─ Execute normally
571
+ ```
572
+
573
+ ### 4. Shorter Interval for Testing
574
+ ```javascript
575
+ // Testing: every 1 minute
576
+ {
577
+ mode: "interval",
578
+ interval: 1,
579
+ unit: "minutes"
580
+ }
581
+
582
+ // Production: every 1 hour
583
+ {
584
+ mode: "interval",
585
+ interval: 1,
586
+ unit: "hours"
587
+ }
588
+ ```
589
+
590
+ ---
591
+
592
+ ## Common Gotchas
593
+
594
+ ### 1. ❌ Wrong: Ignoring timezone
595
+ ```javascript
596
+ Schedule (9 AM) // 9 AM in which timezone?
597
+ ```
598
+
599
+ ### ✅ Correct: Set workflow timezone
600
+ ```javascript
601
+ // Workflow settings
602
+ {
603
+ timezone: "America/New_York"
604
+ }
605
+ ```
606
+
607
+ ### 2. ❌ Wrong: Overlapping executions
608
+ ```
609
+ Schedule (every 5 min) → Long-running task (10 min)
610
+ // Two executions running simultaneously!
611
+ ```
612
+
613
+ ### ✅ Correct: Add execution lock
614
+ ```
615
+ Schedule → Redis (check lock)
616
+ → IF (locked) → Skip
617
+ → ELSE → Execute
618
+ ```
619
+
620
+ ### 3. ❌ Wrong: No error handling
621
+ ```
622
+ Schedule → API call → Process (fails silently)
623
+ ```
624
+
625
+ ### ✅ Correct: Add error workflow
626
+ ```
627
+ Main: Schedule → Execute
628
+ Error: Error Trigger → Alert
629
+ ```
630
+
631
+ ### 4. ❌ Wrong: Processing all data at once
632
+ ```
633
+ Schedule → SELECT 1000000 records → Process (OOM)
634
+ ```
635
+
636
+ ### ✅ Correct: Batch processing
637
+ ```
638
+ Schedule → SELECT with pagination → Split In Batches → Process
639
+ ```
640
+
641
+ ### 5. ❌ Wrong: Hardcoded dates
642
+ ```javascript
643
+ query: "SELECT * FROM orders WHERE date = '2024-01-15'"
644
+ ```
645
+
646
+ ### ✅ Correct: Dynamic dates
647
+ ```javascript
648
+ query: "SELECT * FROM orders WHERE date = CURRENT_DATE - INTERVAL '1 day'"
649
+ ```
650
+
651
+ ---
652
+
653
+ ## Real Template Examples
654
+
655
+ From n8n template library:
656
+
657
+ **Template #2947** (Weather to Slack):
658
+ ```
659
+ Schedule (daily 8 AM)
660
+ → HTTP Request (weather API)
661
+ → Set (format message)
662
+ → Slack (post to #general)
663
+ ```
664
+
665
+ **Daily backup**:
666
+ ```
667
+ Schedule (nightly 2 AM)
668
+ → Postgres (export data)
669
+ → Google Drive (upload)
670
+ → Email (confirmation)
671
+ ```
672
+
673
+ **Monitoring**:
674
+ ```
675
+ Schedule (every 5 min)
676
+ → HTTP Request (health check)
677
+ → IF (down) → PagerDuty alert
678
+ ```
679
+
680
+ Browse the n8n template library (n8n.io/workflows) for more examples!
681
+
682
+ ---
683
+
684
+ ## Checklist for Scheduled Workflows
685
+
686
+ ### Planning
687
+ - [ ] Define schedule frequency (interval, cron, days & hours)
688
+ - [ ] Set workflow timezone
689
+ - [ ] Estimate execution duration
690
+ - [ ] Plan for failures and retries
691
+ - [ ] Consider timezone and DST
692
+
693
+ ### Implementation
694
+ - [ ] Configure Schedule Trigger
695
+ - [ ] Set workflow timezone in settings
696
+ - [ ] Add early exit for no-op cases
697
+ - [ ] Implement batch processing for large data
698
+ - [ ] Add execution logging
699
+
700
+ ### Error Handling
701
+ - [ ] Create Error Trigger workflow
702
+ - [ ] Implement retry logic
703
+ - [ ] Add alert notifications
704
+ - [ ] Log errors for analysis
705
+ - [ ] Handle partial failures gracefully
706
+
707
+ ### Monitoring
708
+ - [ ] Log each execution (start, end, status)
709
+ - [ ] Track metrics (duration, records, success rate)
710
+ - [ ] Set up daily/weekly summaries
711
+ - [ ] Alert on consecutive failures
712
+ - [ ] Monitor resource usage
713
+
714
+ ### Testing
715
+ - [ ] Test with Manual Trigger first
716
+ - [ ] Verify timezone behavior
717
+ - [ ] Test error scenarios
718
+ - [ ] Check for overlapping executions
719
+ - [ ] Validate output quality
720
+
721
+ ### Deployment
722
+ - [ ] Document workflow purpose
723
+ - [ ] Set up monitoring
724
+ - [ ] Configure alerts
725
+ - [ ] Activate workflow in the n8n UI (toggle at the top of the editor)
726
+ - [ ] Test in production (short interval first)
727
+ - [ ] Monitor first few executions
728
+
729
+ ---
730
+
731
+ ## Advanced Patterns
732
+
733
+ ### Dynamic Scheduling
734
+ **Change schedule based on conditions**:
735
+
736
+ ```
737
+ Schedule (check every hour) → Code (check if it's time to run)
738
+ → IF (business hours AND weekday)
739
+ └─ Execute workflow
740
+ → ELSE
741
+ └─ Skip
742
+ ```
743
+
744
+ ### Dependent Schedules
745
+ **Chain workflows**:
746
+
747
+ ```
748
+ Workflow A (daily 2 AM): Data sync
749
+ → On completion → Trigger Workflow B
750
+
751
+ Workflow B: Generate report (depends on fresh data)
752
+ ```
753
+
754
+ ### Conditional Execution
755
+ **Skip based on external factors**:
756
+
757
+ ```
758
+ Schedule → HTTP Request (check feature flag)
759
+ → IF (feature enabled)
760
+ └─ Execute
761
+ → ELSE
762
+ └─ Skip
763
+ ```
764
+
765
+ ---
766
+
767
+ ## Summary
768
+
769
+ **Key Points**:
770
+ 1. **Set workflow timezone** explicitly
771
+ 2. **Batch processing** for large datasets
772
+ 3. **Error handling** is critical (Error Trigger + retries)
773
+ 4. **Prevent overlaps** with execution locks
774
+ 5. **Monitor and log** all executions
775
+
776
+ **Pattern**: Schedule → Fetch → Process → Deliver → Log
777
+
778
+ **Schedule Modes**:
779
+ - **Interval**: Simple recurring (every X minutes/hours)
780
+ - **Days & Hours**: Specific days and times
781
+ - **Cron**: Advanced complex schedules
782
+
783
+ **Related**:
784
+ - [http_api_integration.md](http_api_integration.md) - Fetching data on schedule
785
+ - [database_operations.md](database_operations.md) - Scheduled database tasks
786
+ - [webhook_processing.md](webhook_processing.md) - Alternative to scheduling