Runoob Tutorial ArchiveEnglish

n8n Getting Started Tutorial

n8n Getting Started Tutorial

n8n (pronounced "n-eight-n", meaning "nodemation") is currently the most favored open-source workflow automation platform among technical teams.

The core advantages of n8n are: visual canvas + native code support + complete self-hosting—it allows non-developers to build workflows by dragging and dropping, and allows developers to write JavaScript or Python in any node, and it can run on your own server with data kept locally.

n8n is a workflow automation platform that allows you to integrate AI safely and controllably into your work and processes.

n8n combines a visual building experience with coding capabilities—you can write JavaScript or Python anywhere in the workflow and instantly view the results next to the input and output of each step.

runoob 178 719 46 71

Differences between Dify and n8n

Unlike Dify, n8n's core is general automation and system integration, with AI being one powerful component, whereas Dify's core is AI application development, with automation being a supporting capability.

Simply put:

Who is it suitable for

n8n's visual interface allows non-developers to quickly design and test workflows, and as complexity increases, developers can extend it using Function nodes, external scripts, or custom integrations.

This allows teams to incrementally layer structure, validation, and control.

Most typical user group:

User group Typical scenarios
Operations team Automated CRM updates, report generation, email sending
Developer API integration, data pipelines, internal tool automation
Data engineer ETL pipelines, data cleaning, scheduled synchronization
IT team Monitoring and alerting, incident response, user management
Tech startup company Backend automation layer for rapidly building an MVP

Core concepts

Before starting to learn, let's first understand these core concepts.

Workflow

A workflow is a directed graph of nodes that defines the logic of "when X happens, execute Y, then execute Z."

Workflows have two states: Active, which runs automatically upon triggering, and Inactive, which can only be executed manually for testing.

Node

The basic building block of a workflow, each node executes a specific operation:

Node types Color Description
Trigger node Orange The starting point of a workflow, defining when to trigger
Regular nodes Blue Processing data, calling APIs, executing logic
AI-related nodes Purple LLM calls, vector storage, Agent

Execution

A complete run of a workflow is called an execution.

n8n's execution billing method is: one execution = one run of the workflow, regardless of how many steps it has or how much data it processes.

Connection

Arrows between nodes define the data flow direction and execution order. A node can have multiple outputs to implement branching logic.

Credential

A secure container for storing sensitive information such as API Keys, OAuth Tokens, and database passwords.

Credentials are encrypted and stored, and can be shared by multiple workflows without being exposed in plain text in the workflow JSON.

Expression

n8n's dynamic value syntax, wrapped in double curly braces: {{ $json.fieldName }}.

Allows node parameters to reference the output of upstream nodes instead of fixed values.


Installation and Startup

Five installation methods, ranging from quick local experience to enterprise-grade high availability deployment.

Method One: Quick Local Experience (Fastest, 5 minutes)

Use npx or global installation, no extra configuration required.

Original prompt (Chinese, left untranslated)



# Use npx, no installation required (requires Node.js 18+)

npx n8n



# or global install

npm install -g n8n

n8n start

Open a browser and access http://localhost:5678; use after completing account registration.

runoob 178 7195 65

If you forget your email password, usenpx n8n user-management:resetcommand to reset it.


Method two: Docker single container (recommended for individuals and small teams)

Starts with one command, data is persisted to a local directory.

Original prompt (Chinese, left untranslated)



# Create data persistence directory

mkdir -p ~/.n8n



# Start n8n container

docker run -d \

  --name n8n \

  -p 5678:5678 \

  -v ~/.n8n:/home/node/.n8n \

  -e N8N_ENCRYPTION_KEY="your-random-32-char-secret-key" \

  docker.n8n.io/n8nio/n8n:latest

Access http://localhost:5678 to complete the setup.


Method three: Docker Compose + PostgreSQL (recommended for production environments)

Suitable for production environments, data is stored in PostgreSQL, supporting more stable concurrent access.

Create docker-compose.yml:

Original prompt (Chinese, left untranslated)



version: "3.8"



services:

  postgres:

    image: postgres:16-alpine

    restart: always

    environment:

      POSTGRES_DB: n8n

      POSTGRES_USER: n8n

      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}

    volumes:

      - postgres_data:/var/lib/postgresql/data

    healthcheck:

      test: ["CMD-SHELL", "pg_isready -U n8n"]

      interval: 10s

      timeout: 5s

      retries: 5



  n8n:

    image: docker.n8n.io/n8nio/n8n:latest

    restart: always

    ports:

      - "5678:5678"

    environment:

      # Database connection configuration

      DB_TYPE: postgresdb

      DB_POSTGRESDB_HOST: postgres

      DB_POSTGRESDB_DATABASE: n8n

      DB_POSTGRESDB_USER: n8n

      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}

      # Security configuration

      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}

      N8N_SECURE_COOKIE: "false"          # 如果没有 HTTPS,设为 false

      # Access URL (replace with your actual domain)

      WEBHOOK_URL: https://your-domain.com

      N8N_EDITOR_BASE_URL: https://your-domain.com

      # Timezone setting

      GENERIC_TIMEZONE: Asia/Shanghai

      TZ: Asia/Shanghai

    volumes:

      - n8n_data:/home/node/.n8n

    depends_on:

      postgres:

        condition: service_healthy



volumes:

  postgres_data:

  n8n_data:

Create .env file:



POSTGRES_PASSWORD=your-strong-postgres-password

N8N_ENCRYPTION_KEY=your-32-char-random-encryption-key

Generate a secure encryption key:

Original prompt (Chinese, left untranslated)



# Generate a 24-byte base64 random key

openssl rand -base64 24

Start the service:

Original prompt (Chinese, left untranslated)



# Start all services in the background

docker compose up -d



# View logs, wait for startup to complete

docker compose logs -f n8n


Method Four: Configure reverse proxy (Nginx + HTTPS)

For production deployment, configure Nginx to facilitate domain binding and HTTPS.

Original prompt (Chinese, left untranslated)



server {

    listen 80;

    server_name n8n.yourdomain.com;

    return 301 https://$host$request_uri;

}



server {

    listen 443 ssl;

    server_name n8n.yourdomain.com;



    # SSL certificate path (using Let's Encrypt automatic issuance)

    ssl_certificate     /etc/letsencrypt/live/n8n.yourdomain.com/fullchain.pem;

    ssl_certificate_key /etc/letsencrypt/live/n8n.yourdomain.com/privkey.pem;



    # n8n WebSocket Support

    location / {

        proxy_pass http://localhost:5678;

        proxy_http_version 1.1;

        proxy_set_header Upgrade $http_upgrade;

        proxy_set_header Connection "upgrade";

        proxy_set_header Host $host;

        proxy_set_header X-Real-IP $remote_addr;

        proxy_read_timeout 300s;

        proxy_send_timeout 300s;

    }



    # MCP SSE Endpoint Specific Configuration

    location ~* ^/mcp {

        proxy_pass http://localhost:5678;

        proxy_buffering off;

        gzip off;

        chunked_transfer_encoding off;

        proxy_set_header Connection "";

    }

}

Apply for SSL certificate (Let's Encrypt):

Original prompt (Chinese, left untranslated)



# Automatically configure Nginx and apply SSL certificate

certbot --nginx -d n8n.yourdomain.com


Method Five: Kubernetes (High availability, enterprise-grade)

For teams requiring high availability, use the official Helm Chart.

Original prompt (Chinese, left untranslated)



# Add n8n Helm repository

helm repo add n8n https://n8n-helm-chart.netlify.app



# Install n8n, enable PostgreSQL and Redis

helm install n8n n8n/n8n \

  --set n8n.encryption_key="your-key" \

  --set postgresql.enabled=true \

  --set redis.enabled=true   # Queue mode requires Redis

High availability architecture requires configuring "Queue Mode," using Redis as the message queue, allowing multiple Worker nodes to process tasks in parallel.


System Requirements

Hardware Recommendations for Different Use Cases:

Scenario CPU Memory Disk
Development and testing 1 core 1 GB 10 GB
Small team production 2 cores 4 GB 20 GB
Medium load 4 cores 8 GB 50 GB

Database recommendation: n8n defaults to SQLite, but PostgreSQL is strongly recommended for production environments. PostgreSQL offers better performance, supports concurrent access, and is easier to back up.


Interface tour: First time opening n8n

Understand the main interface areas of n8n to get started quickly.

runoob1 178 7199 9699

Left navigation bar

Icons/Regions Functions
Workflow List View, Search, Create Workflows
Execution History View run records of all workflows
Credentials Manage sensitive information such as API Key and OAuth
Variables Global Variables (Team/Business Features)
Settings Instance Configuration, User Management

We can configure APIs, such as DeepSeek. Click the New Chat menu, click the model in the top left corner, and select DeepSeek from the dropdown list:

runoob 178 7199 9699

Then configure the API key:

runoob3 178 7199 9699

After successful configuration, click the model in the top left corner and select the DeepSeek model from the dropdown list:

runoob4 178 7199 9699

You can start chatting:

runoob5 178 7199 9699

Workflow Canvas

Canvas Operation Shortcuts:

Operation Shortcut/Method
Add Node Click the + button to add between two nodes
Search Node Ctrl+K for quick search and add
Pan canvas Drag empty area
Zoom canvas Mouse wheel
Select all nodes Ctrl+A
Delete node Delete selected node with Delete key

Node Panel

Click any node to open the configuration panel, which is divided into three tabs:

Tabs Function
Parameters Main node configuration
Settings Execution control (retry, timeout, error handling)
Notes Add description text to the node

Top toolbar

Button Function
Execute Workflow Manually trigger one execution
Save Save current edit
Active switch Activate/deactivate workflow

Build the first workflow

Get started with a complete example: automatically fetch Hacker News top stories every morning at 8 AM, format them, and send them to a Slack channel.

Step 1: Create a workflow

Select Workflows on the left, click New Workflow, and rename it to "HN Morning Report".

Step 2: Add a scheduled trigger

Click the + button, search for "Schedule", and select Schedule Trigger.

Configuration instructions:

Original prompt (Chinese, left untranslated)



Trigger Rule:0 8 * * 1-5(周一到周五早上 8 点)

或使用界面选择器:Hour → 8,Weekday → Mon to Fri

Step three: Fetch HN data

Click + to the right of Schedule Trigger, search for "HTTP Request", and add a node.

Configuration:



Method:GET

URL:https://hacker-news.firebaseio.com/v0/topstories.json

This will return an array of IDs for currently trending articles (up to 500).

Step four: Limit to the first 5

Add a Code node and write JavaScript:

Instance

// Get the first 5 story IDs and return them as independent JSON objects

const

topIds

=

$input.

first

(

)

.

json

.

slice

(

0

,

5

)

;

return

topIds.

map

(

id

=>

(

{

json

:

{

id

}

}

)

)

;

Step five: Parallelly fetch details for each article

Add an HTTP Request node.

n8n will automatically execute in parallel for every piece of data from the upstream, without needing to write a manual loop.

Configuration:



URL:https://hacker-news.firebaseio.com/v0/item/{{ $json.id }}.json

Step six: Format the message

Add Code node:

Instance

const

items

=

$input.

all

(

)

;

// Iterate over all articles and format them into Slack message format

const

formatted

=

items.

map

(

item

=>

{

 

const

{

title

,

url

,

score

,

by

}

=

item.

json

;

 

return

`•

$

{

title

}

Score

:

$

{

score

}

|

Author

:

$

{

by

}

$

{

url

||

'(No link)'

}

`

;

}

)

.

join

(

'\n\n'

)

;

// Return the assembled message

return

[

{

json

:

{

message

:

`

Hacker News Trending Today

\n\n$

{

formatted

}

`

}

}

]

;

Step seven: Send to Slack

Add the Slack node (first complete the Slack credential configuration, see the Credential Management chapter).

Configuration:

Original prompt (Chinese, left untranslated)



Resource:Message

Operation:Send

Channel:#general(或你的目标频道)

Message:{{ $json.message }}

Step eight: Test run

Click the Execute Workflow button at the top to observe the numbers next to each node (representing the number of data items processed).

Clicking any node allows you to view its input and output data.

Step Nine: Activate Workflow

After the test passes, click the Active switch in the upper right corner, and the workflow will enter an active state, executing automatically at 8 AM every business day.


Detailed Explanation of Common Nodes

Master the most commonly used node types, covering three categories: triggers, data processing, and databases.

Trigger Nodes

A trigger is the starting point of a workflow, defining when execution begins.

Node Triggering method Typical scenarios
Schedule Trigger Scheduled (cron expression) Daily reports, scheduled synchronization
Webhook HTTP request trigger Receive Stripe/GitHub events
Chat Trigger AI conversation messages Drive AI Agent workflows
Email Trigger (IMAP) New email arrives Process email requests
Slack Trigger Slack Events Respond to Slash Commands

Data Processing Node

HTTP Request (The most core node)

Can call almost any REST API:

Original prompt (Chinese, left untranslated)



Method: POST

URL: https://api.example.com/endpoint

Authentication: Header Auth(配合凭证使用)

Body Content Type: JSON

Body: {

  "key": "{{ $json.value }}"

}

Supports automatic pagination, allowing you to retrieve all data without writing loop logic.

Code (JavaScript / Python)

JavaScript Example:

Instance

// Process all items from upstream

for

(

const

item of $input.

all

(

)

)

{

 

// Add processing timestamp to each data item

item.

json

.

processedAt

=

new

Date

(

)

.

toISOString

(

)

;

}

return

$input.

all

(

)

;

Python example:

Instance

Python also supports it, use _input to access upstream data

for

item

in

_input.

all

(

)

:

    item.

json

[

"processed"

]

=

True

return

_input.

all

(

)

Set (Set Variable)

Visually set, modify, or delete fields without writing code.

Original prompt (Chinese, left untranslated)



字段名: fullName

值: {{ $json.firstName + " " + $json.lastName }}

IF (Conditional Branch)

Routes data to different branches based on conditions:

Original prompt (Chinese, left untranslated)



条件: {{ $json.status }} == "active"

True 分支 → 处理活跃用户

False 分支 → 处理非活跃用户

Switch (Multi-way Branch)

Similar to IF, but supports multiple conditions (similar to switch-case), distributing data to different processing paths.

Loop Over Items (Loop)

Processes each element in the array sequentially, suitable for scenarios that require rate control rather than parallel processing.

Merge

Merges data from multiple branches, supporting strategies such as Append, Keep Key Matches, and Combine By Position.

Wait (Human-in-the-Loop)

Pauses workflow execution and resumes only after the following conditions are met:

Respond to Webhook

In a workflow that receives a Webhook, synchronously return a response to the requester.

Database node

Node Supported operations
PostgreSQL Select / Insert / Update / Delete / Execute Query
MySQL Select / Insert / Update / Delete / Execute Query
MongoDB Find / Insert / Update / Delete / Aggregate
Redis Get / Set / Delete / Incr / Expire
Supabase Via REST or PostgreSQL node

Credential management: Securely connect to external services

Credentials are a unified mechanism in n8n for managing all authentication information, and all credentials are encrypted and stored in the database using N8N_ENCRYPTION_KEY.

Teams can share credentials without seeing the actual key content.

Add Credential

Two ways to add credentials:

  1. Select Credentials in the left navigation and click Add Credential.
  2. In the node configuration, click the credential dropdown and select Create new credential.

Common Credential Configurations

Slack (OAuth)

  1. Visit api.slack.com/apps to create an App
  2. Enable Bot Token Scopes (chat:write, channels:read)
  3. Install the App to the workspace and copy the Bot Token (starting with xoxb-)
  4. Select Slack in n8n and paste the Bot Token

GitHub (Personal Access Token)

  1. In GitHub, select Settings, go to Developer settings, select Personal access tokens, and click Generate new token
  2. Select the required permissions (repo, issues, etc.)
  3. Copy the Token and add GitHub credentials in n8n

OpenAI / Anthropic (API Key)

  1. Obtain API Key from each provider's console
  2. In n8n, select Credentials, search for "OpenAI" or "Anthropic", and paste the Key

Generic HTTP Header (for any API)

For services without a dedicated node in n8n, use the HTTP Request node with Header Auth credentials:



Header Name: Authorization

Header Value: Bearer your-api-key-here


AI Agent Node: Let the workflow think

The native AI Agent node in n8n allows you to build intelligent, autonomous workflows that use large language models for decision-making, natural language processing, and multi-step reasoning.

Components of the AI Agent Node

The AI Agent node is a "cluster node" composed of three types of sub-nodes:

Original prompt (Chinese, left untranslated)



AI Agent(根节点)

├── Chat Model(必需):驱动 Agent 的 LLM

│   ├── OpenAI Chat Model

│   ├── Anthropic Chat Model

│   └── Google Gemini Chat Model

├── Memory(可选):让 Agent 记住对话历史

│   ├── Simple Memory(会话内记忆)

│   ├── Window Buffer Memory(固定窗口)

│   └── Postgres/Redis Chat Memory(跨会话持久化)

└── Tools(可选):Agent 可以调用的工具

    ├── 内置工具(Calculator、SerpAPI、Wikipedia)

    ├── HTTP Request Tool(调用任意 API)

    ├── n8n Workflow Tool(调用另一个工作流)

    └── MCP Client Tool(调用 MCP 服务器)

Configure AI Agent

Step 1: Add an AI Agent node.

Search for AI Agent on the workflow canvas and select Tools Agent (the most general Agent type).

Step 2: Add Chat Model.

Click the Chat Model slot at the bottom of the AI Agent node and add the Anthropic Chat Model.

Configuration:

Original prompt (Chinese, left untranslated)



Model:claude-sonnet-4-6

凭证:选择已配置的 Anthropic 凭证

Step 3: Configure System Prompt.

Original prompt (Chinese, left untranslated)



你是一个数据分析助手,帮助用户分析 {{ $json.company_name }} 公司的销售数据。



Available tools:

- 查询数据库获取历史销售数据

- 搜索互联网获取市场信息

- 计算器用于数学运算



回答要简洁、数据驱动。如果数据不足,明确说明需要哪些额外信息。

Step 4: Add tools.

Click Add Tool to add the required tool nodes.

Each tool requires configuration of a tool name (the Agent uses this name to decide when to call) and a tool description (tells the Agent what this tool can do).

Agent Type Selection

Agent Type Suitable Scenarios
Tools Agent (Recommended) General-purpose, supports Function Calling, best choice for modern LLMs
ReAct Agent Reasoning + Acting, suitable for tasks requiring multi-step reasoning
Plan and Execute Agent First formulate a complete plan, then execute step by step
Conversational Agent Conversational, with built-in memory, suitable for chatbots
SQL Agent Specifically handles database queries
OpenAI Functions Agent OpenAI Exclusive Function Calling

MCP Integration: Connecting the AI Ecosystem

n8n has a dual role in the MCP (Model Context Protocol) ecosystem: it can consume MCP services (as an MCP client) or expose workflows as MCP services (as an MCP server).

n8n as an MCP Client (Calling External Tools)

Use the MCP Client Tool node to connect to any MCP server.

The MCP Client Tool node supports Bearer, Generic Header, Multiple Headers, and OAuth2 authentication methods.

Configuration Example: Connecting to a GitHub MCP Server

Original prompt (Chinese, left untranslated)



节点类型:MCP Client Tool

SSE Endpoint: https://mcp.github.com/sse    # 或自托管的 MCP 服务器地址

Authentication: Bearer

Bearer Token: your-github-token

Tools to Include: All(暴露所有工具给 Agent)

Connect the MCP Client Tool node to the Tools slot of an AI Agent, and the Agent can directly call GitHub's MCP tools (list Issues, create PRs, view code, etc.).

n8n as an MCP server (exposing workflows)

Using the MCP Server Trigger node allows n8n to act as an MCP server, exposing n8n tools and workflows to MCP clients.

It operates by exposing a URL, which MCP clients can interact with to access n8n tools.

Setup steps:

  1. Create a new workflow and add the MCP Server Trigger node
  2. The node will automatically generate a test URL and a production URL (format: https://your-n8n.com/mcp/xxxxxxxx)
  3. Connect the tool node you want to expose next to the MCP Server Trigger

Original prompt (Chinese, left untranslated)



MCP Server Trigger

├── Google Calendar Tool(查看/创建日程)

├── Gmail Tool(读取/发送邮件)

├── Slack Tool(发送消息)

└── Custom n8n Workflow Tool(调用其他工作流)

  1. Publish the workflow (click Publish)

In Claude Desktop:

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

Instance

{

 

"mcpServers"

:

{

   

"n8n"

:

{

     

"command"

:

"npx"

,

     

"args"

:

[

       

"-y"

,

       

"mcp-remote@latest"

,

       

"https://your-n8n.com/mcp/your-mcp-path"

,

       

"--header"

,

       

"Authorization:Bearer your-bearer-token"

     

]

   

}

 

}

}

Instance-level MCP server

In April 2026, n8n released the instance-level MCP server.

It allows AI clients (such as Claude Desktop, Cursor, etc.) to directly create, validate, test, and publish entire workflows using natural language—it is a development tool, not a runtime tool.

How to enable (self-hosted):



N8N_MCP_ACCESS_ENABLED=true

After enabling, your Claude Desktop or other MCP client can directly tell n8n: "Create a workflow to send the GitHub PR list to Slack every morning," and n8n will automatically build this workflow.


Practical Scenario One: Automatic GitHub Issue Classification and Notification

Use AI Agent to automatically classify GitHub Issues and route them to different handlers and channels based on type.

Business Scenarios

Open-source projects receive a large number of issues daily, requiring automatic classification (Bug / Feature Request / Question / Docs) and notification to the relevant person in charge.

Workflow Design

Original prompt (Chinese, left untranslated)



Webhook(接收 GitHub Issue 事件)

  ↓

IF 节点(过滤:只处理新建的 Issue)

  ↓

AI Agent 节点(分析 Issue 内容,给出分类和优先级)

  ↓

Switch 节点(根据分类路由)

  ├── Bug → 添加 "bug" 标签 + 通知 @backend-team

  ├── Feature → 添加 "enhancement" 标签 + 通知 @product-team

  ├── Question → 添加 "question" 标签 + 自动生成初步回复

  └── Docs → 添加 "documentation" 标签 + 通知 @docs-team

  ↓

GitHub 节点(添加标签 + 发表评论)

  ↓

Slack 节点(发送通知到对应频道)

Key Node Configuration

Step 1: Configure GitHub Webhook

In the GitHub repository, select Settings, go to Webhooks, and click Add Webhook:

Original prompt (Chinese, left untranslated)



Payload URL:https://your-n8n.com/webhook/github-issues

Content type:application/json

Events:Issues(只选 Issues 事件)

Add a Webhook node in n8n:

Original prompt (Chinese, left untranslated)



HTTP Method:POST

Path:github-issues

(记录下 Test URL,用于调试)

Step 2: Filter new events

Add IF node:

Original prompt (Chinese, left untranslated)



条件:{{ $json.action }} == "opened"

Only events where action === "opened" will be processed; events like labeled or closed will be discarded directly.

Step 3: AI Classification Node

Add AI Agent node and configure System Prompt:

Original prompt (Chinese, left untranslated)



You are a GitHub Issue classification expert. Analyze the following Issue and return the classification result in JSON format:



{

  "category": "bug" | "feature" | "question" | "docs",

  "priority": "P0" | "P1" | "P2" | "P3",

  "reason": "分类理由(一句话)",

  "suggested_reply": "给 Issue 作者的初步回复(仅用于 question 类型)"

}



Classification criteria:

- bug:描述了一个功能不正常工作的情况

- feature:要求新增功能或改进现有功能

- question:寻求帮助或解释

- docs:关于文档的问题或建议



Priority:

- P0:生产崩溃、安全漏洞

- P1:核心功能损坏

- P2:普通 Bug 或常见需求

- P3:优化建议、文档改善

Configure User message using expression:

Original prompt (Chinese, left untranslated)



Issue 标题:{{ $json.issue.title }}

Issue 内容:{{ $json.issue.body }}

作者:{{ $json.issue.user.login }}

Step 4: Parse AI Output

Add Code node to parse JSON (because AI might output JSON with Markdown code blocks):

Original prompt (Chinese, left untranslated)



const text = $input.first().json.output;



// Remove possible ```json and ``` wrappers, extract pure JSON

const cleaned = text.replace(/```json\n?/g, '').replace(/```\n?/g, '').trim();

const parsed = JSON.parse(cleaned);



return [{ json: parsed }];

Step five: Switch routing

Add Switch node:

Original prompt (Chinese, left untranslated)



Value 1:{{ $json.category }}

Routing rules:

  "bug"     → Output 1

  "feature" → Output 2

  "question"→ Output 3

  "docs"    → Output 4

  (默认)    → Output 5

Step six: Add label + post comment

Add GitHub node for each branch (two operations).

GitHub node (add label):

Original prompt (Chinese, left untranslated)



Resource:Issue

Operation:Add Labels

Repository Owner:{{ $('Webhook').item.json.repository.owner.login }}

Repository Name:{{ $('Webhook').item.json.repository.name }}

Issue Number:{{ $('Webhook').item.json.issue.number }}

Labels:bug(根据分支不同填不同标签)

GitHub node (post comment, only question branch):



Resource:Issue

Operation:Create Comment

Body:{{ $('AI Agent').item.json.suggested_reply }}

Step seven: Slack notification

Original prompt (Chinese, left untranslated)



Channel:#bugs(根据分支选择不同频道)

Message:

*New Issue* has been categorized as `{{ $json.category }}` (Priority {{ $json.priority }}).



*Title*:{{ $('Webhook').item.json.issue.title }}

*Author*:{{ $('Webhook').item.json.issue.user.login }}

*链接*:{{ $('Webhook').item.json.issue.html_url }}



*Reason for classification*:{{ $json.reason }}


Scenario practice two: AI document processing pipeline (invoice/contract extraction)

Automatically extract invoice information from email attachments using AI and store it in Google Sheets.

Business Scenarios

The highest value entry scenario is the AI document processing workflow. The pattern is: trigger document reception via Webhook or email attachment, pass the document content to the AI node, extract structured data using JSON format instructions, and then write the results to Google Sheets, Airtable, or a database. This single workflow can save small operations teams 2-4 hours of manual data entry daily.

Goal: AI extracts key fields from invoice PDF attachments in emails, writes them to Google Sheets, and sends a confirmation.

Workflow Design

Original prompt (Chinese, left untranslated)



Email Trigger(监听新邮件,有附件)

  ↓

IF 节点(过滤:只处理包含发票/invoice 的邮件)

  ↓

HTTP Request(下载邮件附件)

  ↓

AI Agent(提取发票信息,返回结构化 JSON)

  ↓

Google Sheets(追加新行)

  ↓

Email(发送处理确认邮件给发件人)

Key Node Configuration

Email Trigger (IMAP)

Original prompt (Chinese, left untranslated)



Protocol:IMAP

Host:imap.gmail.com(或你的邮件服务器)

User/Password:邮箱账号和专用密码

Mailbox:INBOX

Download Attachments:开启

Prompt for extracting invoice information

Use the AI Agent node, or directly use the Anthropic Chat Model node (more economical):

Original prompt (Chinese, left untranslated)



System: 你是一个发票数据提取专家。从以下发票文本中提取信息,

        Return strict JSON format, no extra text:

{

  "invoice_number": "发票号",

  "invoice_date": "发票日期(YYYY-MM-DD)",

  "vendor_name": "供应商名称",

  "vendor_tax_id": "供应商税号",

  "buyer_name": "购买方名称",

  "items": [

    {

      "description": "商品描述",

      "quantity": 数量,

      "unit_price": 单价,

      "amount": 金额

    }

  ],

  "subtotal": 小计,

  "tax_rate": 税率,

  "tax_amount": 税额,

  "total_amount": 总金额,

  "currency": "货币(CNY/USD/EUR)",

  "due_date": "付款截止日(YYYY-MM-DD,没有则为 null)"

}



User: {{ $json.attachmentText }}

Google Sheets node

Configuration:



Resource:Sheet Within Document

Operation:Append Row

Map fields (reference AI output using expressions):

Original prompt (Chinese, left untranslated)



发票号:{{ $json.invoice_number }}

日期:{{ $json.invoice_date }}

供应商:{{ $json.vendor_name }}

金额:{{ $json.total_amount }}

货币:{{ $json.currency }}

处理时间:{{ $now.toISOString() }}


Scenario Practice Three: Multi-channel Customer Service Routing (with Human-in-the-Loop)

Merge customer service tickets from multiple channels, automatically handle low-priority tickets after AI grading, and wait for manual approval for high-priority tickets.

Business Scenario

Customer service tickets pour in from multiple channels (email, Slack, forms), requiring initial analysis and graded routing by AI, with complex tickets requiring manual approval before replying.

Workflow Design

Original prompt (Chinese, left untranslated)



Merge(合并来自三个渠道的触发)

├── Email Trigger(邮件渠道)

├── Slack Trigger(Slack 消息)

└── Webhook(表单提交)

  ↓

Code 节点(统一数据格式)

  ↓

AI Agent(分析:分类、情感、优先级、建议回复)

  ↓

Switch 节点

  ├── 高优先级(P0/P1)→ 立即通知人工 + Wait 等待审批

  │                        ↓ (等人工回复 Webhook)

  │                     发送审批后的回复

  │

  └── 低优先级(P2/P3)→ 自动发送 AI 生成的回复

                          ↓

                       记录到 Airtable

Human-in-the-Loop Core Configuration

Wait Node (Wait for manual approval)

This is the core node for implementing Human-in-the-Loop in n8n:

Original prompt (Chinese, left untranslated)



Wait for:Webhook

Webhook URL:自动生成一个唯一的审批 URL

Send approval request (to Slack)

Before the Wait node, send the approval message using the Slack node:

Original prompt (Chinese, left untranslated)

Channel: #customer-service-review

Message:

*High priority ticket requires approval*



*Customer*

*Channel*:{{ $json.source }}

*Question*:{{ $json.message }}



*AI 分析*:

- 分类:{{ $json.category }}

- 情感:{{ $json.sentiment }}

- 建议回复:{{ $json.suggested_reply }}



Operation Link

批准回复: {{ $json.approve_url }}?action=approve

修改后批准: https://your-n8n.com/form/modify-reply

拒绝(将升级处理): {{ $json.approve_url }}?action=reject

Wait node receives callback

When a human clicks the "Approve" link, a GET request is sent to the Wait node's Webhook URL, and the workflow automatically continues execution.


Scenario Practice Four: Scheduled Competitor Monitoring and Weekly Report Generation

Automatically scrape competitor updates every Monday, generate a structured weekly report after AI analysis, differentiating between urgent alerts and regular reports.

Business Scenario

The product team needs to receive a competitor dynamic report every Monday morning, covering competitors' blog updates, product releases, and social media activity.

Workflow Design

Original prompt (Chinese, left untranslated)



Schedule Trigger(每周一 8:00)

  ↓

并行分支(4 个竞品,同时抓取)

├── HTTP Request → competitor1.com/blog/rss

├── HTTP Request → competitor2.com/blog/rss

├── HTTP Request → SerpAPI 搜索 "competitor3 release"

└── HTTP Request → GitHub API 查询 competitor4 最新 Release

  ↓

Merge(合并四路结果)

  ↓

Code(过滤:只保留过去 7 天的内容)

  ↓

AI Agent(

  分析所有条目,

  生成结构化的竞品周报,

  突出重大变化和值得关注的趋势

)

  ↓

IF 节点(有没有值得关注的重大变化?)

├── 有重大变化 → 发送 Slack 紧急提醒 + 发邮件周报

└── 无重大变化 → 只发邮件周报(减少噪音)

  ↓

Google Docs(创建本周报告文档)

  ↓

Notion(记录到知识库数据库)

Prompt for AI-generated Weekly Report

Original prompt (Chinese, left untranslated)



你是一个产品竞争情报分析师。



Analyze the following weekly dynamics from competitors and generate a structured competitor weekly report:



{{ $json.allItems }}



Weekly report format requirements:

## 竞品动态周报 - {{ $now.format('YYYY年MM月DD日') }}



### 重大变化(需要立即关注)

[只列出明显的产品发布、定价调整、重大功能更新]



### Competitor Dynamics



#### Competitor A

- [本周更新摘要]



#### Competitor B

- [本周更新摘要]



### 值得关注的趋势

[跨竞品的共同趋势或信号]



### 建议行动

[基于本周动态的 1-3 条具体建议]



---

数据来源:RSS Feed + Google 搜索 + GitHub Releases

数据截止:{{ $now.format('YYYY-MM-DD HH:mm') }}


Error Handling and Reliability

The production environment workflow must handle failure cases to avoid silent failures—where the workflow errors but you are unaware.

Node-level error handling

Click the node, select the Settings tab, and configure the following options:

Configuration options Description
Always Output Data Passes data downstream even if the node fails (suitable for non-critical steps)
Execute Once Executes only once, regardless of how many data items come from upstream
Retry On Fail Automatically retry on failure, with configurable Max Tries: 3 and Wait Between Tries: 2000ms
Continue On Fail Does not interrupt the workflow when a node fails, but marks the error in the output

Workflow-level error handling

In Workflow Settings, select Error Workflow and specify an error handling workflow:

Original prompt (Chinese, left untranslated)



Error Trigger 节点

  ↓

Slack 节点(发送告警):

  频道:#alerts

  消息:

  *Workflow execution failed*

  工作流:{{ $json.workflow.name }}

  执行 ID:{{ $json.execution.id }}

  错误:{{ $json.execution.error.message }}

  发生时间:{{ $now.format('YYYY-MM-DD HH:mm:ss') }}



  查看执行详情: {{ $json.execution.url }}

Establish an alerting workflow

It is recommended to create a dedicated "System Monitoring" workflow:

Original prompt (Chinese, left untranslated)



Schedule Trigger(每 5 分钟)

  ↓

n8n API(获取最近失败的执行)

  ↓

IF 节点(有失败的执行吗?)

  ├── 是 → Slack 告警 + 记录到数据库

  └── 否 → 结束

OpenTelemetry Integration (v2.16+)

n8n now emits OpenTelemetry tracing data for workflow executions.

Each execution becomes a trace record in your existing OpenTelemetry backend, without needing a sidecar, custom exporter, or timing tricks.

Configure in .env:



N8N_METRICS=true

N8N_METRICS_PREFIX=n8n_

OTEL_EXPORTER_OTLP_ENDPOINT=http://your-otel-collector:4318


Version Control and Team Collaboration

Enables team-level collaboration through Git integration, project isolation, and variable management.

Git Integration (Business / Enterprise)

For production deployments, Git version control helps manage workflow changes. All workflows can be versioned in Git and reviewed via PR before going to production, which is impossible in Zapier or Make.

Configuration Path: Select Source Control in Settings:

Projects

In Team plans and above, workflows can be organized into projects, supporting permission isolation between projects, credential isolation by project scope, and execution log filtering by project.

Variable Management

Environment Variables:

Original prompt (Chinese, left untranslated)



# Defined in .env file, referenced in workflow via expression

MY_API_BASE_URL=https://api.example.com



# Use in node

{{ $env.MY_API_BASE_URL }}/endpoint

Variables Node (Team plan and above): Define in Settings under Variables in the n8n interface; can be modified without restarting, suitable for storing frequently changing configuration values.


Fees and Plan Selection

Understand the fee structure for n8n Cloud and self-hosting to choose the plan that best suits you.

n8n Cloud Plans

n8n Cloud pricing is as follows:

Plan Monthly Fee (Annual Payment) Execution Volume Concurrency Suitable for
Starter €20/month 2,500/month 5 Personal projects, light testing
Pro €50/month 10,000/month 20 Daily automation for small and medium-sized teams
Business €667/month 40,000/month Custom Enterprise, including SSO, Git, and multi-environment
Enterprise Customization Unlimited Unlimited Large enterprise compliance requirements

All plans include unlimited workflows and unlimited users, billed only by execution volume. Update in April 2026: n8n has removed the active workflow count limit for all plans, so every plan now has unlimited active workflows, billed only by execution volume.

Self-hosted Community Edition (Free)

n8n Community Edition is completely free and includes: unlimited workflow executions (no upper limit), 500+ integration nodes, full AI Agent workflows, MCP tool integration, and vector storage nodes.

Only pay for server costs:

Configuration Provider Monthly fee Suitable for
2 cores 4 GB Hetzner CX22 €4.5/month Individual / Small team
4 cores 8 GB Hetzner CX32 €7.4/month Medium load
8 cores 16 GB DigitalOcean €40/month High concurrency production

When to choose self-hosting

Self-hosting breaks even at about 20,000 executions/month. Below this amount, n8n Cloud is more cost-effective (saving maintenance time). Above this amount, the savings from self-hosting begin to compound significantly.

Scenarios suitable for self-hosting:

Scenarios suitable for n8n Cloud:


Comparison with Zapier / Make

Compares the three platforms across dimensions such as number of integrations, pricing model, coding ability, and technical team suitability.

n8n, Zapier, and Make have the same execution volume, but the cost for complex workflows is lower.

Zapier has more integrations (6,000+ vs n8n's 500+), but each step is billed separately, making it much more expensive in multi-step workflows.

Make is the cheapest cloud option for simple workflows, but costs rise quickly in complex scenarios (each module = 1 operation).

Dimension Zapier Make n8n
Number of integrations 6,000+ 1,500+ 500+ (+community)
Pricing model Per task (billed per step) Per operation (billed per node) Per execution (entire workflow)
Code support Limited JavaScript None Full JS + Python
Self-hosted Not supported Not supported Fully supported
AI Agent Limited Limited Native complete
Git version control Not supported Not supported Supported (Business+)
Learning curve Low Low Medium
Technical team suitability Low Medium High

Summary: If you have a technical background, or if your workflow complexity exceeds 3-5 steps, n8n is almost always the better choice. If you are completely non-technical and only need to connect two common SaaS, Zapier is easier.


Resources

Recommended learning paths and related resources to help you from beginner to expert in n8n.

Recommended learning paths

Original prompt (Chinese, left untranslated)



本地安装 n8n,跑通第一个 Hello World 工作流

    ↓

完成「HN 早报」案例,熟悉 Schedule + HTTP + Slack

    ↓

配置 3-5 个你日常工作的凭证(GitHub/Slack/Google)

    ↓

完成「文档处理流水线」场景,学会 AI Agent 节点

    ↓

用 Docker Compose + PostgreSQL 搭建自托管实例

    ↓

配置错误处理工作流,建立监控告警

    ↓

配置 MCP Server Trigger,让 Claude Desktop 调用你的工作流

    ↓

(团队)启用 Git 集成,建立开发/生产双环境

Official resources

Resources Link Description
Official website n8n.io Product information and registration entrance
Documentation docs.n8n.io Complete product usage documentation
Workflow templates n8n.io/workflows 1,000+ community templates, one-click import
GitHub github.com/n8n-io/n8n Fair-code license, source code available for viewing
Community forum community.n8n.io Technical Q&A and discussions
Blog blog.n8n.io Feature updates and use cases
Release Notes docs.n8n.io/release-notes Version Update Contents

Common Workflow Templates

You can quickly find corresponding templates by searching the following keywords in the template market:

Scenarios Template Search Keywords
Slack Notification Bot "slack notification"
GitHub automation "github automation"
AI email processing "email AI classification"
Airtable sync "airtable sync"
Database ETL "database sync"
AI Agent "AI agent tools"