n8n
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseN8N Skill
N8N 技能
Comprehensive assistance with n8n development, generated from official documentation. n8n is a fair-code licensed workflow automation tool that combines AI capabilities with business process automation.
提供基于官方文档的n8n开发全方位支持。n8n是一款采用公平代码许可的工作流自动化工具,将AI能力与业务流程自动化相结合。
When to Use This Skill
何时使用该技能
This skill should be triggered when:
- Building or debugging n8n workflows
- Working with the Code node (JavaScript or Python)
- Using expressions and data transformations
- Implementing AI agents, chains, or RAG workflows
- Configuring n8n deployments (Docker, npm, self-hosted)
- Setting up webhooks, credentials, or integrations
- Handling errors in workflows
- Scaling n8n with queue mode
- Creating custom nodes or white labeling n8n
- Using the n8n API programmatically
- Working with LangChain in n8n
- Migrating to n8n v1.0
在以下场景中可触发本技能:
- 构建或调试n8n工作流
- 使用Code节点(JavaScript或Python)
- 运用表达式与数据转换
- 实现AI Agent、链或RAG工作流
- 配置n8n部署(Docker、npm、自托管)
- 设置Webhook、凭证或集成
- 处理工作流中的错误
- 通过队列模式扩展n8n
- 创建自定义节点或为n8n添加白标
- 以编程方式使用n8n API
- 在n8n中使用LangChain
- 迁移至n8n v1.0
Key Concepts
核心概念
Core Components
核心组件
- Workflows: Visual automation flows with nodes connected together
- Nodes: Individual operations in a workflow (trigger, action, logic, etc.)
- Expressions: Code snippets using syntax to access and transform data
{{ }} - Credentials: Secure storage for API keys and authentication
- Executions: Individual workflow runs with their data and status
- Workflows(工作流):由节点连接而成的可视化自动化流程
- Nodes(节点):工作流中的单个操作(触发器、动作、逻辑等)
- Expressions(表达式):使用语法的代码片段,用于访问和转换数据
{{ }} - Credentials(凭证):安全存储API密钥与认证信息
- Executions(执行记录):工作流的单次运行实例,包含运行数据与状态
Data Structure
数据结构
- n8n passes data between nodes as items (array of JSON objects)
- Each item has a property containing the main data
json - Binary data is stored separately in the property
binary - Use to access current item's data in expressions
$json
- n8n通过**items(项)**在节点间传递数据(JSON对象数组)
- 每个项包含属性,存储主要数据
json - 二进制数据单独存储在属性中
binary - 在表达式中使用访问当前项的数据
$json
AI Capabilities
AI能力
- Agents: AI that can use tools and make decisions
- Chains: Predefined sequences of AI operations
- Memory: Store conversation history for context
- Tools: Functions that AI agents can call
- Vector Databases: Store and retrieve embeddings for RAG
- Agents(智能体):可使用工具并做出决策的AI
- Chains(链):预定义的AI操作序列
- Memory(记忆):存储对话历史以保留上下文
- Tools(工具):AI智能体可调用的函数
- Vector Databases(向量数据库):存储和检索嵌入向量以实现RAG
Quick Reference
快速参考
Example 1: Basic Expression to Access Data
示例1:访问数据的基础表达式
javascript
// Access data from the current item
{{ $json.name }}
// Access data from a specific node
{{ $node["HTTP Request"].json.response }}
// Access all items from a node
{{ $("HTTP Request").all() }}javascript
// Access data from the current item
{{ $json.name }}
// Access data from a specific node
{{ $node["HTTP Request"].json.response }}
// Access all items from a node
{{ $("HTTP Request").all() }}Example 2: HTTP Request with Authentication
示例2:带认证的HTTP请求
When working with the HTTP Request node, handle errors and rate limits:
javascript
// In HTTP Request node settings:
// - Enable "Retry on Fail"
// - Set Max Tries to 3
// - Set Wait Between Tries (ms) to 1000
// For rate limiting, use Batching:
// - Items per Batch: 10
// - Batch Interval (ms): 1000使用HTTP Request节点时,处理错误与速率限制:
javascript
// In HTTP Request node settings:
// - Enable "Retry on Fail"
// - Set Max Tries to 3
// - Set Wait Between Tries (ms) to 1000
// For rate limiting, use Batching:
// - Items per Batch: 10
// - Batch Interval (ms): 1000Example 3: Code Node - Transform Data (JavaScript)
示例3:Code节点 - 数据转换(JavaScript)
javascript
// Access input data
const items = $input.all();
// Transform each item
return items.map(item => {
return {
json: {
fullName: `${item.json.firstName} ${item.json.lastName}`,
email: item.json.email.toLowerCase(),
timestamp: new Date().toISOString()
}
};
});javascript
// Access input data
const items = $input.all();
// Transform each item
return items.map(item => {
return {
json: {
fullName: `${item.json.firstName} ${item.json.lastName}`,
email: item.json.email.toLowerCase(),
timestamp: new Date().toISOString()
}
};
});Example 4: Code Node - Filter Data (Python)
示例4:Code节点 - 数据过滤(Python)
python
undefinedpython
undefinedFilter items based on a condition
Filter items based on a condition
output = []
for item in items:
if item['json']['status'] == 'active':
output.append({
'json': {
'id': item['json']['id'],
'name': item['json']['name']
}
})
return output
undefinedoutput = []
for item in items:
if item['json']['status'] == 'active':
output.append({
'json': {
'id': item['json']['id'],
'name': item['json']['name']
}
})
return output
undefinedExample 5: Expression - Date Handling with Luxon
示例5:表达式 - 使用Luxon处理日期
javascript
// Current date
{{ $now }}
// Format date
{{ $now.toFormat('yyyy-MM-dd') }}
// Add 7 days
{{ $now.plus({ days: 7 }) }}
// Parse and format custom date
{{ DateTime.fromISO($json.dateString).toFormat('LLL dd, yyyy') }}javascript
// Current date
{{ $now }}
// Format date
{{ $now.toFormat('yyyy-MM-dd') }}
// Add 7 days
{{ $now.plus({ days: 7 }) }}
// Parse and format custom date
{{ DateTime.fromISO($json.dateString).toFormat('LLL dd, yyyy') }}Example 6: JWT Authentication Credential
示例6:JWT认证凭证
For APIs requiring JWT authentication:
javascript
// Use JWT credential with:
// - Key Type: Passphrase (for HMAC) or PEM Key (for RSA/ECDSA)
// - Secret: Your secret key
// - Algorithm: HS256, RS256, ES256, etc.
// The JWT credential automatically generates tokens
// Use it in HTTP Request node > Authentication > JWT对于需要JWT认证的API:
javascript
// Use JWT credential with:
// - Key Type: Passphrase (for HMAC) or PEM Key (for RSA/ECDSA)
// - Secret: Your secret key
// - Algorithm: HS256, RS256, ES256, etc.
// The JWT credential automatically generates tokens
// Use it in HTTP Request node > Authentication > JWTExample 7: Handle Errors in Workflow
示例7:处理工作流中的错误
javascript
// In Code node, use try-catch:
try {
const result = $json.data.someField.toUpperCase();
return [{ json: { result } }];
} catch (error) {
// Return error information
return [{
json: {
error: error.message,
originalData: $json
}
}];
}
// Or set up Error Workflow in Workflow Settings
// to catch all failures and send notificationsjavascript
// In Code node, use try-catch:
try {
const result = $json.data.someField.toUpperCase();
return [{ json: { result } }];
} catch (error) {
// Return error information
return [{
json: {
error: error.message,
originalData: $json
}
}];
}
// Or set up Error Workflow in Workflow Settings
// to catch all failures and send notificationsExample 8: Pagination in HTTP Request
示例8:HTTP请求中的分页
javascript
// Use pagination to fetch all pages
// In HTTP Request node > Pagination:
// Type: Generic Pagination
// Request URL: {{ $url }}&page={{ $pageNumber }}
// Complete When: {{ $response.body.hasMore === false }}
// Next Page URL: Automaticjavascript
// Use pagination to fetch all pages
// In HTTP Request node > Pagination:
// Type: Generic Pagination
// Request URL: {{ $url }}&page={{ $pageNumber }}
// Complete When: {{ $response.body.hasMore === false }}
// Next Page URL: AutomaticExample 9: AI Agent with Tools
示例9:带工具的AI Agent
javascript
// In AI Agent node:
// 1. Connect a Chat Model (OpenAI, etc.)
// 2. Add tools (Calculator, HTTP Request, etc.)
// 3. Configure memory if needed
// The agent can:
// - Analyze user input
// - Decide which tools to use
// - Execute tools and process results
// - Return final answerjavascript
// In AI Agent node:
// 1. Connect a Chat Model (OpenAI, etc.)
// 2. Add tools (Calculator, HTTP Request, etc.)
// 3. Configure memory if needed
// The agent can:
// - Analyze user input
// - Decide which tools to use
// - Execute tools and process results
// - Return final answerExample 10: Environment Variables and Static Data
示例10:环境变量与静态数据
javascript
// Access environment variables
{{ $env.MY_API_KEY }}
// Store workflow static data (persists across executions)
const staticData = getWorkflowStaticData('global');
staticData.lastRun = new Date().toISOString();
staticData.counter = (staticData.counter || 0) + 1;
// Retrieve static data
{{ $workflow.staticData.counter }}javascript
// Access environment variables
{{ $env.MY_API_KEY }}
// Store workflow static data (persists across executions)
const staticData = getWorkflowStaticData('global');
staticData.lastRun = new Date().toISOString();
staticData.counter = (staticData.counter || 0) + 1;
// Retrieve static data
{{ $workflow.staticData.counter }}Reference Files
参考文件
This skill includes comprehensive documentation in :
references/-
llms-txt.md - Complete n8n documentation formatted for LLMs
- Installation and setup guides
- Node reference documentation
- API documentation
- Code examples and patterns
- Configuration options
- Troubleshooting guides
-
llms-full.md - Extended documentation with deep technical details
- Advanced configuration
- Scaling and performance
- Security and authentication
- Custom node development
- White labeling and embed options
Use to read specific reference files when detailed information is needed.
view本技能包含目录下的完整文档:
references/-
llms-txt.md - 为大语言模型格式化的完整n8n文档
- 安装与设置指南
- 节点参考文档
- API文档
- 代码示例与模式
- 配置选项
- 故障排除指南
-
llms-full.md - 包含深度技术细节的扩展文档
- 高级配置
- 扩展与性能优化
- 安全与认证
- 自定义节点开发
- 白标与嵌入选项
当需要详细信息时,使用命令查看特定参考文件。
viewWorking with This Skill
使用本技能的指南
For Beginners
初学者
-
Start with basic workflow creation:
- Trigger nodes (Webhook, Schedule, Manual)
- Action nodes (HTTP Request, Set, Edit Fields)
- Learn expression syntax with simple access
{{ $json.field }}
-
Understand data structure:
- Each node outputs an array of items
- Use the data inspector to see item structure
- Practice with the Edit Fields node for data transformation
-
Common patterns:
- Webhook → HTTP Request → Set → Respond to Webhook
- Schedule → Code → HTTP Request → Conditional
- Manual → Loop Over Items → Process Each
-
从基础工作流创建开始:
- 触发器节点(Webhook、Schedule、Manual)
- 动作节点(HTTP Request、Set、Edit Fields)
- 学习使用简单的表达式语法访问数据
{{ $json.field }}
-
理解数据结构:
- 每个节点输出项数组
- 使用数据检查器查看项结构
- 练习使用Edit Fields节点进行数据转换
-
常见模式:
- Webhook → HTTP Request → Set → Respond to Webhook
- Schedule → Code → HTTP Request → Conditional
- Manual → Loop Over Items → Process Each
For Intermediate Users
中级用户
-
Master the Code node:
- JavaScript mode for complex transformations
- Access for all items
$input.all() - Return properly formatted items with property
json
-
Work with expressions:
- Use built-in methods: ,
.first(),.last().item - Date manipulation with Luxon
- JMESPath for complex JSON queries
- Use built-in methods:
-
Error handling:
- Use Try-Catch in Code nodes
- Set up Error Workflows
- Configure Retry on Fail for API calls
-
Data operations:
- Merge data from multiple sources
- Split and filter items
- Loop over items for batch processing
-
精通Code节点:
- 使用JavaScript模式进行复杂转换
- 访问获取所有项
$input.all() - 返回带有属性的格式正确的项
json
-
运用表达式:
- 使用内置方法:、
.first()、.last().item - 使用Luxon处理日期
- 使用JMESPath进行复杂JSON查询
- 使用内置方法:
-
错误处理:
- 在Code节点中使用Try-Catch
- 设置错误工作流
- 为API调用配置失败重试
-
数据操作:
- 合并多源数据
- 拆分与过滤项
- 循环处理项以实现批量操作
For Advanced Users
高级用户
-
AI and LangChain:
- Build AI agents with custom tools
- Implement RAG with vector databases
- Use memory for conversational workflows
- Chain multiple AI operations
-
Scaling and performance:
- Configure queue mode for distributed execution
- Optimize database settings
- Use execution data pruning
- Configure task runners
-
Custom development:
- Create custom nodes
- White label n8n for embedding
- Use the n8n API for workflow management
- Implement external secrets with AWS/Azure/GCP
-
Advanced patterns:
- Sub-workflows for reusability
- Webhook authentication and validation
- Complex data transformations with JMESPath
- Real-time data processing with SSE/WebSockets
-
AI与LangChain:
- 使用自定义工具构建AI Agent
- 结合向量数据库实现RAG
- 为对话式工作流使用记忆功能
- 链式调用多个AI操作
-
扩展与性能优化:
- 配置队列模式实现分布式执行
- 优化数据库设置
- 使用执行数据清理
- 配置任务运行器
-
自定义开发:
- 创建自定义节点
- 为n8n添加白标以实现嵌入
- 使用n8n API管理工作流
- 集成AWS/Azure/GCP的外部密钥管理
-
高级模式:
- 使用子工作流实现复用
- Webhook认证与验证
- 使用JMESPath进行复杂数据转换
- 使用SSE/WebSockets处理实时数据
Common Issues and Solutions
常见问题与解决方案
HTTP Request Errors
HTTP请求错误
- 400 Bad Request: Check query parameters and array formatting
- 403 Forbidden: Verify credentials and API permissions
- 429 Rate Limit: Use Batching or Retry on Fail options
- 404 Not Found: Verify endpoint URL is correct
- 400 Bad Request:检查查询参数与数组格式
- 403 Forbidden:验证凭证与API权限
- 429 Rate Limit:使用批量处理或失败重试选项
- 404 Not Found:验证端点URL是否正确
Expression Errors
表达式错误
- Workflows now fail on expression errors in v1.0+
- Set up Error Workflows to catch failures
- Test expressions in the expression editor
- Check for undefined values before accessing properties
- 在v1.0+版本中,工作流会因表达式错误而终止
- 设置错误工作流以捕获失败
- 在表达式编辑器中测试表达式
- 在访问属性前检查是否存在未定义值
Data Type Issues
数据类型问题
- Use ,
.toString()for type conversion.toNumber() - Handle null/undefined with
{{ $json.field || 'default' }} - Binary data requires special handling with buffers
- 使用、
.toString()进行类型转换.toNumber() - 使用处理null/未定义值
{{ $json.field || 'default' }} - 二进制数据需要使用缓冲区进行特殊处理
Migration to v1.0
迁移至v1.0
- New execution order (depth-first instead of breadth-first)
- Python support in Code node (Pyodide)
- Mandatory user management (no more BasicAuth)
- WebSocket push backend is now default
- Node 18.17.0 or higher required
- 新的执行顺序(深度优先而非广度优先)
- Code节点支持Python(基于Pyodide)
- 强制用户管理(不再支持BasicAuth)
- WebSocket推送后端成为默认选项
- 需要Node 18.17.0或更高版本
Environment Configuration
环境配置
Docker Setup
Docker设置
bash
undefinedbash
undefinedBasic n8n with Docker
Basic n8n with Docker
docker run -it --rm
--name n8n
-p 5678:5678
-v ~/.n8n:/home/node/.n8n
n8nio/n8n
--name n8n
-p 5678:5678
-v ~/.n8n:/home/node/.n8n
n8nio/n8n
docker run -it --rm
--name n8n
-p 5678:5678
-v ~/.n8n:/home/node/.n8n
n8nio/n8n
--name n8n
-p 5678:5678
-v ~/.n8n:/home/node/.n8n
n8nio/n8n
With environment variables
With environment variables
docker run -it --rm
--name n8n
-p 5678:5678
-e N8N_BASIC_AUTH_ACTIVE=true
-e N8N_BASIC_AUTH_USER=admin
-e N8N_BASIC_AUTH_PASSWORD=password
-v ~/.n8n:/home/node/.n8n
n8nio/n8n
--name n8n
-p 5678:5678
-e N8N_BASIC_AUTH_ACTIVE=true
-e N8N_BASIC_AUTH_USER=admin
-e N8N_BASIC_AUTH_PASSWORD=password
-v ~/.n8n:/home/node/.n8n
n8nio/n8n
undefineddocker run -it --rm
--name n8n
-p 5678:5678
-e N8N_BASIC_AUTH_ACTIVE=true
-e N8N_BASIC_AUTH_USER=admin
-e N8N_BASIC_AUTH_PASSWORD=password
-v ~/.n8n:/home/node/.n8n
n8nio/n8n
--name n8n
-p 5678:5678
-e N8N_BASIC_AUTH_ACTIVE=true
-e N8N_BASIC_AUTH_USER=admin
-e N8N_BASIC_AUTH_PASSWORD=password
-v ~/.n8n:/home/node/.n8n
n8nio/n8n
undefinedKey Environment Variables
关键环境变量
- : Hostname (default: localhost)
N8N_HOST - : Port (default: 5678)
N8N_PORT - : http or https
N8N_PROTOCOL - : External webhook URL
WEBHOOK_URL - : Encryption key for credentials
N8N_ENCRYPTION_KEY - : Database type (sqlite, postgres)
DB_TYPE - : queue or main (queue for scaling)
EXECUTIONS_MODE
- :主机名(默认:localhost)
N8N_HOST - :端口(默认:5678)
N8N_PORT - :http或https
N8N_PROTOCOL - :外部Webhook URL
WEBHOOK_URL - :凭证加密密钥
N8N_ENCRYPTION_KEY - :数据库类型(sqlite、postgres)
DB_TYPE - :queue或main(queue用于扩展)
EXECUTIONS_MODE
Resources
资源
Official Resources
官方资源
Learning Paths
学习路径
- Level One Course: Basic workflow building
- Level Two Course: Advanced data handling and error management
- Video Courses: Visual learning resources
- AI Tutorial: Build AI workflows from scratch
- Level One Course:基础工作流构建
- Level Two Course:高级数据处理与错误管理
- Video Courses:可视化学习资源
- AI Tutorial:从零开始构建AI工作流
API and Development
API与开发
Notes
说明
- This skill was automatically generated from official n8n documentation
- Code examples use proper language tags for syntax highlighting
- Examples are extracted from real-world patterns in the docs
- Focus on practical, actionable patterns for immediate use
- 本技能由官方n8n文档自动生成
- 代码示例使用正确的语言标签以实现语法高亮
- 示例提取自文档中的真实场景模式
- 聚焦于实用、可立即使用的模式
Updating
更新
To refresh this skill with updated documentation:
- Re-run the scraper with the same configuration
- The skill will be rebuilt with the latest information
- Review Quick Reference section for new examples
如需使用最新文档刷新本技能:
- 使用相同配置重新运行抓取工具
- 技能将使用最新信息重建
- 查看快速参考部分获取新示例