返回顶部
n

n8nn8n工作流管理

Manage n8n workflows and automations via API. Use when working with n8n workflows, executions, or automation tasks - listing workflows, activating/deactivating, checking execution status, manually triggering workflows, or debugging automation issues.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 2.0.0
安全检测
已通过
16,719
下载量
免费
免费
52
收藏
概述
安装方式
版本历史

n8n

n8n 工作流管理

为 n8n 平台提供全面的工作流自动化管理,包括创建、测试、执行监控和性能优化能力。

⚠️ 关键:工作流创建规则

创建 n8n 工作流时,始终:

  1. 1. ✅ 生成完整的工作流,包含所有功能节点
  2. 包含实际的 HTTP 请求节点,用于 API 调用(ImageFX、Gemini、Veo、Suno 等)
  3. 添加代码节点,用于数据转换和逻辑处理
  4. 在所有节点之间创建正确的连接
  5. 使用真实的节点类型(n8n-nodes-base.httpRequest、n8n-nodes-base.code、n8n-nodes-base.set)

切勿:

  • - ❌ 创建设置说明占位节点
  • ❌ 生成仅包含 TODO 注释的工作流
  • ❌ 创建需要手动添加节点的不完整工作流
  • ❌ 使用纯文本节点替代实际功能

良好工作流示例:

手动触发 → 设置配置 → HTTP 请求(API 调用)→ 代码(解析)→ 响应

不良工作流示例:

手动触发 → 代码(在此添加 HTTP 节点,配置 API...)

始终构建完整、功能齐全的工作流,配置并连接所有必要节点。

设置

所需环境变量:

  • - N8NAPIKEY — 您的 n8n API 密钥(n8n 界面中的设置 → API)
  • N8NBASEURL — 您的 n8n 实例 URL

通过 OpenClaw 设置配置凭据:

添加到 ~/.config/openclaw/settings.json:
json
{
skills: {
n8n: {
env: {
N8NAPIKEY: your-api-key-here,
N8NBASEURL: your-n8n-url-here
}
}
}
}

或按会话设置(不要将密钥持久化存储在 shell rc 文件中):
bash
export N8NAPIKEY=your-api-key-here
export N8NBASEURL=your-n8n-url-here

验证连接:
bash
python3 scripts/n8n_api.py list-workflows --pretty

安全提示: 切勿将 API 密钥以明文形式存储在 shell 配置文件(~/.bashrc、~/.zshrc)中。请使用 OpenClaw 设置文件或安全的密钥管理器。

快速参考

工作流管理

列出工作流

bash python3 scripts/n8n_api.py list-workflows --pretty python3 scripts/n8n_api.py list-workflows --active true --pretty

获取工作流详情

bash python3 scripts/n8n_api.py get-workflow --id --pretty

创建工作流

bash

从 JSON 文件创建

python3 scripts/n8n_api.py create --from-file workflow.json

激活/停用

bash python3 scripts/n8n_api.py activate --id python3 scripts/n8n_api.py deactivate --id

测试与验证

验证工作流结构

bash

验证现有工作流

python3 scripts/n8n_tester.py validate --id

从文件验证

python3 scripts/n8n_tester.py validate --file workflow.json --pretty

生成验证报告

python3 scripts/n8n_tester.py report --id

试运行测试

bash

使用数据测试

python3 scripts/n8n_tester.py dry-run --id --data {email: test@example.com}

使用数据文件测试

python3 scripts/n8n_tester.py dry-run --id --data-file test-data.json

完整测试报告(验证 + 试运行)

python3 scripts/n8n_tester.py dry-run --id --data-file test.json --report

测试套件

bash

运行多个测试用例

python3 scripts/n8n_tester.py test-suite --id --test-suite test-cases.json

执行监控

列出执行记录

bash

最近的执行记录(所有工作流)

python3 scripts/n8n_api.py list-executions --limit 10 --pretty

特定工作流的执行记录

python3 scripts/n8n_api.py list-executions --id --limit 20 --pretty

获取执行详情

bash python3 scripts/n8n_api.py get-execution --id --pretty

手动执行

bash

触发工作流

python3 scripts/n8n_api.py execute --id

带数据执行

python3 scripts/n8n_api.py execute --id --data {key: value}

性能优化

分析性能

bash

完整性能分析

python3 scripts/n8n_optimizer.py analyze --id --pretty

分析特定时间段

python3 scripts/n8n_optimizer.py analyze --id --days 30 --pretty

获取优化建议

bash

按优先级排序的建议

python3 scripts/n8n_optimizer.py suggest --id --pretty

生成优化报告

bash

包含指标、瓶颈和建议的可读报告

python3 scripts/n8n_optimizer.py report --id

获取工作流统计信息

bash

执行统计

python3 scripts/n8n_api.py stats --id --days 7 --pretty

Python API

基本用法

python
from scripts.n8n_api import N8nClient

client = N8nClient()

列出工作流

workflows = client.list_workflows(active=True)

获取工作流

workflow = client.get_workflow(workflow-id)

创建工作流

newworkflow = client.createworkflow({ name: My Workflow, nodes: [...], connections: {...} })

激活/停用

client.activate_workflow(workflow-id) client.deactivate_workflow(workflow-id)

执行记录

executions = client.listexecutions(workflowid=workflow-id, limit=10) execution = client.get_execution(execution-id)

执行工作流

result = client.execute_workflow(workflow-id, data={key: value})

验证与测试

python
from scripts.n8n_api import N8nClient
from scripts.n8n_tester import WorkflowTester

client = N8nClient()
tester = WorkflowTester(client)

验证工作流

validation = tester.validateworkflow(workflowid=123) print(f有效: {validation[valid]}) print(f错误: {validation[errors]}) print(f警告: {validation[warnings]})

试运行

result = tester.dry_run( workflow_id=123, test_data={email: test@example.com} ) print(f状态: {result[status]})

测试套件

test_cases = [ {name: 测试 1, input: {...}, expected: {...}}, {name: 测试 2, input: {...}, expected: {...}} ] results = tester.testsuite(123, testcases) print(f通过: {results[passed]}/{results[total_tests]})

生成报告

report = tester.generatetestreport(validation, result) print(report)

性能优化

python
from scripts.n8n_optimizer import WorkflowOptimizer

optimizer = WorkflowOptimizer()

分析性能

analysis = optimizer.analyze_performance(workflow-id, days=7) print(f性能评分: {analysis[performance_score]}/100) print(f健康状态: {analysis[execution_metrics][health]})

获取建议

suggestions = optimizer.suggest_optimizations(workflow-id) print(f优先操作: {len(suggestions[priority_actions])}) print(f快速优化: {len(suggestions[quick_wins])})

生成报告

report = optimizer.generateoptimizationreport(analysis) print(report)

常见工作流

1. 验证和测试工作流

bash

验证工作流结构


python3 scripts/n8n_tester.py validate --id --pretty

使用样本

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 n8n-1776354434 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 n8n-1776354434 技能

通过命令行安装

skillhub install n8n-1776354434

下载

⬇ 下载 n8n v2.0.0(免费)

文件大小: 21.5 KB | 发布时间: 2026-4-17 15:15

v2.0.0 最新 2026-4-17 15:15
# Changelog - n8n Enhanced Workflow Management Skill

## Version 2.0.0 - 10 Feb 2026

### 🎉 Major Enhancement Release

Complete redesign of the n8n skill with comprehensive workflow lifecycle management capabilities.

### ✨ New Features

#### Testing & Validation
- **Structure Validation:** `n8n_tester.py` validates workflow integrity
- Node and connection validation
- Credential checking
- Configuration verification
- Flow analysis
- **Dry-Run Testing:** Test workflows with sample data before activation
- **Test Suites:** Run multiple test cases against workflows
- **Validation Reports:** Human-readable test reports with errors and warnings

#### Execution Monitoring
- **Enhanced Execution Tracking:** Real-time execution monitoring
- **Detailed Statistics:** Success/failure rates, execution patterns
- **Error Analysis:** Identify and categorize failure patterns
- **Retry Logic:** Built-in retry support for failed executions

#### Performance Optimization
- **Performance Analysis:** `n8n_optimizer.py` provides comprehensive metrics
- Execution metrics (success rate, failure patterns)
- Node analysis (complexity, expensive operations)
- Connection analysis (parallel paths, bottlenecks)
- Performance scoring (0-100)
- **Bottleneck Detection:** Identify workflow performance issues
- Sequential expensive operations
- High failure rates
- Missing error handling
- **Optimization Suggestions:** Actionable recommendations
- Parallel execution opportunities
- Caching strategies
- Batch processing
- Error handling improvements
- Complexity reduction
- **Optimization Reports:** Human-readable performance reports

### 📝 API Extensions

#### n8n_api.py Enhancements
- `validate_workflow()` - Validate workflow structure
- `dry_run_workflow()` - Test workflow with mock data
- `get_workflow_statistics()` - Get execution statistics
- `analyze_workflow_performance()` - Performance analysis
- CLI support for `create`, `validate`, and `stats` commands

#### New Modules
- **n8n_tester.py** - Testing and validation
- Structure validation
- Dry-run execution
- Test suite runner
- Report generation
- **n8n_optimizer.py** - Performance optimization
- Performance analysis
- Bottleneck detection
- Optimization suggestions
- Report generation

### 📚 Documentation

#### New Documentation
- **README.md** - Quick start guide with examples
- **SKILL.md** - Comprehensive documentation (16KB)
- All CLI commands
- Python API examples
- Common workflows
- Best practices
- Troubleshooting guide
- **templates/README.md** - Template documentation
- Template descriptions
- Configuration guides
- Test data examples
- **CHANGELOG.md** - This file

#### Updated Documentation
- Enhanced quick reference
- Added validation examples
- Performance optimization guides
- Template usage examples

### 🗂️ File Structure

```
~/clawd/skills/n8n/
├── README.md # Quick start guide
├── SKILL.md # Comprehensive documentation
├── CHANGELOG.md # This file
├── scripts/
│ ├── n8n_api.py # Core API client (extended)
│ ├── n8n_tester.py # NEW: Testing & validation
│ └── n8n_optimizer.py # NEW: Performance optimization
└── references/
└── api.md
```

### 🔧 Technical Improvements

- **Modular Design:** Separated concerns into specialized modules
- **Error Handling:** Comprehensive error checking and reporting
- **Import Flexibility:** Support for both direct and module imports
- **Validation Logic:** Standalone validation without API dependency
- **Performance Metrics:** Multi-dimensional workflow analysis
- **Extensible Templates:** Easy to add new workflow templates

### 📊 Metrics & Analysis

New performance metrics tracked:
- Execution success/failure rates
- Node complexity scores (0-100)
- Performance scores (0-100)
- Health status (excellent/good/fair/poor)
- Bottleneck severity levels
- Optimization priorities (high/medium/low)

### 🎯 Use Cases

The enhanced skill now supports:
1. **Rapid Prototyping:** Deploy templates and test within minutes
2. **Quality Assurance:** Validate and test before production deployment
3. **Performance Tuning:** Identify and resolve bottlenecks
4. **Continuous Monitoring:** Track workflow health over time
5. **Best Practices:** Built-in optimization recommendations

### 🔄 Migration from v1.0

No breaking changes. All v1.0 functionality preserved and enhanced:
- `list-workflows` - Still works
- `get-workflow` - Still works
- `activate` / `deactivate` - Still works
- `list-executions` / `get-execution` - Still works
- `execute` - Still works

New commands added:
- `create` - Create workflows from templates or files
- `validate` - Validate workflow structure
- `stats` - Get execution statistics

### 🐛 Bug Fixes

- Fixed import issues in testing module
- Added standalone validation for file-based workflows
- Improved error messages for missing credentials
- Enhanced connection validation logic

### ⚡ Performance

- Validation runs without API calls for file-based workflows
- Efficient execution monitoring with configurable polling
- Optimized statistics calculation for large execution histories

### 🔐 Security

- No credentials stored in templates (placeholders only)
- Environment variable-based authentication
- Validation runs safely without modifying workflows

### 📦 Dependencies

No new dependencies
- `requests` (existing)
- `json`, `sys`, `argparse`, `pathlib`, `typing` (standard library)

### 🚀 Future Roadmap

Planned for future releases:
- Additional workflow templates (10+ total)
- Workflow versioning and rollback
- A/B testing framework
- Cost tracking and optimization
- Workflow dependencies and orchestration
- Visual workflow builder web UI
- AI-powered workflow optimization
- Integration testing framework

### 👥 Contributors

- Enhanced n8n skill for Clawdbot/Thomas
- Based on requirements for SaaS automation workflows

### 📄 License

Part of the Clawdbot skills library.

---

## Version 1.0.0 - January 2026

### Initial Release

Basic n8n API integration:
- List workflows
- Get workflow details
- Activate/deactivate workflows
- List and get executions
- Manual workflow execution
- Python API client
- Basic CLI interface

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部