DEV Community

אחיה כהן
אחיה כהן

Posted on • Originally published at achiya-automation.com

7 n8n Workflow Patterns Every Automation Developer Should Know

After building 50+ automation systems with n8n, I've identified recurring workflow patterns that solve common business problems. Here are 7 patterns I use in almost every project.

1. The Webhook → Validate → Route Pattern

The most fundamental pattern. An external event triggers a webhook, you validate the payload, then route to different branches based on content.

Webhook → IF (has required fields?) 
  → YES: Switch (by event type) → Handle each type
  → NO: Error Workflow → Alert via Slack/WhatsApp
Enter fullscreen mode Exit fullscreen mode

Real use case: A WhatsApp bot receives messages. The webhook validates the payload structure, then routes: text messages go to AI classification, media goes to storage, location shares go to the CRM.

Pro tip: Always validate webhook payloads before processing. External services send malformed data more often than you'd think.

2. The Batch Processing Pattern

When you need to process hundreds or thousands of items without hitting API rate limits.

Trigger → Get Items (from DB/Sheet) 
  → SplitInBatches (size: 50) 
  → Process Batch 
  → Wait (2 seconds) 
  → Loop back
Enter fullscreen mode Exit fullscreen mode

Real use case: Sending WhatsApp broadcast messages to 500+ customers. WhatsApp Business API has rate limits (~80 messages/second for tier 1). SplitInBatches + Wait ensures you stay within limits.

Pro tip: Store progress using getWorkflowStaticData() so if the workflow crashes mid-batch, you can resume from where you left off — not from the beginning.

3. The Error Recovery Pattern

Production workflows WILL fail. The question is: do you find out immediately, or a week later?

Main Workflow → Error Trigger → 
  → Log error to Google Sheets
  → Send WhatsApp/Slack alert with error details
  → Optionally: retry the failed item
Enter fullscreen mode Exit fullscreen mode

Real use case: A CRM sync workflow fails because the API returned a 429 (rate limit). The error workflow logs the failure, waits 60 seconds, and retries the specific failed item — not the entire batch.

Pro tip: Include the execution ID, node name, and error message in your alert. This makes debugging 10x faster.

4. The Deduplication Pattern

Webhooks sometimes fire multiple times for the same event. Without dedup, you'll process duplicates.

Webhook → Function (check staticData for event ID)
  → IF (already processed?) 
  → YES: Stop
  → NO: Store ID in staticData → Continue processing
Enter fullscreen mode Exit fullscreen mode
// Dedup using workflow static data
const staticData = getWorkflowStaticData('global');
const eventId = items[0].json.id;

if (!staticData.processed) staticData.processed = {};
if (staticData.processed[eventId]) {
  return []; // Already processed, skip
}

staticData.processed[eventId] = Date.now();

// Cleanup old entries (keep last 1000)
const entries = Object.entries(staticData.processed);
if (entries.length > 1000) {
  const sorted = entries.sort((a, b) => a[1] - b[1]);
  sorted.slice(0, entries.length - 1000).forEach(([key]) => {
    delete staticData.processed[key];
  });
}

return items;
Enter fullscreen mode Exit fullscreen mode

5. The AI Classification Pattern

Use LLMs to classify incoming data and route workflows accordingly.

Input (email/message/form) 
  → OpenAI/Claude (classify intent: hot_lead | support | spam)
  → Switch (by classification)
  → hot_lead: Immediate WhatsApp + CRM update
  → support: Create ticket in helpdesk
  → spam: Archive and ignore
Enter fullscreen mode Exit fullscreen mode

Real use case: A real estate agency receives inquiries from 5 different sources. Each inquiry goes through AI classification: "ready to buy" gets an immediate call-back, "just browsing" enters a 7-day drip sequence, "spam" is silently archived.

Pro tip: Include 3-5 examples in your prompt for few-shot classification. Accuracy jumps from ~70% to ~95%.

6. The Scheduled Report Pattern

Automatically generate and deliver business reports on a schedule.

Cron (every Monday 8 AM) 
  → Query CRM (leads this week)
  → Query Google Sheets (revenue data)
  → Merge data
  → Generate HTML report
  → Send via email/WhatsApp
Enter fullscreen mode Exit fullscreen mode

Real use case: Every Monday, a business owner receives a WhatsApp message with: new leads count, conversion rate, revenue, and top-performing channels — all auto-generated from their CRM + Google Sheets.

Pro tip: Use the HTML node to create a formatted report, then convert to PDF if needed. Store reports in Google Drive for historical access.

7. The Multi-Channel Sync Pattern

Keep data consistent across multiple platforms in real-time.

Webhook (from any source)
  → Identify source (CRM? Form? WhatsApp?)
  → Normalize data format
  → Update all OTHER platforms (not the source)
  → Log sync event
Enter fullscreen mode Exit fullscreen mode

Real use case: When a customer updates their phone number in the CRM, the workflow automatically updates it in Google Sheets, the WhatsApp contact list, and the invoicing system — without creating an infinite loop (because it skips the source platform).

Pro tip: Always track the "source" of each update to prevent infinite sync loops. Platform A updates B, B triggers update to A, A triggers update to B... Add a sync_source field and skip if it matches the current platform.


Bonus: Combining Patterns

Real production workflows combine multiple patterns. A typical WhatsApp bot workflow uses:

  • Pattern 1 (webhook + route) for message handling
  • Pattern 4 (dedup) for webhook reliability
  • Pattern 5 (AI classification) for intent detection
  • Pattern 3 (error recovery) for production reliability

What's Your Most-Used Pattern?

I'd love to hear what patterns you've developed. Drop a comment below!


I build WhatsApp bots and business automation systems using n8n (self-hosted). More detailed guides on my site: achiya-automation.com — Business Automation Guide

Top comments (0)