Skip to main content

Workflow Patterns

Proven architectural patterns for building n8n workflows, based on analysis of real workflow usage.

Pattern Selection Guide

Pattern Statistics

Most common triggers: Webhook (35%), Schedule (28%), Manual (22%), Service triggers (15%) Most common transformations: Set/field mapping (68%), Code/custom logic (42%), IF/conditional (38%), Switch (18%) Most common outputs: HTTP Request (45%), Slack (32%), Database writes (28%), Email (24%)

Pattern 1: Webhook Processing

Most common pattern — 35% of all workflows

Structure

Node List

  1. Webhook — HTTP endpoint (instant trigger)
  2. IF / Switch — Validate incoming data
  3. Set — Map/transform fields
  4. Action node — Slack, Email, HTTP Request, Database
  5. Respond to Webhook — Send HTTP response back to caller

Use Cases

  • Form submissions (contact forms, sign-ups)
  • Payment webhooks (Stripe, PayPal)
  • Git webhooks (GitHub, GitLab push events)
  • Slack slash commands
  • Chat integrations

Quick Start Example

Webhook data is nested under .body.Always access webhook payload fields as {{$json.body.fieldName}}, not {{$json.fieldName}}.

Template Reference

The n8n template library has hundreds of webhook processing examples. Search with:

Pattern 2: HTTP API Integration

Structure

Node List

  1. Trigger — Manual, Schedule, or Webhook
  2. HTTP Request — Fetch from REST API
  3. Split In Batches — Handle large result sets
  4. Set / Code — Transform API response
  5. Action node — Database write, Slack notification, etc.
  6. Error Trigger — Catch and handle failures

Use Cases

  • Data fetching and synchronization with third-party services
  • Building data pipelines between systems
  • Multi-step API orchestration
  • Converting between service formats (e.g., GitHub → Jira)

Quick Start Example

Key Configuration Notes

Template Reference


Pattern 3: Database Operations

Structure

Node List

  1. Schedule — Trigger on cron schedule
  2. Postgres / MySQL / MongoDB — Read source database
  3. IF — Check if records exist or need updating
  4. Set / Code — Transform and clean data
  5. Postgres / MySQL — Write to target database
  6. Postgres — Update sync timestamp or log result

Use Cases

  • Database synchronization between systems
  • ETL (Extract, Transform, Load) workflows
  • Scheduled reports from database queries
  • Data backup and archival
  • Incremental sync (only new/changed records)

Quick Start Example

Key Configuration Notes


Pattern 4: AI Agent Workflow

Structure

Node List

  1. Webhook / Chat Trigger — Receive user message
  2. AI Agent (nodes-langchain.agent) — Core reasoning node
  3. OpenAI Chat Model — Connected via ai_languageModel
  4. Tool nodes — Connected via ai_tool (HTTP Request, DB Query, etc.)
  5. Window Buffer Memory — Connected via ai_memory
  6. Webhook Response — Send AI reply back to user

Use Cases

  • Conversational chatbots with tool access
  • AI assistants that can query databases or call APIs
  • Content generation with data lookup
  • Multi-step reasoning and decision-making

Quick Start Example

AI Connection Types Reference

Use ai_agents_guide() from the n8n-mcp server for comprehensive AI workflow guidance including connection types, tool configuration, and prompt engineering.

Pattern 5: Scheduled Tasks

Structure

Node List

  1. Schedule Trigger — Cron-based timing
  2. HTTP Request / Database — Fetch fresh data
  3. Code / Set — Aggregate and format data
  4. Email / Slack — Deliver report or notification
  5. Error Trigger → Slack — Notify on failure

Use Cases

  • Daily/weekly analytics reports emailed to team
  • Hourly health checks for external services
  • Nightly database backups
  • Periodic data synchronization
  • Maintenance workflows (cleanup, archival)

Quick Start Example

Template #2947 (Weather to Slack):

Schedule Examples


Data Flow Patterns

Use when: Simple workflows with a single execution path.

Common Workflow Components

  • Webhook — HTTP endpoint, instant response to events
  • Schedule — Cron-based timing for periodic tasks
  • Manual — Click to execute (testing and admin)
  • Polling — Check for changes at intervals
  • Set — Map and transform fields (used in 68% of workflows)
  • Code — Complex custom logic in JavaScript or Python
  • IF / Switch — Conditional routing
  • Merge — Combine multiple data streams
  • Error Trigger — Catch workflow-level errors
  • IF — Check for error conditions inline
  • Stop and Error — Explicit failure node
  • Continue On Fail — Per-node setting to keep workflow running

Workflow Creation Checklist

1

Planning Phase

  • Identify the pattern (webhook, API, database, AI, scheduled)
  • List required nodes (use search_nodes)
  • Map data flow: input → transform → output
  • Plan error handling strategy
2

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
3

Validation Phase

  • Validate each node with validate_node
  • Validate complete workflow with validate_workflow
  • Test with sample data
  • Handle edge cases (empty data, API errors)
4

Deployment Phase

  • Review workflow settings (execution order, timeout)
  • Activate using activateWorkflow operation
  • Monitor first executions
  • Document workflow purpose and data flow

Common Gotchas

Best Practices

Do

  • Start with the simplest pattern that solves your problem
  • Plan workflow structure before building
  • Add error handling to every production workflow
  • Test with sample data before activation
  • Use descriptive node names
  • Build iteratively (avg 56s between edits is normal)

Don't

  • Build complex multi-pattern workflows without clear boundaries
  • Skip validation before activation
  • Ignore error scenarios
  • Hardcode credentials in node parameters
  • Forget to handle empty data cases
  • Deploy without testing