ProjekinAja. Agentic AI Stage 5 · Multi-Agent Automation Lesson 5.5
● Stage 5 · Lesson 5.5

n8n Deep-Dive — Visual Agent Automation

In 4.3 you met the idea of wiring tools without code. Now we go deep on the tool the agent-builder community loves most: n8n. Same anatomy — but with a real AI Agent node that packs the whole loop, tools, and memory into a single box.

⏱ ~16 min read 🧩 Visual automation 🤖 The AI Agent node

🎯 By the end you'll understand

What n8n is and why it's a favourite for agentic automation, its core node families (triggers, action nodes, flow-control, and the AI nodes), how the AI Agent node wraps everything from Stage 2 into one box, how to modularize with sub-workflows, how n8n speaks MCP, how credentials and human-approval nodes keep you safe — and the honest line between when n8n wins and when code wins.

KEY INSIGHTThe one idea to take away

n8n's AI Agent node is the entire Stage 2 agent — the loop, the tools, the memory — folded into a single box on a canvas. You stop wiring the loop by hand and start configuring it.

In Lesson 4.3 the "AI step" was a fixed brain you dropped into a pipe. n8n takes that further. It gives you a proper AI Agent node with sockets underneath it — plug in a chat model, plug in tools, plug in a memory store — and the node runs the act → observe → decide loop you studied in Lesson 2.1 for you. The rest of n8n is the plumbing that feeds it (triggers), routes it (flow-control), and lets it touch the world (actions). One canvas, hundreds of integrations, and the agent loop is a node you assemble.

🔑 Hold onto this

n8n's UI will keep changing — menu names, panel layouts, the exact look of the AI Agent node. Don't memorize pixels. Memorize the durable structure: a workflow is nodes connected by wires; a trigger starts it; an AI Agent node is loop + model + tools + memory; deterministic nodes do the irreversible work. Learn that and any version of n8n reads like a map you already own.

DEFINITIONWhat n8n actually is

n8n (pronounced "n-eight-n," short for nodemation) is an open-source, self-hostable workflow automation platform. Like Zapier and Make (which you met in 4.3), you build automations by connecting boxes on a visual canvas. But n8n earned its place in the agent-builder's toolbox for a few specific reasons:

📖 n8n

An open-source, self-hostable automation platform where you build workflows as graphs of connected nodes. Notable for deep flexibility (branching, loops, raw code), a large integration library, and native AI Agent nodes that turn a workflow into an agent.

FRAMEWORKThe core node types

Everything in n8n is a node — a single box that does one job, wired to the next by a connection. There are only four families to learn, and once you know them you can read any workflow on the canvas.

Node typeWhat it doesExample
⚡ TriggerStarts the workflow. Every workflow needs exactly one to run.Webhook, Schedule, Gmail Trigger (new email), new row added
🛠️ Action / RegularDoes work: calls an app, transforms data, runs code. The "hands."HTTP Request, Gmail · Send, Set (shape data), Code (JS/Python)
⑂ Flow-controlDecides where data goes and how it's grouped or repeated.IF, Switch, Merge, Loop / Split in Batches
🧠 AI nodesAdd intelligence: a model, a full agent, tools, memory, retrieval.Chat Model, AI Agent, Tool nodes, Memory, Vector Store

A quick tour of each family, with the config-level detail — what you actually put into the box:

⚡

Trigger nodes

The spark. A Webhook gives you a URL another app pings; a Schedule runs on a cron ("every weekday 8am"); an app-event trigger fires on "new email," "new row," "new Stripe payment." You configure which account and which event. No trigger, the workflow never runs.

🛠️

Action / regular nodes

The doers. HTTP Request calls any API (you fill in URL, method, headers, body). App nodes like Gmail · Send expose friendly fields (to, subject, body). Set reshapes data; the Code node lets you write raw JavaScript or Python when no node fits. These are deterministic: same input, same behaviour.

⑂

Flow-control nodes

The routing. IF splits two ways on a true/false test; Switch splits many ways; Merge rejoins branches; Loop / Split in Batches runs a set of items one chunk at a time (handy for rate limits). This is how one workflow handles every situation, not just one.

🧠

AI nodes

The brains. A Chat Model node points at an LLM (you pick the provider/model and credential). The AI Agent node runs the loop. Tool nodes are capabilities the agent can call. A Memory node remembers the conversation. A Vector Store node powers retrieval (the RAG idea from Lesson 2.4).

💡 Two kinds of connection

Most wires flow left→right, carrying data from one step to the next. But the AI nodes use a second kind: things like the chat model, tools, and memory plug into the AI Agent node from underneath as attachments, not as the next step. Spotting that "plugged in from below" shape is the fastest way to recognise an agent on an n8n canvas.

CORE CONCEPTThe AI Agent node is Stage 2 in a box

Here's the payoff for everything you learned in Stage 2. Remember the formula from Lesson 1.1: an agent is an LLM + tools + a loop, pointed at a goal. The n8n AI Agent node is exactly that formula, wrapped in a single configurable box. Look at what you plug into it:

And the part you don't wire by hand: the loop (2.1). Inside the node, the agent reads the goal, decides whether to call a tool, calls it, observes the result, and repeats — until it has an answer. In 4.3 you had to imagine that loop running between your boxes. In n8n the loop lives inside the AI Agent node. You configure it; n8n runs it.

▸ The mapping, made explicit

AI Agent node = the Chat Model (brain) + attached Tools (hands) + Memory + the loop, all in one box, pointed at your system prompt (goal). Every Stage 2 concept becomes a socket you fill in.

PRACTICALWhat an agentic workflow looks like

Let's draw the canonical build we'll keep returning to: a new support email arrives → an AI Agent classifies it and drafts a reply → if it's urgent, route to a human for approval → send. Here is the node graph, with the AI Agent's attachments plugged in from below:

⚡ Gmail Trigger new support email 🤖 AI Agent classify + draft reply 🧠 Chat Model the LLM brain 🛠️ Tools lookup / KB 💾 Memory thread history ⑂ IF urgent? true / false 🙋 Wait · approve human checkpoint 📤 Gmail · Send routine reply then send
A real agentic n8n workflow: trigger → AI Agent (model + tools + memory attached below) → IF → human approval / send.

Read it as a sentence: "When a support email arrives, the AI Agent — using its model, its lookup tools, and the thread's memory — classifies it and drafts a reply. The IF node checks if it's urgent: if so, pause for a human to approve before the Gmail Send node fires; if routine, send straight away." That single shape covers a huge slice of real business automation.

SEE ITBuild an n8n workflow

Now assemble it yourself. Toggle nodes on in order to grow the workflow — and attach the AI Agent's brain, tools, and memory. Watch the node graph fill in and the readout describe what your workflow does, with a safety note. The order matters: an agent with no model can't think; a Send with no approval before it is risky.

🧩 Interactive · Grow the node graph

Switch nodes on to build: Trigger → AI Agent (+ attachments) → IF → Human approval → Send.

📧 Email Trigger
Fires when a new support email arrives.
🤖 AI Agent node
Runs the loop: classify the email + draft a reply.
🧠 Chat model (attached)
The LLM brain that reasons each step.
🛠️ Tools (attached)
Order lookup, knowledge base — things it can call.
💾 Memory (attached)
Remembers the email thread's history.
⑂ IF · urgent?
Branch on the agent's classification.
🙋 Human approval (Wait)
Pause until a person clicks approve.
📤 Gmail · Send
Deterministic action — the reply goes out.

CORE CONCEPTSub-workflows: the n8n way to modularize

As a workflow grows, one giant canvas becomes the "haunted house" we warned about in 4.3 — impossible to read or debug. n8n's answer is the sub-workflow: a workflow you can call from another workflow, like calling a function.

You wrap a chunk of logic — say, "look up a customer and enrich their record" — into its own workflow with an Execute Sub-workflow Trigger. Then, from a main workflow, an Execute Sub-workflow node calls it, passes data in, and gets a result back. The detail stays hidden in the child; the parent reads cleanly.

💡 This is multi-agent, in disguise

Recognise the shape? It's the orchestrator → worker pattern from Lesson 5.2 and Lesson 5.3. A main "orchestrator" workflow can call several specialised "worker" sub-workflows — each a focused agent. And because a sub-workflow can be attached to an AI Agent node as a tool, the agent itself can decide to invoke a worker. Sub-workflows are how you build modular, multi-agent systems on one canvas without the spaghetti.

🧭 Orchestrator workflow decides which worker to call 🔎 Research sub-workflow a focused worker agent ✍️ Drafting sub-workflow a focused worker agent results return to the orchestrator
Sub-workflows let one orchestrator call specialised worker agents — the 5.2 / 5.3 pattern on a canvas.

CONTEXTMCP in n8n — joining the standard tool ecosystem

Back in Lesson 2.8 you met MCP (the Model Context Protocol) — the "USB-C for tools," a standard way for agents to discover and call tools without bespoke wiring for each one. n8n speaks MCP on both sides of the wire:

💡 Why this matters

MCP support means n8n isn't an island. It plugs into the same standard tool layer everything else is converging on (2.8). You can consume tools the community already built, and publish your workflows for others to consume — visual automation and the coded agent world, speaking one language.

PRACTICALCredentials & human-approval nodes

To let a node touch Gmail, Stripe, or your database, you store a credential in n8n — a saved login or API token the node uses to act on your behalf. This is power, and it deserves the two safety habits from across the course.

✗ Credentials and irreversible sends are where n8n bites

A stored credential lets the workflow act without you watching. If an AI Agent mis-classifies one email and it's wired straight into Gmail · Send, a wrong reply lands in a real customer's inbox — and you cannot un-send it. Treat "send," "delete," "pay," and "post publicly" as irreversible. Scope credentials tightly, and gate every irreversible action behind a human-approval node until dozens of correct runs have earned your trust.

COMPARISONWhen n8n shines vs when code wins

n8n is brilliant, but it's not always the right answer. You met the no-code limits in 4.3 and crossed to code in Lesson 5.4. Here's the honest split:

Reach for n8n when…Reach for code when…
You're gluing many SaaS apps together (Gmail, Slack, Sheets, Stripe).Your logic is genuinely complex — many edge cases, tricky transforms.
You need scheduled or triggered automations running unattended.You need tight control over the loop, retries, and prompts.
You want visual debugging — seeing data flow node-to-node, inspecting each step.You want version control, tests, and code review on the agent itself.
You want to ship fast without a developer.You're hitting node limits, fighting the canvas, or need a tool nobody built.
▸ It's not either/or

The best builders mix both. Use n8n's Code node for the tricky bit inside a visual flow. Or have your coded agent (5.4) call an n8n workflow via its MCP Server Trigger or webhook. Visual where it's fast, code where it's hard — that's the next lesson's whole theme (5.6).

WEAKNESSCommon mistakes to avoid

✗ Giving an n8n credential full account scope

Connecting a credential with read-write-delete over your whole Gmail or database "to be safe" is the opposite of safe. One bug or one bad agent decision now has the keys to everything. Scope every credential to the narrowest permission the workflow actually needs (3.4).

✗ Auto-sending before a human-approval node

Wiring the AI Agent straight into Gmail · Send with no Wait / approval node feels efficient — until it mis-judges one email and fires a wrong reply you can't recall. Gate every irreversible action behind a human approval until many correct runs have earned trust (3.4).

✗ Rebuilding complex logic visually when code is clearer

Some logic — nested edge cases, intricate data transforms, careful retry rules — turns into a tangle of a dozen IF and Switch nodes that's harder to read than ten lines of code. When the canvas fights you more than it helps, drop into a Code node or move that piece to real code (5.4).

KEY INSIGHTWhere this connects in your course

  • No-code: connecting tools (4.3) — the trigger → AI step → action anatomy; n8n is that anatomy made deep, with a real AI Agent node.
  • The agent loop & tools (2.1, 2.2) — exactly what the AI Agent node wraps: loop + model + attached tools + memory.
  • MCP (2.8) — n8n can be an MCP client (consume tools) and an MCP server (expose workflows). The standard tool layer.
  • Human approval & the trust gradient (3.4) — the Wait node before irreversible sends.
  • Agentic automation (3.10) — the agent decides, deterministic nodes execute.
  • Multi-agent patterns (5.2, 5.3) — sub-workflows give you orchestrator → worker on a canvas.
  • Build it in code (5.4) — the other side of the choice; when to graduate past visual.
  • Agents + automation together (5.6) — next, where code agents and n8n workflows combine into one system.

Hold the durable structure — trigger → AI Agent (model + tools + memory) → flow-control → action, with approval before the irreversible — and any version of n8n, and any visual automation tool, will read like a language you already speak.

GLOSSARYKey terms introduced

n8n
An open-source, self-hostable visual automation platform where workflows are graphs of connected nodes; notable for flexibility and native AI Agent nodes.
Node
A single box on the canvas that does one job (trigger, action, flow-control, or AI), wired to others by connections.
Trigger
The node that starts a workflow — a webhook, a schedule, or an app event like "new email." Every workflow needs one.
AI Agent node
An n8n node that runs the full agent loop. You attach a chat model (brain), tools (hands), and memory; it decides and acts until done. Stage 2 in a box.
Sub-workflow
A workflow callable from another workflow (like a function), used to modularize logic and build orchestrator → worker multi-agent systems.
Credential
A stored login or API token an n8n node uses to act on a connected app on your behalf; scope it to least privilege.
MCP client
n8n acting as a consumer of MCP servers — attaching an MCP Client Tool node so an agent can call standard external tools.
Human-approval node
A Wait-style node that pauses the workflow until a person approves — placed before irreversible actions like sending or charging.

ACTIVE RECALLCheck your understanding

Answer in your own words first, then reveal.

1What does the n8n AI Agent node wrap, and which part don't you wire by hand?›

It wraps the whole 1.1 formula: a chat model (brain), attached tools (hands), and memory, pointed at a goal via its system prompt. The part you don't wire is the loop (2.1) — act → observe → decide → repeat runs inside the node. You configure it; n8n runs it.

2Name the four families of n8n nodes and one example of each.›

Triggers (Webhook, Schedule, Gmail Trigger), action/regular nodes (HTTP Request, Gmail Send, Set, Code), flow-control (IF, Switch, Merge, Loop / Split in Batches), and AI nodes (Chat Model, AI Agent, Tools, Memory, Vector Store).

3What is a sub-workflow, and how does it relate to multi-agent systems?›

A sub-workflow is a workflow you call from another, like a function — used to modularize and keep the canvas readable. It's the orchestrator → worker pattern from 5.2/5.3: a main workflow calls specialised worker sub-workflows, and a sub-workflow can even be attached to an AI Agent as a tool.

4Give two safety practices for n8n, and one sign it's time to use code instead.›

Least-privilege credentials (scope each token to the minimum needed) and a human-approval node before any irreversible action (3.4). It's time for code when logic gets genuinely complex, you need tight control/tests, or you're fighting the canvas more than it helps (5.4).

You can now read and build an n8n agent. Next: agents + automation together →