n8n

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

n8n Skill - Manage Workflows and Executions

n8n 技能 - 管理工作流与执行任务

n8n Concepts

n8n 核心概念

Workflows

工作流

A workflow is an automation that connects multiple services/apps. It consists of:
  • Nodes - Individual steps that perform actions (HTTP requests, code execution, integrations)
  • Connections - Links between nodes defining data flow
  • Triggers - How the workflow starts (webhook, schedule, manual, etc.)
工作流是一种连接多个服务/应用的自动化流程,它由以下部分组成:
  • Nodes(节点) - 执行具体操作的独立步骤(HTTP请求、代码执行、第三方集成等)
  • Connections(连接) - 定义节点间数据流的关联链路
  • Triggers(触发器) - 工作流的启动方式(webhook、定时任务、手动触发等)

Node Types

节点类型

  • Trigger nodes - Start workflows (Webhook, Schedule, Manual)
  • Regular nodes - Process data (HTTP Request, Set, IF, Switch)
  • Code nodes - Custom JavaScript/Python logic
  • Integration nodes - Connect to services (Slack, Discord, Notion, etc.)
  • Trigger nodes(触发节点) - 启动工作流(Webhook、Schedule、Manual)
  • Regular nodes(常规节点) - 处理数据(HTTP Request、Set、IF、Switch)
  • Code nodes(代码节点) - 自定义JavaScript/Python逻辑
  • Integration nodes(集成节点) - 对接第三方服务(Slack、Discord、Notion等)

Executions

执行任务

An execution is a single run of a workflow. States:
  • success - Completed without errors
  • error - Failed at some node
  • running - Currently executing
  • waiting - Paused, waiting for external event
  • canceled - Manually stopped
执行任务指工作流的单次运行,包含以下状态:
  • success(成功) - 无错误完成运行
  • error(失败) - 在某个节点执行失败
  • running(运行中) - 当前正在执行
  • waiting(等待中) - 已暂停,等待外部事件触发
  • canceled(已取消) - 手动停止运行

Execution Modes

执行模式

  • webhook - Triggered by HTTP request
  • trigger - Triggered by schedule or event
  • manual - Triggered manually from UI
  • retry - Retried from a failed execution
  • webhook - 由HTTP请求触发
  • trigger - 由定时任务或事件触发
  • manual - 从UI手动触发
  • retry - 从失败的执行任务中重试

Webhooks

Webhook

HTTP endpoints that trigger workflows:
  • Production webhook -
    /webhook/<path>
    - Always active when workflow is active
  • Test webhook -
    /webhook-test/<path>
    - For testing, shows data in UI
用于触发工作流的HTTP端点:
  • Production webhook(生产环境Webhook) -
    /webhook/<path>
    - 工作流激活时始终可用
  • Test webhook(测试环境Webhook) -
    /webhook-test/<path>
    - 用于测试,可在UI中查看数据

Credentials

凭据

Stored authentication for services (API keys, OAuth tokens). Referenced by nodes but not exposed in workflow JSON.
存储的第三方服务认证信息(API密钥、OAuth令牌)。节点会引用凭据,但不会在工作流JSON中暴露。

CLI Setup

CLI 配置

The CLI is available via uvx (no installation needed):
bash
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli --help
可通过uvx使用CLI工具(无需安装):
bash
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli --help

Environment Variables

环境变量

Required:
  • N8N_API_KEY
    - API key from n8n (Settings → n8n API)
  • N8N_BASE_URL
    - n8n instance URL (e.g.,
    https://your-instance.app.n8n.cloud
    )
必填项:
  • N8N_API_KEY
    - n8n的API密钥(路径:设置 → n8n API)
  • N8N_BASE_URL
    - n8n实例地址(例如:
    https://your-instance.app.n8n.cloud

CLI Reference

CLI 参考手册

List Workflows

列出工作流

bash
undefined
bash
undefined

List all workflows

列出所有工作流

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli workflows
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli workflows

Active workflows only

仅列出激活的工作流

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli workflows --active
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli workflows --active

JSON output

以JSON格式输出

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli workflows --json
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli workflows --json
undefined

Workflow Details

查看工作流详情

bash
undefined
bash
undefined

Get workflow details

获取工作流详情

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli workflow <workflow_id>
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli workflow <workflow_id>

Full JSON output

输出完整JSON内容

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli workflow <workflow_id> --json
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli workflow <workflow_id> --json
undefined

Activate/Deactivate Workflows

激活/停用工作流

bash
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli activate <workflow_id>
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli deactivate <workflow_id>
bash
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli activate <workflow_id>
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli deactivate <workflow_id>

List Nodes in Workflow

列出工作流中的节点

bash
undefined
bash
undefined

List all nodes (Code nodes marked with *)

列出所有节点(代码节点标记为*)

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli nodes <workflow_id>
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli nodes <workflow_id>
undefined

View/Edit Nodes

查看/编辑节点

bash
undefined
bash
undefined

View node details

查看节点详情

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "node name"
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "node name"

View Code node's JavaScript

查看代码节点的JavaScript代码

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "node name" --code
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "node name" --code

Update Code node from file

从文件更新代码节点

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "node name" --set-code script.js
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "node name" --set-code script.js

Rename a node

重命名节点

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "old name" --rename "new name"
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "old name" --rename "new name"

Set node parameter (supports dot notation for nested keys)

设置节点参数(支持点标记法设置嵌套键)

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "HTTP Request" --set-param url="https://api.example.com" uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "Agent" --set-param options.systemMessage="You are helpful"
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "HTTP Request" --set-param url="https://api.example.com" uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "Agent" --set-param options.systemMessage="You are helpful"

Set multiple parameters at once

同时设置多个参数

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "Node" -p timeout=5000 -p retries=3
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "Node" -p timeout=5000 -p retries=3

Bulk update parameters from JSON (deep merged)

从JSON批量更新参数(深度合并)

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "Node" --set-param-json '{"options": {"systemMessage": "Hello"}}'
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "Node" --set-param-json '{"options": {"systemMessage": "Hello"}}'
undefined

Export/Import Code Nodes

导出/导入代码节点

Useful for editing Code node scripts in a proper editor:
bash
undefined
适合在专业编辑器中编辑代码节点脚本:
bash
undefined

Export all Code nodes to files

将所有代码节点导出到文件

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli export-code <workflow_id> ./nodes/
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli export-code <workflow_id> ./nodes/

Import updated scripts back

将更新后的脚本导入回工作流

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli import-code <workflow_id> ./nodes/
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli import-code <workflow_id> ./nodes/
undefined

Trigger Workflows

触发工作流

bash
undefined
bash
undefined

Trigger workflow by name via webhook

通过Webhook按名称触发工作流

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli trigger "Workflow Name"
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli trigger "Workflow Name"

With JSON payload

携带JSON负载触发

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli trigger "Workflow Name" --data '{"key": "value"}'
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli trigger "Workflow Name" --data '{"key": "value"}'

With payload from file

从文件读取负载触发

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli trigger "Workflow Name" --file payload.json
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli trigger "Workflow Name" --file payload.json

Use test webhook URL

使用测试环境Webhook地址

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli trigger "Workflow Name" --test
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli trigger "Workflow Name" --test
undefined

List Executions

列出执行任务

bash
undefined
bash
undefined

Recent executions

查看最近的执行任务

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions

Filter by workflow

按工作流筛选

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions --workflow <workflow_id>
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions --workflow <workflow_id>

Filter by status (error, success, running, waiting, canceled)

按状态筛选(error、success、running、waiting、canceled)

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions --status error
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions --status error

Limit results

限制结果数量

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions -n 100
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions -n 100
undefined

Execution Details

查看执行任务详情

bash
undefined
bash
undefined

Get execution details (shows error info for failed executions)

获取执行任务详情(失败任务会显示错误信息)

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli execution <execution_id>
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli execution <execution_id>

Include full execution data

包含完整执行数据

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli execution <execution_id> --data
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli execution <execution_id> --data

JSON output

以JSON格式输出

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli execution <execution_id> --data --json
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli execution <execution_id> --data --json
undefined

Retry Failed Execution

重试失败的执行任务

bash
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli retry <execution_id>
bash
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli retry <execution_id>

Use latest workflow version

使用最新版本的工作流重试

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli retry <execution_id> --latest
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli retry <execution_id> --latest
undefined

Credentials Management

凭据管理

Note: The n8n API does not allow reading credential values (security restriction). You can only list credentials metadata, create new credentials, and delete credentials. To update a credential, you must delete and recreate it.
bash
undefined
注意: n8n API不允许读取凭据值(安全限制)。你只能列出凭据元数据、创建新凭据和删除凭据。如需更新凭据,必须先删除再重新创建。
bash
undefined

List all credentials (metadata only - id, name, type)

列出所有凭据(仅元数据 - ID、名称、类型)

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli credentials
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli credentials

Get schema for a credential type (shows required fields)

获取凭据类型的 schema(显示必填字段)

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli credential-schema httpHeaderAuth uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli credential-schema openAiApi --json
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli credential-schema httpHeaderAuth uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli credential-schema openAiApi --json

Create a credential

创建凭据

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli create-credential --name "My API Key" --type httpHeaderAuth --data '{"name": "X-API-Key", "value": "secret"}'
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli create-credential --name "My API Key" --type httpHeaderAuth --data '{"name": "X-API-Key", "value": "secret"}'

Create from file

从文件创建凭据

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli create-credential --name "OpenAI" --type openAiApi --data-file credentials.json
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli create-credential --name "OpenAI" --type openAiApi --data-file credentials.json

Delete a credential

删除凭据

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli delete-credential <credential_id>
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli delete-credential <credential_id>
undefined

Common Workflows

常见工作流场景

Troubleshoot Failed Executions

排查失败的执行任务

bash
undefined
bash
undefined

1. Find failed executions

1. 查找失败的执行任务

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions --status error
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions --status error

2. Get error details

2. 获取错误详情

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli execution <id>
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli execution <id>

3. Get full data for debugging

3. 获取完整数据用于调试

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli execution <id> --data --json
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli execution <id> --data --json
undefined

Edit Code Nodes

编辑代码节点

bash
undefined
bash
undefined

1. Export all Code nodes

1. 导出所有代码节点

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli export-code <workflow_id> ./nodes/
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli export-code <workflow_id> ./nodes/

2. Edit scripts in your editor

2. 在编辑器中编辑脚本

Files: ./nodes/node_name.js

文件路径:./nodes/node_name.js

3. Import changes back

3. 将修改导入回工作流

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli import-code <workflow_id> ./nodes/
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli import-code <workflow_id> ./nodes/
undefined

Quick Node Update

快速更新节点

bash
undefined
bash
undefined

View current code

查看当前代码

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "node name" --code > script.js
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "node name" --code > script.js

Edit script.js...

编辑script.js...

Update node

更新节点

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "node name" --set-code script.js
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli node <workflow_id> "node name" --set-code script.js
undefined

Test Webhook Workflow

测试Webhook工作流

bash
undefined
bash
undefined

Trigger with test payload

使用测试负载触发

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli trigger "Workflow Name" --test --file test_payload.json
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli trigger "Workflow Name" --test --file test_payload.json

Check execution result

检查执行结果

uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions --workflow <id> -n 1
undefined
uvx --from git+https://github.com/pokgak/n8n-cli n8n-cli executions --workflow <id> -n 1
undefined

Execution Data Structure

执行数据结构

When debugging with
--data --json
, the execution contains:
execution
├── id                    # Execution ID
├── status                # success, error, running, etc.
├── mode                  # webhook, trigger, manual, retry
├── startedAt / stoppedAt # Timestamps
├── workflowData          # Snapshot of workflow at execution time
│   ├── name
│   ├── nodes[]
│   └── connections
└── data
    └── resultData
        ├── runData       # Output from each node
        │   └── [nodeName][]
        │       ├── data.main[][] # Node output items
        │       └── executionStatus
        ├── lastNodeExecuted
        └── error         # If failed
            ├── message
            ├── description
            └── node      # Which node failed
使用
--data --json
调试时,执行任务包含以下结构:
execution
├── id                    # 执行任务ID
├── status                # success、error、running等
├── mode                  # webhook、trigger、manual、retry
├── startedAt / stoppedAt # 时间戳
├── workflowData          # 执行时的工作流快照
│   ├── name
│   ├── nodes[]
│   └── connections
└── data
    └── resultData
        ├── runData       # 每个节点的输出
        │   └── [nodeName][]
        │       ├── data.main[][] # 节点输出项
        │       └── executionStatus
        ├── lastNodeExecuted
        └── error         # 失败时的错误信息
            ├── message
            ├── description
            └── node      # 失败的节点

Common Error Patterns

常见错误类型

Webhook Payload Issues

Webhook负载问题

  • Check
    execution --data --json
    and look at the Webhook node's output
  • Payload is in
    runData.Webhook[0].data.main[0][0].json.body
  • 执行
    execution --data --json
    并查看Webhook节点的输出
  • 负载位于
    runData.Webhook[0].data.main[0][0].json.body

Code Node Errors

代码节点错误

  • Error message shows the JavaScript error
  • Use
    node <workflow_id> "node name" --code
    to view the code
  • Common: undefined variables, JSON parsing, missing fields
  • 错误信息会显示JavaScript错误详情
  • 使用
    node <workflow_id> "node name" --code
    查看代码
  • 常见问题:未定义变量、JSON解析错误、字段缺失

Integration Failures

集成失败

  • Usually credential or API issues
  • Check if the service is accessible
  • Verify credential permissions
  • 通常是凭据或API问题
  • 检查服务是否可访问
  • 验证凭据权限