简介
将 N8N/Zapier/Make 工作流迁移至企业级 Python/Node.js 脚本,消除订阅成本并增强可观测性。
原始描述
Migrate N8N/Zapier/Make workflows to production-grade Python or Node.js scripts. Given a workflow description or paste, rewrites automation logic with retry,...
通过你的 Agent 添加
安装目录:workflow-migrate/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
workflow-migrate 用于将低代码自动化平台(N8N、Zapier、Make)的工作流转换为可版本控制、可独立运行的生产级脚本。用户通过粘贴工作流 JSON、步骤描述或直接输入自然语言描述触发迁移,工具自动解析触发器、动作链、数据流,并生成完整的可执行代码。
显著优点
- 成本归零:彻底消除 $50-500/月的 SaaS 订阅费用
- 工程化增强:原生支持指数退避重试、结构化日志、故障自愈(告警、死信队列、幂等性)
- 可控可测:提供
--dry-run模式,支持本地调试与 CI/CD 集成 - 交付标准化:自动生成
.env.example、requirements.txt/package.json、README.md,复杂场景额外生成SKILL.md - 双向兼容:Python(默认)与 Node.js 双栈支持,智能匹配异步场景
潜在缺点与局限性
- 手动解析风险:非标准 JSON 或模糊描述需人工澄清 2-3 个问题
- 专有节点限制:N8N 原生封装节点(如 OpenAI 节点)需降级为原始 HTTP API 调用,增加开发复杂度
- 规模阈值:超过 15 节点的复杂工作流需拆分为多脚本协调架构,学习成本上升
- 运维责任转移:脱离托管平台后,监控、日志轮转、宿主机维护由用户承担
- Webhook 额外工作:触发方式为 Webhook 时需自建 Flask/Express 端点,非开箱即用
适合人群
- 希望脱离低代码平台锁定、具备基础开发能力的工程师
- 需要版本控制、代码审查、自动化测试的企业团队
- 月自动化任务量高、SaaS 账单敏感的成长型公司
- 追求故障自愈与可观测性的运维导向用户
常规风险
- 凭证泄露:
.env文件若未纳入.gitignore易造成密钥泄漏 - 状态文件丢失:幂等性依赖的本地状态文件(
processed_ids.json)若未持久化可能导致重复处理 - 重试风暴:下游 API 限流配置不当可能引发级联故障
- 日志磁盘占满:未配置日志轮转策略的长期运行实例存在磁盘耗尽风险
- 时区/调度漂移:
node-cron/schedule依赖系统时间,容器化部署需确保 TZ 正确
技能正文
name: workflow-migrate description: Migrate N8N/Zapier/Make workflows to production-grade Python or Node.js scripts. Given a workflow description or paste, rewrites automation logic with retry, backoff, logging, and self-healing. Billable migration deliverable. argument-hint: [workflow description, or paste workflow JSON/steps, or type "paste" to describe inline] allowed-tools: Read, Write, Edit, Bash, Glob, Grep, WebSearch
Workflow Migrate — Automation Migration Tool
Why This Exists
N8N/Zapier/Make workflows break silently, can't be version-controlled, and cost $50-500/month in SaaS fees. This skill rewrites them as standalone scripts that run forever with zero subscription cost. Each migration is a $500-5000 billable deliverable.
Trigger
Use when: "migrate this workflow", "convert N8N to Python", "rewrite my Zapier", "turn this automation into a script", "get off N8N"
Invoked as: /workflow-migrate [workflow description or paste]
Process
Step 1: Parse the Workflow Input
From $ARGUMENTS:
- If it's a description ("when a form is submitted, send email and update Airtable"): parse directly
- If it's N8N JSON: read and extract nodes/connections
- If it's Zapier steps: parse the trigger + action chain
- If it's Make (formerly Integromat) scenario: parse modules
Extract and document:
Triggers:
- Webhook (POST endpoint)
- Cron/schedule (every X minutes/hours)
- Form submission
- Email received
- File drop (S3, Google Drive, local folder)
- DB row created/updated
Actions:
- HTTP/API calls (list each endpoint, method, payload)
- Database reads/writes
- Email sends
- File operations
- Conditional logic (if/else branches)
- Loops over arrays
- Data transformations
Data flow:
- Input payload fields used
- Intermediate computed values
- Output destinations
If the workflow description is too vague, ask 2-3 targeted questions before proceeding:
- "What triggers it — webhook, schedule, or something else?"
- "Which API endpoints does it call and with what data?"
- "What counts as success? What should happen on failure?"
Step 2: Choose Language
Default to Python unless:
- The workflow is heavily async/event-driven (prefer Node.js)
- Existing codebase is Node.js
- Kevin explicitly requests Node
Python stack: requests, schedule, logging, tenacity (retry), python-dotenv
Node.js stack: axios, node-cron, winston, async-retry, dotenv
Step 3: Write the Script
Generate a complete, runnable script. Required elements:
Python Template Structure:
#!/usr/bin/env python3
"""
[Workflow Name] — Migrated from [N8N/Zapier/Make]
Original: [brief description of what the workflow did]
Migrated: [date]
Usage:
python workflow_[name].py # run once
python workflow_[name].py --schedule # run on schedule
python workflow_[name].py --dry-run # test without side effects
"""
import os
import sys
import logging
import time
import argparse
from datetime import datetime
from typing import Optional, Dict, Any
import requests
from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type
from dotenv import load_dotenv
load_dotenv()
# ─── Logging ───────────────────────────────────────────────────────────────────
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
handlers=[
logging.StreamHandler(sys.stdout),
logging.FileHandler(f"logs/workflow_{datetime.now().strftime('%Y%m')}.log"),
]
)
log = logging.getLogger(__name__)
# ─── Config ────────────────────────────────────────────────────────────────────
API_KEY = os.getenv("API_KEY") # from .env
WEBHOOK_URL = os.getenv("WEBHOOK_URL") # destination
DRY_RUN = False
# ─── Retry Decorator ───────────────────────────────────────────────────────────
@retry(
stop=stop_after_attempt(3),
wait=wait_exponential(multiplier=1, min=2, max=30),
retry=retry_if_exception_type((requests.RequestException, ConnectionError)),
before_sleep=lambda rs: log.warning(f"Retrying (attempt {rs.attempt_number})..."),
reraise=True
)
def api_call(method: str, url: str, **kwargs) -> Dict[str, Any]:
"""Make an HTTP call with automatic retry and exponential backoff."""
if DRY_RUN:
log.info(f"[DRY RUN] {method.upper()} {url} payload={kwargs.get('json', {})}")
return {"dry_run": True}
resp = requests.request(method, url, timeout=30, **kwargs)
resp.raise_for_status()
return resp.json()
Node.js Template Structure:
#!/usr/bin/env node
/**
* [Workflow Name] — Migrated from [N8N/Zapier/Make]
* Original: [brief description]
* Migrated: [date]
*
* Usage:
* node workflow_[name].js # run once
* node workflow_[name].js --schedule # run on schedule
* node workflow_[name].js --dry-run # test without side effects
*/
require('dotenv').config();
const axios = require('axios');
const retry = require('async-retry');
const cron = require('node-cron');
const winston = require('winston');
const fs = require('fs');
// ─── Logger ────────────────────────────────────────────────────────────────────
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(winston.format.timestamp(), winston.format.json()),
transports: [
new winston.transports.Console({ format: winston.format.simple() }),
new winston.transports.File({ filename: `logs/workflow_${new Date().toISOString().slice(0,7)}.log` }),
],
});
// ─── Config ────────────────────────────────────────────────────────────────────
const API_KEY = process.env.API_KEY;
const DRY_RUN = process.argv.includes('--dry-run');
// ─── Retry Wrapper ─────────────────────────────────────────────────────────────
async function apiCall(method, url, data = {}, headers = {}) {
return retry(async (bail, attempt) => {
if (DRY_RUN) {
logger.info(`[DRY RUN] ${method.toUpperCase()} ${url}`, { data });
return { dry_run: true };
}
try {
const resp = await axios({ method, url, data, headers, timeout: 30000 });
return resp.data;
} catch (err) {
if (err.response && err.response.status < 500) bail(err); // 4xx = don't retry
logger.warn(`Retrying attempt ${attempt}...`, { error: err.message });
throw err;
}
}, { retries: 3, minTimeout: 2000, maxTimeout: 30000, factor: 2 });
}
For each action in the workflow, write a dedicated function:
- One function per logical action (e.g.,
fetch_leads(),send_notification(),update_database()) - Functions are composable and testable in isolation
- Every function logs what it's doing: start, result, any errors
Main orchestrator:
def run(dry_run: bool = False):
global DRY_RUN
DRY_RUN = dry_run
log.info("=== Workflow started ===")
try:
# Step 1: [action name]
data = fetch_source_data()
log.info(f"Fetched {len(data)} records")
# Step 2: [action name]
for item in data:
result = process_item(item)
if result:
send_to_destination(result)
log.info("=== Workflow completed successfully ===")
except Exception as e:
log.error(f"Workflow failed: {e}", exc_info=True)
send_alert(f"Workflow [name] failed: {e}") # self-healing alert
raise
Self-healing patterns to include:
- Alert on failure (Telegram message via Kevin's bot token if available, else log to file)
- Idempotency: skip already-processed records (use a state file or DB flag)
- Dead-letter queue: failed items saved to
failed_[date].jsonfor manual review - Heartbeat: log "still alive" every N runs for scheduled workflows
Step 4: Generate .env.example
# [Workflow Name] — Environment Variables
# Copy to .env and fill in values
API_KEY=your_api_key_here
WEBHOOK_URL=https://...
DATABASE_URL=...
# Optional: Telegram alerts on failure
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=8062428674
Step 5: Generate requirements.txt or package.json
Python:
requests>=2.31.0
tenacity>=8.2.0
python-dotenv>=1.0.0
schedule>=1.2.0 # only if cron-triggered
Node.js:
{
"dependencies": {
"axios": "^1.6.0",
"async-retry": "^1.3.3",
"node-cron": "^3.0.3",
"winston": "^3.11.0",
"dotenv": "^16.3.1"
}
}
Step 6: If the Workflow is Recurring — Generate a SKILL.md
If the workflow runs on a schedule or will be reused:
- Generate a
SKILL.mdin the same output directory - Name it after the workflow function
- Description: "Run [workflow name] — [what it does in 10 words]"
- Instructions: path to script, how to run it, what env vars are needed
Step 7: Save Outputs and Print Migration Summary
Output location: Ask Kevin where to save, default to ./workflow_[name]/
Create:
workflow_[name].py(or.js).env.examplerequirements.txt(orpackage.json)SKILL.md(if recurring)README.md(quick usage guide — 20 lines max)
Print migration summary:
Migration complete.
Original: [N8N/Zapier/Make] workflow — [X] nodes/steps
Output: ./workflow_[name]/workflow_[name].py
What changed:
- [X] N8N nodes → [Y] lines of Python
- Added: retry with exponential backoff (3 attempts, 2s-30s)
- Added: rotating log file (monthly)
- Added: dry-run mode (--dry-run flag)
- Added: failure alerts via [Telegram/log]
- Removed: $XX/month SaaS subscription
To run:
cd workflow_[name]/
cp .env.example .env # fill in your keys
pip install -r requirements.txt
python workflow_[name].py --dry-run # test first
python workflow_[name].py # run for real
Error Handling
- Ambiguous workflow: ask 2-3 targeted questions, don't guess at API endpoints
- Proprietary N8N nodes (e.g., OpenAI node): rewrite using the raw API — include API docs link in comments
- Very complex workflow (>15 nodes): break into multiple scripts with a coordinator, document the dependency order
- No credentials visible: generate .env.example with clear placeholders, add comments explaining where each key comes from
- Webhook trigger: generate a Flask/Express endpoint stub that receives the webhook and calls the workflow function
Notes
- Always test with
--dry-runbefore running for real - State file for idempotency:
./state/processed_ids.json— createstate/dir if it doesn't exist - For scheduled runs, prefer
cron/scheduleover external task runners (fewer dependencies)
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。