Library
N8N Foundation · Chapter 1 of 10Preview
Chapter 01

N8N Foundations &
Mental Models

Think like an automation engineer. Learn the primitives — nodes, items, JSON, expressions — that turn scattered SaaS tools into a single, reliable system.

n8nAutomationWebhooksJSONExpressions
A Handbook For Builders
N8N Foundations &
Mental Models
Chapter 01
The Claude Code Handbook

Automation is not a tool — it is a way of thinking. Before you touch a single node, you must see your work as a graph of events, data, and decisions. This chapter builds that mental model, then grounds it in three real workflows you can rebuild in an hour.

Section 1

1. What is Automation

Automation is any system that performs a task without a human doing it manually every time. In software, it means turning a repeatable process — "when a form is submitted, save it to a sheet and email the team" — into code that runs forever, unattended, at 3am on a Sunday.

  • Trigger — the event that starts the workflow (webhook, schedule, new row).
  • Steps — the actions performed on the data (transform, call API, filter).
  • Outcome — the side-effects (a row written, a message sent, a file saved).
Section 2

2. A Short History of Automation

  1. 1980s — Shell scripts & cron. Sysadmins glued binaries with bash.
  2. 2000s — Enterprise iPaaS. MuleSoft, Boomi. Powerful, but priced for banks.
  3. 2011 — Zapier. Democratised SaaS-to-SaaS glue with a simple UI.
  4. 2019 — n8n. Open source, self-hostable, node-based, unlimited steps.
  5. 2024 — AI-native workflows. LLMs became first-class nodes: routing, extraction, agents.
Section 3

3. Traditional Automation vs AI Automation

Traditional automation is deterministic: if X happens, do exactly Y. AI automation is probabilistic: given fuzzy input, decide what to do. The best workflows combine both — deterministic plumbing, AI only where reasoning is needed.

Section 4

4. What is n8n

n8n (pronounced n-eight-n) is an open-source workflow automation platform. You compose workflows visually by connecting nodes. Each node either fetches data, transforms it, or sends it somewhere. Under the hood it runs on Node.js and stores state in SQLite or Postgres. You can self-host it or use n8n Cloud.

n8n — Editor
Screenshot placeholder
n8n canvas — a webhook node connected to a Set node, then a Google Sheets node.
Figure — n8n canvas — a webhook node connected to a Set node, then a Google Sheets node.
Section 5

5. How n8n Works

diagramclaude-code
Trigger Node ──▶ Action Node ──▶ Action Node ──▶ Output
  (Webhook)       (HTTP)          (Sheets)         (Response)

Each arrow carries an ARRAY of items.
Each item is a JSON object: { json: { ... }, binary?: { ... } }
Section 6

6. Nodes & Connections

A node is a single step. A connection is the wire between nodes that carries data. Nodes have inputs (left) and outputs (right). Most nodes have one of each — the IF node has two outputs (true / false), and Merge has two inputs.

Section 7

7. Executions & Data

An execution is one run of the workflow. Every execution is stored so you can replay it, inspect what each node saw, and debug failures. Click any node after a run to see the exact JSON that flowed in and out.

n8n — Executions
Screenshot placeholder
Execution view: green ticks on every successful node, red X on failures, JSON inspector on the right.
Figure — Execution view: green ticks on every successful node, red X on failures, JSON inspector on the right.
Section 8

8. JSON & Expressions

Every item in n8n is JSON. Expressions let you reach into that JSON at runtime using ${{ $json.field }} style syntax. Example:

jsclaude-code
// Static value
"Hello world"

// Expression — reads from the previous node
={{ $json.customer.name }}

// Combine
=Hello {{ $json.customer.name }}, your order {{ $json.order_id }} is confirmed.
Section 9

9. Triggers & Actions

  • Trigger nodes — start a workflow. Webhook, Cron, Email, Telegram Trigger, Manual.
  • Action nodes — do work. HTTP Request, Set, Code, Google Sheets, Send Email.
Section 10

10. Data Flow

Data flows left-to-right as an array of items. If a node emits 10 items, the next node runs 10 times (once per item) unless you turn on "Execute Once". This is the single most important concept in n8n — everything is an array.

Section 11

11. Workflow Architecture

diagramclaude-code
[Trigger] ─▶ [Validate] ─▶ [Enrich] ─▶ [Route (IF)] ─┬─▶ [Notify Slack]
                                                    └─▶ [Save to DB]
Section 12

12. Items, Merge, Split, Loop

  • Split In Batches — process 100 rows in chunks of 10 to respect rate limits.
  • Merge — combine two branches by index, key, or wait-until-both.
  • Item Lists — turn one item with an array field into many items, and back.
  • Loop Over Items — explicit iteration when you need a counter.
Section 13

13. IF & Error Handling

The IF node routes on a condition. For failures, attach an Error Triggerworkflow — any execution that crashes will fire it, so you can post to Slack or write to a log.

Section 14

14. Environment Variables & Credentials

Never paste an API key into a node. Store it once as a Credential (encrypted at rest with your N8N_ENCRYPTION_KEY), then reference it from any node. Config values that change per environment go in .env and are read with $env.NAME.

Section 15

15. Execution History

Every run — success or failure — is stored in the executions database. Filter by workflow, by status, by time. Retry a failed execution from the exact node it broke on.

Section 16

16. Zapier vs Make vs n8n

diagramclaude-code
               Zapier         Make            n8n
Pricing        per task       per operation   free (self-host)
Hosting        cloud only     cloud only      cloud OR self-host
Code node      limited        yes             full Node.js
Complex logic  hard           medium          native
AI nodes       add-on         add-on          first-class
Best for       non-devs       power users     engineers
Section 17

17. Project · Webhook Workflow

  1. Add a Webhook trigger node. Copy the test URL.
  2. Add a Set node — create a field greeting = =Hello {{ $json.body.name }}.
  3. Add a Respond to Webhook node returning {{ $json }}.
  4. Test with curl:
bashclaude-code
curl -X POST https://your-n8n.example.com/webhook-test/hello \
  -H "Content-Type: application/json" \
  -d '{"name": "Sara"}'
# → { "greeting": "Hello Sara" }
Section 18

18. Project · Google Sheets Workflow

  1. Create a Google Sheet with columns name, email, created_at.
  2. Add the same Webhook trigger.
  3. Add a Google Sheets node → operation Append.
  4. Map name={{ $json.body.name }}, email={{ $json.body.email }}, created_at={{ $now.toISO() }}.
Section 19

19. Project · Telegram Bot

  1. Talk to @BotFather, create a bot, copy the token.
  2. In n8n add a Telegram Trigger → paste the token as a credential → event message.
  3. Add a Telegram · Send Message node. Chat ID → ={{ $json.message.chat.id }}.
  4. Text → =You said: {{ $json.message.text }}. Activate. DM your bot.
n8n — Telegram Bot
Screenshot placeholder
Telegram echo bot — trigger, set, send-message. Three nodes, live in five minutes.
Figure — Telegram echo bot — trigger, set, send-message. Three nodes, live in five minutes.
Section 20

20. Mini Project & Checklist