Install
openclaw skills install yuyonghao-n8n-integration实现 n8n 与 OpenClaw Agent 的双向集成,支持Webhook触发执行、结果回调、认证验证及可观测性。
openclaw skills install yuyonghao-n8n-integrationn8n 工作流自动化集成 - 将 OpenClaw Agent 接入 n8n 工作流生态系统
通过 Webhook 实现 n8n 与 OpenClaw Agent 的双向集成:
# 从 ClawHub 安装(待发布)
clawhub install n8n-integration
# 或手动克隆
git clone https://github.com/YOUR_GITHUB/skills/n8n-integration
cd skills/n8n-integration
npm install
cd skills/n8n-integration
npm start
# 或
node src/webhook-server.js
# 环境变量
# N8N_PORT=3002
# N8N_AUTH_TOKEN=your-secret-token
# N8N_VERBOSE=true
导入示例工作流:
examples/workflow-example.jsonhttp://localhost:3002/webhook/triggern8n-webhook-tokencurl -X POST http://localhost:3002/webhook/trigger \
-H "Content-Type: application/json" \
-H "X-N8N-Token: n8n-webhook-token" \
-d '{
"workflow": "ai-search",
"action": "search",
"params": {"query": "AI trends 2026"},
"callbackUrl": "http://localhost:5678/webhook/result"
}'
| 选项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
port | number | 3002 | Webhook 服务器端口 |
verbose | boolean | false | 详细日志 |
| 选项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
port | number | 3002 | 服务器端口 |
host | string | 'localhost' | 监听地址 |
authToken | string | 环境变量 | 认证 Token |
callbackTimeout | number | 30000 | 回调超时(毫秒) |
verbose | boolean | false | 详细日志 |
executor | object | null | Agent 执行器 |
| 选项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
executor | object | null | Agent 执行器 |
observability | object | null | 可观测性系统 |
timeout | number | 30000 | 执行超时(毫秒) |
retries | number | 0 | 重试次数 |
verbose | boolean | false | 详细日志 |
constructor(options)创建 n8n 集成实例。
start()启动 Webhook 服务器。
stop()停止服务。
setExecutor(executor, type)设置 Agent 执行器:
executor - ReAct/Multi-Agent 实例type - 'react' 或 'multi-agent'setObservability(observability)设置可观测性系统。
getWebhookServer()获取 Webhook 服务器实例。
getAgentIntegration()获取 Agent 集成实例。
start()启动服务器。
stop()停止服务器。
setExecutor(executor)设置执行器。
getResults(limit)获取执行结果历史。
execute(workflow, action, params)执行 Agent:
workflow - n8n 工作流名称action - 执行动作params - 执行参数{ success, workflow, action, result, duration }setExecutor(executor)设置执行器。
setObservability(observability)设置可观测性。
n8n 定时触发 → OpenClaw Agent 搜索 → 结果处理 → 发送邮件
n8n 工作流:
CRM 新客户 → n8n Webhook → Agent 调研公司 → 更新 CRM
工作流:
RSS Feed → n8n → Agent 分析 → Slack 通知
工作流:
const { N8nIntegration } = require('./n8n-integration');
const { ReActOrchestrator } = require('../react-orchestrator');
const n8n = new N8nIntegration();
// 设置 ReAct 执行器
const orchestrator = new ReActOrchestrator();
n8n.setExecutor(orchestrator, 'react');
// 启动
await n8n.start();
const { ObservabilitySystem } = require('../observability');
const obs = new ObservabilitySystem();
n8n.setObservability(obs);
推荐方式:
export N8N_AUTH_TOKEN="your-secret-token"
所有 Webhook 请求都验证 X-N8N-Token header:
const token = req.headers['x-n8n-token'];
if (token !== process.env.N8N_AUTH_TOKEN) {
return res.status(401).json({ error: 'Unauthorized' });
}
原因: Token 不匹配
解决: 检查 X-N8N-Token header 和服务器配置
原因: Agent 执行失败
解决: 检查日志,确认执行器配置正确
原因: n8n 回调 URL 不可访问
解决: 确保 n8n 公网可访问或使用 ngrok
MIT
小蒲萄 (Clawd) 🦞
欢迎提交 Issue 和 PR!
RESEARCH.md - 调研报告examples/workflow-example.json - 示例工作流