Building Workflows in n8n
Every n8n workflow starts with a trigger, flows through nodes that transform or act on data, and ends with an output. This page walks through the key building blocks and patterns.
Workflow Anatomy
Every workflow: trigger โ process โ branch โ act
Trigger Types
| Trigger | When it fires | Common use |
|---|---|---|
| Webhook | An HTTP request hits your n8n URL | Receive data from any external system |
| Schedule | A cron expression (every hour, daily at 9am, etc.) | Periodic data pulls, reports, digests |
| Manual | You click 'Execute' in the editor | Testing and one-off runs |
| Email Trigger | A new email arrives in Gmail or Outlook | Support tickets, lead capture |
| Chat Trigger | A message is sent to an n8n chat UI | Chatbot interfaces for AI agents |
| Form Trigger | An n8n-hosted form is submitted | Data collection without a custom form backend |
| App Triggers | A new record in Airtable, a Slack message, a GitHub PR | Event-driven automations from any connected app |
Data Flow - Items and Fields
Data in n8n flows as an array of items. Each item is a JSON object. Most nodes process each item individually - if 10 emails come in, the next node runs 10 times. Key concepts:
{{ $json.fieldName }}- access the current item's data in expressions{{ $node['NodeName'].json.field }}- reference data from a specific previous node{{ $items() }}- access all items from the previous node- Merge node - combine data from two parallel branches
- Split In Batches - process large arrays in chunks to avoid API rate limits
Flow Control Nodes
Error Handling
n8n has two error handling mechanisms:
- Try/Catch on nodes: Right-click any node โ "Continue on Fail" to prevent the whole workflow failing if that node errors. The error data flows to the next node.
- Error Workflow: Set a separate workflow to trigger whenever any workflow fails. Use it to send Slack alerts or log failures to a database.
Debugging Tips
- Click any node after execution to see exactly what data it received and output - the most useful debugging tool
- Use the Code node to
console.log()intermediate values - Pin data on a trigger node to test the rest of the workflow without re-triggering the source system
- Use execution logs (left sidebar) to see all past runs and replay them
- The Test URL on webhook triggers lets you send a test payload without going to your source system
Starting From Templates
n8n has a template library at n8n.io/workflows with 1,000+ community-contributed workflows. Many AI agent templates are available - search for "AI agent", "ChatGPT", "summarization", or your specific use case. Templates are one-click imports into your n8n instance.