n8n Workflow Patterns
Proven architectural patterns for building n8n workflows.
The 5 Core Patterns
Based on analysis of real workflow usage:
-
Webhook Processing (Most Common)
- Receive HTTP requests → Process → Output
- Pattern: Webhook → Validate → Transform → Respond/Notify
-
- Fetch from REST APIs → Transform → Store/Use
- Pattern: Trigger → HTTP Request → Transform → Action → Error Handler
-
- Read/Write/Sync database data
- Pattern: Schedule → Query → Transform → Write → Verify
-
- AI agents with tools and memory
- Pattern: Trigger → AI Agent (Model + Tools + Memory) → Output
-
- Recurring automation workflows
- Pattern: Schedule → Fetch → Process → Deliver → Log
Pattern Selection Guide
When to use each pattern:
Webhook Processing - Use when:
- Receiving data from external systems
- Building integrations (Slack commands, form submissions, GitHub webhooks)
- Need instant response to events
- Example: "Receive Stripe payment webhook → Update database → Send confirmation"
HTTP API Integration - Use when:
- Fetching data from external APIs
- Synchronizing with third-party services
- Building data pipelines
- Example: "Fetch GitHub issues → Transform → Create Jira tickets"
Database Operations - Use when:
- Syncing between databases
- Running database queries on schedule
- ETL workflows
- Example: "Read Postgres records → Transform → Write to MySQL"
AI Agent Workflow - Use when:
- Building conversational AI
- Need AI with tool access
- Multi-step reasoning tasks
- Example: "Chat with AI that can search docs, query database, send emails"
Scheduled Tasks - Use when:
- Recurring reports or summaries
- Periodic data fetching
- Maintenance tasks
- Example: "Daily: Fetch analytics → Generate report → Email team"
Common Workflow Components
All patterns share these building blocks:
1. Triggers
- Webhook - HTTP endpoint (instant)
- Schedule - Cron-based timing (periodic)
- Manual - Click to execute (testing)
- Polling - Check for changes (intervals)
2. Data Sources
- HTTP Request - REST APIs
- Database nodes - Postgres, MySQL, MongoDB
- Service nodes - Slack, Google Sheets, etc.
- Code - Custom JavaScript/Python
3. Transformation
- Set - Map/transform fields
- Code - Complex logic
- IF/Switch - Conditional routing
- Merge - Combine data streams
4. Outputs
- HTTP Request - Call APIs
- Database - Write data
- Communication - Email, Slack, Discord
- Storage - Files, cloud storage
5. Error Handling
- Error Trigger - Catch workflow errors
- IF - Check for error conditions
- Stop and Error - Explicit failure
- Continue On Fail - Per-node setting
Workflow Creation Checklist
When building ANY workflow, follow this checklist:
Planning Phase
- Identify the pattern (webhook, API, database, AI, scheduled)
- List required nodes (use search_nodes)
- Understand data flow (input → transform → output)
- Plan error handling strategy
Implementation Phase
- Create workflow with appropriate trigger
- Add data source nodes
- Configure authentication/credentials
- Add transformation nodes (Set, Code, IF)
- Add output/action nodes
- Configure error handling
Validation Phase
- Validate each node configuration (validate_node_operation)
- Validate complete workflow (validate_workflow)
- Test with sample data
- Handle edge cases (empty data, errors)
Deployment Phase
- Review workflow settings (execution order, timeout, error handling)
- Activate workflow ⚠️ Manual activation required in n8n UI (API/MCP cannot activate)
- Monitor first executions
- Document workflow purpose and data flow
Data Flow Patterns
Linear Flow
Trigger → Transform → Action → End
Use when: Simple workflows with single path
Branching Flow
Trigger → IF → [True Path]
└→ [False Path]
Use when: Different actions based on conditions
Parallel Processing
Trigger → [Branch 1] → Merge
└→ [Branch 2] ↗
Use when: Independent operations that can run simultaneously
Loop Pattern
Trigger → Split in Batches → Process → Loop (until done)
Use when: Processing large datasets in chunks
Error Handler Pattern
Main Flow → [Success Path]
└→ [Error Trigger → Error Handler]
Use when: Need separate error handling workflow
Common Gotchas
1. Webhook Data Structure
Problem: Can't access webhook payload data
Solution: Data is nested under $json.body
❌ {{$json.email}}
✅ {{$json.body.email}}
See: n8n Expression Syntax skill
2. Multiple Input Items
Problem: Node processes all input items, but I only want one
Solution: Use "Execute Once" mode or process first item only
{{$json[0].field}} // First item only
3. Authentication Issues
Problem: API calls failing with 401/403
Solution:
- Configure credentials properly
- Use the "Credentials" section, not parameters
- Test credentials before workflow activation
4. Node Execution Order
Problem: Nodes executing in unexpected order
Solution: Check workflow settings → Execution Order
- v0: Top-to-bottom (legacy)
- v1: Connection-based (recommended)
5. Expression Errors
Problem: Expressions showing as literal text
Solution: Use {{}} around expressions
- See n8n Expression Syntax skill for details
Integration with Other Skills
These skills work together with Workflow Patterns:
n8n MCP Tools Expert - Use to:
- Find nodes for your pattern (search_nodes)
- Understand node operations (get_node_essentials)
- Create workflows (n8n_create_workflow)
n8n Expression Syntax - Use to:
- Write expressions in transformation nodes
- Access webhook data correctly ({{$json.body.field}})
- Reference previous nodes ({{$node["Node Name"].json.field}})
n8n Node Configuration - Use to:
- Configure specific operations for pattern nodes
- Understand node-specific requirements
n8n Validation Expert - Use to:
- Validate workflow structure
- Fix validation errors
- Ensure workflow correctness before deployment
Best Practices
✅ Do
- Start with the simplest pattern that solves your problem
- Plan your workflow structure before building
- Use error handling on all workflows
- Test with sample data before activation
- Follow the workflow creation checklist
- Use descriptive node names
- Document complex workflows (notes field)
- Monitor workflow executions after deployment
❌ Don't
- Build workflows in one shot (iterate! avg 56s between edits)
- Skip validation before activation
- Ignore error scenarios
- Use complex patterns when simple ones suffice
- Hardcode credentials in parameters
- Forget to handle empty data cases
- Mix multiple patterns without clear boundaries
- Deploy without testing
Summary
Key Points:
- 5 core patterns cover 90%+ of workflow use cases
- Webhook processing is the most common pattern
- Use the workflow creation checklist for every workflow
- Plan pattern → Select nodes → Build → Validate → Deploy
- Integrate with other skills for complete workflow development
