Are you drowning in manual tasks? Copy-pasting data from a spreadsheet to your CRM? Manually sending welcome emails? In today’s hyper-connected world, the gap between the apps we use creates a massive amount of digital “grunt work.” This repetitive, manual effort doesn’t just drain your time; it drains your energy and focus.
What if you could build a digital assistant that connects all your apps and does this work for you? An assistant that doesn’t need to sleep, never makes copy-paste errors, and can run complex, multi-step processes at the click of a button or on a perfect schedule.
That assistant is n8n.
This is not just another introductory blog post. This is the last n8n guide you will ever need. We’ve taken all the essential information—from the absolute basics to advanced AI agent configuration—and packaged it into one complete deep dive. This is the encyclopedia I wish I had when I first started building workflows.
We will cover everything. No external info is required. By the end of this guide, you will be able to think, build, and deploy powerful automations that can fundamentally change how you work.
What is n8n?
At its simplest, n8n is a workflow automation tool. Think of it as the digital plumbing for your business. You have dozens of powerful applications (your “appliances”) like Google Sheets, Slack, Salesforce, WordPress, and Shopify. By themselves, they’re fantastic. But they don’t talk to each other. n8n is the system of pipes, valves, and pumps that connects them all.
When something happens in one app (a “trigger”), n8n can automatically make something happen in one or many other apps (an “action”).
- Example: When a new row is added to a Google Sheet (trigger), n8n can grab that data, format it, send a custom message in Slack (action 1), and create a new customer in your CRM (action 2).
No more copy-pasting. No more manual exports. Just seamless, automatic data flow.
What Makes n8n Different? (n8n vs. Zapier vs. Make)
You’ve probably heard of other tools like Zapier or Make (formerly Integromat). While they all aim to automate, n8n is built on a different philosophy that gives you, the user, unprecedented power and control.
- You Own Your Data (Self-Hosting): This is the game-changer. While n8n offers a convenient cloud version, its true power lies in its “source-available” model. You can download n8n for free and run it on your own server (or any cheap cloud virtual machine). This means your data, your credentials, and your customer information never have to leave your infrastructure. For anyone in healthcare (HIPAA), finance, or any security-conscious industry, this is not just a feature; it’s a requirement.
- Node-Based Architecture: n8n’s visual canvas is built on “nodes.” Each node is a powerful, pre-built connector to an app or a function (like filtering data). You visually chain these nodes together, allowing you to build infinitely complex and branching logic that other tools simply cannot handle. It’s less like a simple “if this, then that” and more like a visual programming language.
- Extensible and “Code-able”: Don’t see a node for your specific, in-house API? No problem. The HTTP Request node can connect to any app with an API. Need to perform a complex data transformation? The Code node lets you drop in raw JavaScript (or Python) to do literally anything you can imagine. n8n is the perfect “low-code” tool that scales with your skills into a “pro-code” powerhouse.
- Built-in AI Capabilities: n8n isn’t just connecting apps; it’s integrating next-generation AI. You can build powerful AI Agents that can reason, use your other nodes as “tools,” and perform complex tasks autonomously. We will dedicate an entire chapter to this.
- Fair-Code, Not Just “Free Tier”: The free, self-hosted version of n8n is not a crippled “free trial.” It is the full-featured product. You get all 400+ nodes, unlimited workflows, and unlimited steps. You are only limited by the power of the server you run it on.
Who is n8n For?
- Small Businesses: Save countless hours by automating lead-gen from your website, sending invoices, and managing customer support.
- Marketing Teams: Automate your content pipeline. When a blog post is published in WordPress, automatically generate 5 tweets, a LinkedIn post, and a summary email for your newsletter.
- Developers & IT: Stop writing one-off “glue code” scripts. Build, manage, and monitor all your internal processes and API integrations from one central, visual platform.
- Agencies: Build robust, white-labeled automations for your clients.
- Power Users: Anyone who has ever thought, “There has to be a better way to do this,” will find a home in n8n.

Getting Started: The Two Paths to Your First Workflow
You have two primary options for getting n8n up and running. There is no wrong choice; it’s about what you value more: speed or control.
Option 1: n8n Cloud (The “5-Minute” Path)
This is the easiest, fastest, and most “hands-off” way to start. n8n’s team manages the servers, security, and updates for you.
- Go to
n8n.cloudand sign up. - Choose your plan. The “Starter” plan (around €20/month) is more than enough to get started and includes a generous number of workflow executions.
- You’re done. You’ll be instantly redirected to your n8n canvas, ready to build.
Choose this path if: You want to get started immediately, you don’t have technical experience with servers, and you prefer a managed, maintenance-free service.

Option 2: Self-Hosted (The “Ultimate Control” Path)
This is the path that makes n8n famous. You run the entire n8n platform on your own infrastructure. This is cheaper in the long term (costing as little as $5-$10/month for a basic cloud server) and gives you 100% data sovereignty.
However, the original document’s advice is crucial: Do not try to set this up yourself unless you are technical. You will spend days fighting with server configurations, Docker, SSL certificates, and database connections.
The Smart Move: As the source doc says, hire someone on a site like Fiverr or Upwork. Search for “n8n installation.” For $25-$50, an expert can have you up and running on a secure cloud server (like DigitalOcean, Vultr, or Hetzner) in a few hours. This is the single best shortcut you can take.
The “DIY” Path (For Technical Users):
If you’re comfortable with the command line and server management, here is the high-level path using Docker (the recommended method):
- Get a Server: Spin up a new Ubuntu 22.04 server on your cloud provider of choice. A machine with 2GB RAM and 2 vCPUs is a strong start.
- Point Your Domain: Create a subdomain (e.g.,
n8n.yourcompany.com) and point its A-record to your new server’s IP address. - Install Docker: Log into your server via SSH and install Docker and Docker Compose.
- Create a
docker-compose.ymlfile: This file tells Docker how to run n8n. Create a directory (e.g.,mkdir n8n-prodandcd n8n-prod) and create a file nameddocker-compose.yml.

# Example docker-compose.yml for n8n
version: '3.7'
services:
n8n:
image: n8nio/n8n
restart: always
ports:
- "127.0.0.1:5678:5678"
environment:
- N8N_HOST=n8n.yourcompany.com
- N8N_PROTOCOL=https
- NODE_ENV=production
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=db
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n_user
- DB_POSTGRESDB_PASSWORD=YOUR_VERY_SECURE_PASSWORD
- N8N_ENCRYPTION_KEY=YOUR_OTHER_VERY_SECURE_KEY
- GENERIC_TIMEZONE=America/New_York
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- db
db:
image: postgres:14
restart: always
environment:
- POSTGRES_DB=n8n
- POSTGRES_USER=n8n_user
- POSTGRES_PASSWORD=YOUR_VERY_SECURE_PASSWORD
volumes:
- n8n_db_data:/var/lib/postgresql/data
volumes:
n8n_data:
n8n_db_data:
- Set Up a Reverse Proxy: You should not expose n8n directly to the internet. A reverse proxy (like Nginx or Caddy) will handle incoming traffic and, most importantly, manage your free SSL certificates (HTTPS). Caddy is fantastic for this as it’s incredibly simple.
- Launch: Run
docker-compose up -dto start your n8n instance and database in the background.
This process gives you a secure, persistent, and production-ready n8n instance with full control.
The Most Important Chapter: Understanding JSON and Data Flow
Before you touch a single node, you must understand this chapter. This is the #1 thing beginners skip and the #1 reason they get frustrated.
What is JSON?
JSON (JavaScript Object Notation) is the language that n8n and 99% of all modern web services use to exchange data.
Think of it like a digital filing cabinet.
- A
file cabinetis an Object, and it’s wrapped in curly braces{}. - A
fileinside the cabinet is a Key-Value Pair. It has a label (the “Key”) and contents (the “Value”). - A
listof files is an Array, and it’s wrapped in square brackets[].
Here is a simple JSON example representing a user:
{
"name": "John Smith",
"email": "john@company.com",
"age": 30,
"is_active": true,
"tags": [ "priority-support", "newsletter-subscriber" ]
}
"name"is a Key."John Smith"is its String Value."age"is a Key.30is its Number Value."is_active"is a Key.trueis its Boolean Value."tags"is a Key.[ ... ]is its Array Value.
How Data Flows in n8n
In n8n, data moves between nodes as a series of Items. Each item is a single JSON object.
When a workflow runs, it looks like this:
Node 1 (Trigger) -> Node 2 (Action) -> Node 3 (Action)
Node 1 (e.g., a form trigger) runs and creates one item:
[
{
"name": "Jane Doe",
"email": "jane@example.com",
"message": "Hello!"
}
]
This entire list of items is passed to Node 2. Node 2 (e.g., a “Send Slack Message” node) runs once for each item it receives. Since it received one item, it runs once.
But what if your trigger (like a “Google Sheets” node) finds three new rows? It will output three items:
[
{ "name": "Jane Doe", "email": "jane@example.com" },
{ "name": "John Smith", "email": "john@company.com" },
{ "name": "Bob Brown", "email": "bob@test.com" }
]
This list of three items is passed to Node 2. Node 2 (the Slack node) will then run three separate times, once for each item, sending three different Slack messages.
This “run for each item” logic is the fundamental secret to n8n’s power.
The Expression Editor: How to Use the Data
This is the most critical UI element in n8n. When you’re in a node’s parameter field (like the “Message” field of a Slack node), you’ll see a small ƒx icon. This opens the Expression Editor. This is how you tell n8n to use dynamic data from previous nodes.

Here are the essential expressions you will use 99% of the time:
Accessing Data from the Current Item:
This is the most common. {{ $json.key }} pulls data from the item currently being processed.
{{ $json.name }}-> “John Smith”{{ $json.age }}-> 30{{ $json.tags[0] }}-> “priority-support” (Accessing the first item in the array)- Nested Data:
{{ $json.user.profile.name }}(Just add dots to go deeper)
Accessing Data from the Previous Node:
This is useful but less common. {{ $input.item.json.key }}. It’s often easier to just use $json as described above, as n8n automatically passes data along.
Accessing Data from a Specific Node:
This is incredibly powerful. You can pull data from any node in your workflow, not just the previous one. This is perfect for when you need a piece of data from your trigger after 10 other nodes have run.
The syntax is: {{ $('Node Name').first().json.key }}
$('Node Name'): Selects the node by its name (e.g.,$('Webhook Trigger'))..first(): Tells n8n to just get the first item from that node’s output. (You can also use.last()or.item(index))..json: Accesses the JSON data of that item..key: The specific data you want.
Example: {{ $('Start').first().json.customer_id }}
Using JavaScript inside Expressions:
The {{ }} brackets aren’t just for variables; they can run any JavaScript.
- Concatenation:
Hello, {{ $json.firstName + ' ' + $json.lastName }}! - Math:
Your total is: {{ $json.quantity * $json.unit_price }} - Ternary Operator (inline IF):
{{ $json.amount > 1000 ? 'High Value' : 'Standard' }} - Built-in Variables: n8n gives you helpers.
{{ $now }}gives you the current date and time (using the powerful Luxon library). You can format it:{{ $now.toFormat('yyyy-MM-dd') }}.
Master the Expression Editor, and you have mastered n8n.
The n8n Node Encyclopedia: A Deep Dive Reference
A workflow is built from nodes. Here is a complete reference for the most essential nodes you will use every day, expanded with deep-dive examples.
Trigger Nodes (How Workflows Start)
Triggers are the starting point. They are the only nodes that don’t have an input.
Webhook Trigger: The Universal Receiver
- What it does: Creates a unique URL that can receive data from any external source. This is how you connect website forms, payment gateways (like Stripe), or any app that can send an HTTP request.
- Key Settings:
- HTTP Method:
POSTis for receiving data (most common).GETis for retrieving data (e.g., from a link click). - Path: A custom, friendly name for your URL (e.g.,
contact-form) instead of the default random string. - Authentication: Set this to “Header Auth” and create a secure key to prevent spam.
- Response Mode: “Immediately” sends a “Workflow started” message right away. “When Last Node Finishes” will wait for your entire workflow to run and send the final data back as the response (perfect for building custom APIs).
- HTTP Method:
- Common Use Cases:
- Powering a website contact form (Elementor, Webflow, etc.).
- Receiving notifications from Stripe (“new payment succeeded”).
- Receiving data from IoT devices.
- Creating your own custom API endpoints.
- Common Mistakes:
- Forgetting to activate your workflow. The webhook URL will not work until the workflow is “Active.”
- Using the “Test URL” in production. Always use the “Production URL.”
Schedule Trigger: Time-Based Automation
- What it does: Runs a workflow at a specific, repeating time.
- Key Settings:
- Interval: Run every X minutes, hours, days.
- Custom Cron: The “pro” setting. This lets you define any schedule.
0 9 * * 1-5-> Run at 9:00 AM, Monday to Friday.*/15 * * * *-> Run every 15 minutes.0 0 1 * *-> Run at midnight on the first day of every month.
- Timezone: Crucial! Always set this to your local timezone, or your workflow will run at the wrong time.
- Common Use Cases:
- Send a daily report to Slack at 8 AM.
- Run a backup script every Sunday at midnight.
- Check for new blog posts to syndicate every 15 minutes.
n8n Form Trigger: Professional User Forms
- What it does: Creates a beautiful, multi-step web form, hosted by n8n, that triggers a workflow when submitted.
- Key Settings:
- Form Fields: Add text, textareas, numbers, dropdowns, email, and even file uploads.
- Conditional Logic: Show or hide fields based on previous answers (e.g., “If
referral_sourceis ‘Other’, showother_text_field“). - Multi-Step: Break a long form into logical pages.
- Common Use Cases:
- A simple “Contact Us” form.
- A complex, multi-page customer onboarding questionnaire.
- An internal tool for your team (e.g., “Request New Software”).
Error Trigger: Handle Workflow Failures
- What it does: This is a special trigger. It doesn’t start a workflow on its own. Instead, it “catches” errors from other workflows.
- Setup:
- Create a new workflow starting with the “Error Trigger.”
- Add nodes to notify you (e.g., Slack, Email) and log the error (e.g., Google Sheets).
- Go to your main workflow, open its settings, and in the “Error Workflow” dropdown, select the new error-handling workflow you just created.
- Why it’s Essential: When your main workflow fails, n8n will automatically trigger your error workflow, sending it all the data about the failure (error message, failed node, input data). This lets you build resilient, production-grade automations that tell you when they break.
Core Processing Nodes (The “Workhorses”)
These are the nodes that do the actual work of transforming, routing, and processing your data.
Edit Fields (Set) Node: Data Transformation
- What it does: This is one of the most important nodes. It allows you to create, modify, rename, or delete data fields (keys) in your JSON item.
- Key Settings:
- Mode: Manual Mapping: A visual interface.
- Field Name: The key you want to create/change (e.g.,
full_name). - Field Value: The value to put there. Use the Expression Editor!
- Field Name: The key you want to create/change (e.g.,
- Mode: JSON Output: For pros. Lets you write the entire output JSON object from scratch.
- Include Other Input Fields:Crucial.
- Checked (Default): Keeps all the old data and just adds/modifies the fields you defined.
- Unchecked: Deletes all incoming data and only outputs the new fields you defined. (Useful for cleaning up data).
- Mode: Manual Mapping: A visual interface.
- Common Operations:
- Combine Fields: Create
full_namewith value{{ $json.first_name + ' ' + $json.last_name }} - Calculate Values: Create
total_pricewith value{{ $json.quantity * $json.unit_price }} - Format Dates: Create
formatted_datewith value{{ $now.toFormat('yyyy-MM-dd') }} - Rename a Key: Create
customer_emailwith value{{ $json.email }}and then use another “Set” node (or the “Move Binary/JSON Data” node) to remove the originalemailkey. - Create Nested Objects: Use “Dot Notation” in the Field Name, e.g.,
user.profile.email, with a value of{{ $json.email }}.
- Combine Fields: Create
HTTP Request Node: The API Master Key
- What it does: Connects to any web service or API in the world, even if n8n doesn’t have a dedicated node for it.
- Request Configuration:
- Method:
GET: Retrieve data (e.g., get a list of users).POST: Create new data (e.g., create a new user).PUT/PATCH: Update existing data.DELETE: Remove data.
- URL: The full API endpoint, e.g.,
https://api.mycrm.com/v1/contacts. You can use expressions here:https://api.mycrm.com/v1/contacts/{{ $json.contact_id }} - Authentication:
- None: For public APIs.
- Generic Credential Type: The most flexible.
- Basic Auth: For username/password.
- Header Auth: For “Bearer Tokens” or API keys. Set
NametoAuthorizationandValuetoBearer YOUR_API_KEY. - OAuth2: For services like Google, Slack, etc. (More complex, use the Google Cloud setup later in this guide).
- Method:
- Body Content Types (for POST/PUT):
- JSON: The modern standard.
{ "name": "{{ $json.customer_name }}", "email": "{{ $json.email }}" } - Form-Encoded: For older web forms.
- JSON: The modern standard.
- Query Parameters:
- Data sent in the URL. e.g.,
https://api.example.com/users?status=active - You can add these in the “Query Parameters” section, and n8n will build the URL for you. (Name:
status, Value:active).
- Data sent in the URL. e.g.,
- Options (Error Handling):
- Retry on Fail: A lifesaver. Automatically retries the request 3 times if the API is temporarily down.

IF Node: Conditional Logic (Two Paths)
- What it does: Routes your workflow down one of two paths (True or False) based on a condition.
- Condition Types:
- String:
{{ $json.status }}->equals->completed - Number:
{{ $json.amount }}->greater than->1000 - Date:
{{ $json.created_at }}->is after->{{ $now.minus({days: 30}) }} - Boolean:
{{ $json.is_active }}->is true
- String:
- Multiple Conditions:
- AND: All conditions must be true.
- OR: Any condition can be true.
- Common Mistakes:
- String vs. Number: Your form might send
{{ $json.amount }}as the string"100". The conditionNumber > 99will fail! - The Fix: Use JavaScript in the expression to convert it:
{{ Number($json.amount) }}->greater than->99.
- String vs. Number: Your form might send
Switch Node: Multiple Routes (Many Paths)
- What it does: An “IF” node on steroids. It routes data to many different output paths based on multiple conditions.
- Two Modes:
- Rules (Visual): Best for most cases.
- Rule 1:
{{ $json.priority }}equalshigh-> Output 1 - Rule 2:
{{ $json.priority }}equalsmedium-> Output 2 - Rule 3:
{{ $json.priority }}equalslow-> Output 3 - Default: (All other items) -> Output 4
- Rule 1:
- Expression: For advanced logic. You write a JavaScript expression that returns the output index (0, 1, 2, etc.).
{{ $json.priority === 'high' ? 0 : $json.amount > 1000 ? 1 : $json.category === 'urgent' ? 2 : 3 }}
- Rules (Visual): Best for most cases.
Split Out Node: Array Processing
- What it does: Converts one item with an array into multiple separate items. This is essential for processing order line items or email attachments.
- Example Transformation:
- Input (1 item):
{ "customer": "John", "orders": [ {"id": 1, "total": 100}, {"id": 2, "total": 200} ] } - Configuration:
Field to Split Out:orders - Output (2 items):
[ {"id": 1, "total": 100}, {"id": 2, "total": 200} ]
- Input (1 item):
- Key Setting:Include Other Fields: If you check this (“All Other Fields”), it will keep the parent data with each new item:
- Output (2 items with “All Other Fields”):
[ {"id": 1, "total": 100, "customer": "John"}, {"id": 2, "total": 200, "customer": "John"} ]
- Output (2 items with “All Other Fields”):
Merge Node: Combining Data Streams
- What it does: Combines data from two or more different workflow branches.
- Merge Modes:
- Append: The simplest. Stacks all items from Input 1, then all items from Input 2, into one long list.
- Combine by Position: Merges the 1st item from Input 1 with the 1st item from Input 2, 2nd with 2nd, etc.
- Combine by Matching Fields: The most powerful. This is like a VLOOKUP in Excel or a JOIN in SQL. It merges items from two branches only when a specific field matches.
- Example: Branch 1 has customer data. Branch 2 has order data.
- Input 1:
[{"id": 1, "name": "John"}] - Input 2:
[{"customer_id": 1, "total": 100}] - Match on:
id(from Input 1) andcustomer_id(from Input 2). - Output:
[{"id": 1, "name": "John", "customer_id": 1, "total": 100}]
Wait Node: Pause Workflows
- What it does: Pauses the workflow execution until a condition is met.
- Resume Conditions:
- After Time Interval: Wait for 5 minutes, 2 hours, 1 day, etc. (Perfect for email drip campaigns).
- At Specified Time: Wait until an exact date/time.
- On Webhook Call: This is the “Human-in-the-Loop” pattern. The node pauses, generates a unique webhook URL, and only resumes after an external system (or a human clicking a link) calls that URL. (Perfect for approval processes).
Code Node: Your Custom Logic
- What it does: Lets you write custom JavaScript (or Python) to do anything the other nodes can’t.
- Two Execution Modes:
- Run Once for All Items: Processes the entire dataset at once. The input is an array called
items. - Run Once for Each Item: Processes items individually. The input is one item at a time (and often easier for beginners).
- Run Once for All Items: Processes the entire dataset at once. The input is an array called
- JavaScript Starter Pack (Run Once for All Items):
const items = $input.all();– Gets all incoming items.- Transforming (Mapping):
const processedItems = items.map(item => { return { ...item.json, processed_at: new Date().toISOString(), full_name: item.json.first + ' ' + item.json.last }; }); return processedItems; - Filtering:
const filteredItems = items.filter(item => { return item.json.amount > 100; }); return filteredItems; - Pro Tip: Use ChatGPT or Claude! Paste your input JSON and write a prompt: “Write n8n Code node JavaScript to take this data, filter out any user where
is_activeis false, and add a new field calledfull_name.” It will generate the exact code you need.
Execute Sub-workflow Node: Workflow Modularity
- What it does: Calls another workflow (a “sub-workflow”) and waits for it to finish, then gets the data back.
- Why it’s a “Pro” move:
- Reusability: Create one “Customer Validation” workflow and call it from 10 different parent workflows.
- Organization: Break a massive, 100-node workflow into 5 logical, manageable pieces.
- Maintenance: Update the logic in your one sub-workflow, and all 10 parent workflows are instantly updated.
Google Integration Nodes (The “Must-Haves”)
(Note: These all require the Google Cloud setup detailed in Chapter 7)
Google Sheets Node
- What it does: The ultimate spreadsheet automation.
- Key Operations:
- Append Row: Adds new data to the end of a sheet.
- Update Row: Modifies an existing row (requires a “lookup” column, like an
idoremail). - Get Row(s): Retrieves data from the sheet to use in your workflow.
- Append or Update: A “smart” operation that will try to update a row if it finds a match, or append it as a new row if it doesn’t.
- Configuration Example (Append Row):
- Spreadsheet: Select your sheet.
- Worksheet: Select the tab.
- Columns: This is a mapping.
Customer Name(Column Header):{{ $json.name }}Email(Column Header):{{ $json.email }}Order Total(Column Header):{{ $json.total }}
Gmail Node
- What it does: Automates your inbox.
- Key Operations:
- Send Email: Send an email (with HTML, dynamic data, and attachments from other nodes).
- Get Messages: Search your inbox using Gmail’s search syntax (
from:user@example.com subject:urgent has:attachment) and process the results. - Get Attachments: Downloads attachments from emails for processing.
- Add/Remove Labels: Organize your inbox automatically.
Google Drive Node
- What it does: Manages your cloud files.
- Key Operations:
- Upload: Take a file from a previous node (e.g., a generated PDF) and upload it to a specific folder.
- Download: Get a file from Drive to attach to an email or process.
- Search: Find files based on name, type, or folder.
- Share: Automatically change file permissions.
Communication Nodes
Slack Node
- What it does: Integrates directly with your team’s workspace.
- Key Operations:
- Send Message: Post a message to a channel or a specific user. Use Slack’s
mrkdwnformatting and dynamic data:🚨 New High-Priority Ticket! 🚨 *Customer:* {{ $json.customer_name }} *Issue:* {{ $json.description }} *Assigned to:* @{{ $json.assigned_user }} - Send and Wait for Approval: A game-changer. This sends a message with “Approve” and “Reject” buttons. The workflow pauses until a human clicks one, and the click data (who clicked, what they clicked) is sent to the next node. This is the easiest way to build a “Human-in-the-Loop” approval flow.
- Send Message: Post a message to a channel or a specific user. Use Slack’s

5. The AI Revolution: Setting Up AI Models & Agents
This is where n8n goes from an automation tool to an “autonomous” one. n8n’s AI nodes allow you to integrate Large Language Models (LLMs) and build “Agents” that can reason and use your other nodes as tools.
Regular AI vs. AI Agents
- Regular AI (e.g., “OpenAI” node): You give it a prompt, it gives you text. “Generate a blog post about cats.”
- AI Agent (e.g., “AI Agent” node): You give it a goal, and it uses tools to achieve it. “Research the top 5 cat breeds, find a statistic for each, write a blog post, and publish it to WordPress.”
The AI Agent can reason and decide, “To do this, I first need to use the Wikipedia Tool. Then, I need to use the HTTP Request Tool to find statistics. Finally, I will use the WordPress Tool to publish.”
Setting Up Your First AI Agent
Add the “AI Agent” node to your workflow. It has three critical inputs:
- Chat Model (The “Brain”): This is the LLM. You can connect:
- OpenAI Chat Model: For GPT-4o, GPT-4, etc. (Requires an API key from
platform.openai.com). - Anthropic Claude: For Claude 3.5 Sonnet, Opus, etc. (Requires an API key from
console.anthropic.com). - Google Gemini: For Gemini Pro and Flash.
- OpenAI Chat Model: For GPT-4o, GPT-4, etc. (Requires an API key from
- Tools (The “Hands”): This is what the agent can do. You can connect:
- Built-in Tools: “Wikipedia,” “Calculator.”
- ANY n8n NODE: This is the magic. Connect a “Google Sheets” node to the “Tools” input, and the agent can now “search the spreadsheet.” Connect a “Slack” node, and the agent can “send a Slack message.”
- Memory (The “History”): This allows the agent to remember the conversation.
- Simple Memory: Stores conversation history in n8n’s memory. Easy to set up, but is lost when the workflow restarts.
- PostgreSQL Memory / Redis Memory: Stores the conversation in an external database. This provides persistent, long-term memory for your agent.
The Magic: n8n Nodes as AI Tools
This is the most important AI concept. How do you make an n8n node a “tool”?
- Add a “Google Sheets” node and set its operation to “Get Row(s).”
- In the “Search Value” field, instead of typing a value, you use a special expression:
{{ $fromAI('customer_email') }}. - In the node’s settings (not the parameter), give it a “Tool Description”: “Use this tool to get customer information, like their order history and status, by searching for their email.”
- Connect this “Google Sheets” node to the “Tools” input of your AI Agent.
Now, when you chat with your agent:
- You: “What was the last order for
jane@example.com?” - AI Agent (Reasoning): “The user wants order info. I have a tool called ‘get customer information’ that can find this. The tool needs a
customer_email. The user providedjane@example.com.” - AI Agent (Action): The agent automatically runs your Google Sheets node and puts
jane@example.cominto the “Search Value” field (because you used$fromAI('customer_email')). - AI Agent (Response): The Sheets node returns the data to the agent. The agent then formulates a natural language response: “Jane’s last order was for a ‘Premium Widget’ on October 24th.”

System Prompt Engineering for Agents
The “System Prompt” in your AI Agent node defines its personality and rules.
Bad Prompt: “You are a helpful assistant.”
Good Prompt:
You are a professional customer service agent for TechCorp.
Your capabilities:
- You can look up customer orders and account status using the 'GetCustomer' tool.
- You can process refunds up to $50. For amounts over $50, you MUST ask for human approval.
- You can send follow-up emails using the 'SendEmail' tool.
Your personality:
- Friendly, professional, and solution-focused.
- Always be patient and empathetic.
Your Rules:
1. Always greet the customer by name if you can find it.
2. Before processing a refund, ALWAYS confirm the order number and amount.
3. NEVER share information about other customers.
This level of detail turns your agent from a toy into a reliable, autonomous employee.
6. The “Right Way”: Google Cloud Integration Setup
To use any Google node (Sheets, Gmail, Drive, Calendar), you must have Google OAuth credentials. The “quick setup” in n8n is fine for personal testing, but for a business, you need a full Google Cloud Project for higher API limits and professional control.
Here is the full, step-by-step walkthrough.
Step 1: Create a Google Cloud Project
- Go to
console.cloud.google.com. - Click the project dropdown at the top and click “NEW PROJECT”.
- Name it “n8n-automation” (or your company name) and click “CREATE”.
- Make sure your new project is selected.

Step 2: Enable the Required APIs
- In the left sidebar, go to “APIs & Services” -> “Library”.
- Search for and ENABLE these APIs one by one (you must do this for each one you want to use):
Google Drive APIGmail APIGoogle Sheets APIGoogle Calendar API
- Click on the API, then click the blue “ENABLE” button.

Step 3: Configure the OAuth Consent Screen This is the screen your users (or just you) will see when authorizing n8n.
- Go to “APIs & Services” -> “OAuth consent screen”.
- Choose “External” and click “CREATE”.
- Fill out the required fields:
- App name: “n8n Automation”
- User support email: Your email.
- Developer contact email: Your email.
- Click “SAVE AND CONTINUE”.
- On the “Scopes” page, just click “SAVE AND CONTINUE” (n8n will handle this).
- On the “Test users” page, click “ADD USERS” and add the email address of the Google account you want to automate. This is critical, or Google will block the login.
- Click “SAVE AND CONTINUE” and “BACK TO DASHBOARD”.

Step 4: Create Your OAuth Credentials This is the “username and password” for n8n.
- Go to “APIs & Services” -> “Credentials”.
- Click “+ CREATE CREDENTIALS” -> “OAuth 2.0 Client ID”.
- Application type: “Web application”.
- Name: “n8n Integration”.
- Authorized redirect URIs: This is the most important step.
- Click “+ ADD URI”.
- If you use n8n Cloud, enter:
https://your-instance.app.n8n.cloud/rest/oauth2-credential/callback - If you are self-hosted, enter:
https://n8n.yourcompany.com/rest/oauth2-credential/callback - (Replace the domain with your actual n8n URL).
- Click “CREATE”.

Step 5: Copy Your Keys and Add to n8n
- A box will pop up with your Client ID and Client Secret. Copy these immediately.
- In your n8n workflow, add a “Google Sheets” node.
- In the “Credential” field, click “Create New Credential”.
- Select “Google OAuth2 API”.
- Paste your Client ID and Client Secret into the fields.
- Click “Sign in with Google”.
- A new window will open. Log in with the “test user” email you added in Step 3.
- Click “Continue” on the permissions screen.
- You’ll be redirected back to n8n. Save your credential.
You are now fully and professionally authenticated. You can re-use this single credential for all Google nodes.
7. The Ultimate Troubleshooting Guide
Workflows break. Data formats change. APIs go down. Here is how to fix your issues in minutes, not hours.
The AI Debug Method (Your First Step, Always)
This is the single fastest way to solve 90% of your problems. When a node fails:
- Click on the failed node. You will see an “Error” tab and an “Input” tab.
- Copy the Error Message (e.g.,
ERROR: Cannot read property 'email' of undefined). - Go to the “Input” tab and copy the JSON data that was fed into the node.
- Paste both into ChatGPT or Claude with this prompt:
“I’m having an issue with my n8n workflow. Here’s the error message and the JSON data from the input of the failed node. Can you tell me what’s wrong and how to fix it?”
ERROR MESSAGE:
[paste error here]INPUT JSON DATA:
[paste JSON here]
Why this works: The AI can instantly see that your error “Cannot read ’email'” is because your input JSON has {"user_email": "..."} instead of {"email": "..."}. It will tell you, “Your expression {{ $json.email }} is wrong. You should be using {{ $json.user_email }}.” This solves the problem instantly.
Common HTTP Error Code Glossary
When the “HTTP Request” node fails, look at the code:
400 Bad Request: Your fault. The data you sent was wrong. Check your JSON body, query parameters, or URL.401 Unauthorized: Your fault. Your “Authentication” is wrong. Your API key is invalid, expired, or you forgot theBearerprefix.403 Forbidden: Your fault. You are authenticated (your key is right), but you don’t have permission to access this specific resource.404 Not Found: Your fault. The URL or API endpoint is wrong.429 Rate Limited: The API’s fault (sort of). You’re sending too many requests too quickly. Fix this by adding a “Wait” node in a loop or using the “Retry on Fail” option in the HTTP node.500 Internal Server Error: Their fault. The server you are calling is broken. Use “Retry on Fail” to handle this automatically.
Common n8n Expression Errors
- Error:
Cannot read property 'name' of undefined- Meaning: You’re trying to access
{{ $json.name }}, but thenamekey doesn’t exist in the current JSON item. Or, even worse, the entire$jsonobject is empty because the previous node returned nothing. - Fix: Use a “safe” expression with a fallback:
{{ $json.name || 'default_value' }}. Or, better, use an “IF” node first to check{{ $json.name }}->is not empty.
- Meaning: You’re trying to access
- Error:
[Object: Object]showing up in your text fields- Meaning: You are trying to display an entire JSON object as text.
- Fix: You need to pick a specific key from that object. Instead of
{{ $json.user }}, you need{{ $json.user.name }}. If you do want to see the whole object for debugging, use{{ JSON.stringify($json) }}.
8. 7 Powerful Workflow Patterns to Build Now
Here are 7 proven, high-value workflow patterns you can build using the nodes we’ve discussed.
1. The “Smart” Contact Form
- Goal: Qualify, route, and store new leads from your website.
- Nodes:
Webhook Trigger->AI Agent->SwitchWebhookreceives the form data.AI Agent(with a prompt to “categorize this lead as ‘Sales’, ‘Support’, or ‘Spam'”) analyzes the message.Switchroutes the lead based on the AI’s output:- Path 1 (Sales): ->
Slack(notify #sales channel) ->Salesforce(create new lead). - Path 2 (Support): ->
Zendesk(create new ticket). - Path 3 (Spam): ->
No-op(do nothing).
- Path 1 (Sales): ->
2. The Daily Digest Report
- Goal: Get a summary of all your key metrics in one place, every morning.
- Nodes:
Schedule Trigger->Google Sheets(Get) ->AI Agent->EmailScheduleruns at 8:00 AM.Google Sheets(Get Rows) pulls all “new sales” and “new signups” from the day before.AI Agent(with prompt “Summarize this data into 3 bullet points”) creates a clean summary.Emailsends the summary to your inbox.
3. The Human-in-the-Loop Approval
- Goal: Require manager approval before a high-value action is taken.
- Nodes:
n8n Form Trigger->Slack(Send and Wait) ->IFForm Triggeris used by an employee to “Request a >$500 refund.”Slack(Send and Wait for Approval) sends the details to a manager with “Approve” / “Reject” buttons. The workflow pauses.- Manager clicks “Approve.” The workflow resumes.
IFnode checks the Slack output:{{ $json.action }}equalsapprove.- True Path: ->
Stripe(process refund) ->Slack(notify employee). - False Path: ->
Slack(notify employee of rejection).
- True Path: ->
4. The AI Content Factory
- Goal: Autonomously generate and publish blog post drafts.
- Nodes:
Google Sheets Trigger->AI Agent->WordPressSheets Trigger(On New Row) watches a sheet of “Blog Ideas.”AI Agent(with prompt “Write a 1000-word blog post on this topic” and connected toWikipediaorHTTP Requesttools for research) generates the article.WordPressnode uploads the AI-generated text as a new “Draft” post, ready for a human to review and publish.
5. The “VLOOKUP” Data Syncer
- Goal: Keep two systems (e.g., your CRM and your billing system) in sync.
- Nodes:
Salesforce(Get Updated Contacts) ->HTTP Request(Get Stripe Data) ->Merge->Stripe(Update)Salesforcegets all contacts updated in the last hour.HTTP Requestgets all customers from Stripe.Merge(Combine by Matching Fields) merges the two lists on the email field.- This gives you a combined list. You can then use an
IFnode to find discrepancies and aStripenode to update records.
6. The Bulletproof Workflow (Error Handling)
- Goal: A workflow that notifies you when it fails.
- Nodes: (This is two workflows)
- Workflow 1 (Main):
Schedule->HTTP Request->Google Sheets. In Settings, set “Error Workflow” to “WF-2”. - Workflow 2 (Error Handler):
Error Trigger->Slack->Google Sheets(Log) - Result: If the
HTTP Requestin WF-1 fails, WF-2 is immediately triggered. TheError Triggergets all the error data. TheSlacknode DMs you: “WF-1 FAILED! Error: 500 Server Error.” TheGoogle Sheetsnode logs the error to a spreadsheet.
- Workflow 1 (Main):
7. The Thumbnail Generator (from the source doc)
- Goal: A perfect example of a multi-step creative process.
- Nodes:
n8n Form Trigger->AI Agent->HTTP Request(Image Gen) ->EmailFormtakes a “Blog Post Title.”AI Agentgenerates 3 “short, visual prompts for a thumbnail.”HTTP Request(to an image generation API) creates the images.Emailsends the 3 image options back to the user.
9. Your Next Steps: Crawl, Walk, Run
You’ve just consumed a massive amount of information. The n8n universe is vast, but the barrier to entry is low. You don’t need to be a developer. You just need to be curious and willing to connect the blocks.
Here is your plan. Do not try to build an AI agent today. Start simple.
1. Crawl (Your First Hour)
- Your goal is to build one simple, two-node workflow.
- The Workflow:
n8n Form Trigger->Send Email. - Create a form with “Name” and “Email” fields.
- Connect an “Email” node.
- In the “Message” body, use the Expression Editor:
Hello, {{ $json.Name }}! Welcome. - Activate your workflow, open the form, and submit it.
- When you get that email, you’ll feel the magic. You’ve just built an automation.
2. Walk (Your First Day)
- Your goal is to build a three-node workflow with logic.
- The Workflow:
Schedule Trigger->HTTP Request->IF->Slack Scheduleto run every hour.HTTP Requestto call a public API (e.g., a weather API).IFnode to check the data:{{ $json.temperature }}greater than25.- True Path: ->
Slack(send “It’s hot today! ☀️”) - False Path: ->
No-op(do nothing).
3. Run (Your First Week)
- Your goal is to build your first “dream” automation.
- Pick a manual task you hate doing.
- Does it involve a spreadsheet? Use the
Google Sheetsnode. - Does it involve an API? Use the
HTTP Requestnode. - Does it need to run every day? Use the
Schedule Trigger. - Does it need to be smart? Connect an
AI Agentnode. - Stuck? Use the AI Debug Method from Chapter 7.
n8n becomes truly powerful once you internalize these building blocks. The combination of a visual canvas, a “run-for-each-item” data flow, powerful data transformation, and game-changing AI integration makes it possible to automate almost any business process you can think of.
You have the knowledge. You have the guide.
Now go build something amazing.








