Setting Up Business Process Automation via n8n
n8n is an open-source automation platform with a visual workflow editor. Unlike Zapier and Make, n8n is self-hosted, supports arbitrary JavaScript in nodes, and has no operation limits.
Typical Automation Scenarios
- New user in database → welcome email + CRM task + Slack notification
- Incoming webhook → data processing → Google Sheets entry + SMS send
- Cron task: daily PostgreSQL report → formatting → email send
- New WooCommerce order → invoice creation in 1C → manager notification
n8n Architecture
Workflow consists of nodes:
- Trigger: Webhook, Cron, Database polling, Event
- Action: HTTP Request, Send Email, Slack, Telegram, DB operations
- Transform: Code (JavaScript/Python), Set, Merge, Split
- Logic: If, Switch, Wait, Loop Over Items
Example: Onboarding Automation
[Trigger: Webhook POST /signup]
│
[Node: Validate email] ──error──► [Node: Slack #errors]
│
[Node: PostgreSQL INSERT user]
│
[Node: Split in Batches]
│
┌───┴────────────────────────┐
▼ ▼
[Node: SendGrid [Node: HubSpot
Welcome Email] Create Contact]
│ │
└────────────┬───────────────┘
▼
[Node: Slack
#new-users notify]
Code Node (JavaScript)
// Data transformation inside workflow
const items = $input.all();
return items.map(item => {
const user = item.json;
const registrationDate = new Date(user.created_at);
return {
json: {
...user,
displayName: `${user.first_name} ${user.last_name}`.trim() || user.email,
isWeekendRegistration: [0, 6].includes(registrationDate.getDay()),
utmSource: user.utm_source || 'organic',
welcomeEmailSubject: user.plan === 'pro'
? `Welcome to Pro, ${user.first_name}!`
: `Welcome, ${user.first_name}!`
}
};
});
HTTP Request Node
{
"method": "POST",
"url": "https://api.sendgrid.com/v3/mail/send",
"authentication": "headerAuth",
"headers": {
"Authorization": "Bearer {{ $env.SENDGRID_API_KEY }}"
},
"body": {
"personalizations": [
{
"to": [{ "email": "={{ $json.email }}" }],
"dynamic_template_data": {
"name": "={{ $json.displayName }}",
"plan": "={{ $json.plan }}"
}
}
],
"from": { "email": "[email protected]" },
"template_id": "d-abc123"
}
}
Error Handling
[Main workflow]
│
────┼──── error handler branch ────►
│ │
[Node: Continue on fail = true] [Node: Slack alert]
│
[Node: Log to DB]
Enable "Continue On Fail" in node settings + separate Error Workflow branch for alerts.
Timeline
Simple workflow (3–5 nodes) — 1 day. Complex workflow with conditions, transformations, and error handling — 3–5 days.







