diff --git a/openclaw/yunce/n8n-content-pipeline-workflow.md b/openclaw/yunce/n8n-content-pipeline-workflow.md index c12c60c2..3106d3f6 100644 --- a/openclaw/yunce/n8n-content-pipeline-workflow.md +++ b/openclaw/yunce/n8n-content-pipeline-workflow.md @@ -1,16 +1,38 @@ -# N8N 内容转化流水线工作流设计(v4) +# N8N 内容转化流水线工作流设计(v4 → v5 升级) > 用于:AI 英文文章 → 中文公众号/X/视频 内容转化 -> 工作流ID:`iOf32aOKvTjfTDSM` +> 工作流ID:`iOf32aOKvTjfTDSM`(v4基础) > 触发方式:OpenClaw 通过 Webhook 调用 > 管理平台:Mac mini 上的 n8n (`https://n8n.ishenwei.online`) --- -## 📋 工作流概述 +## 📋 核心需求更新(v5) -**当前活跃版本:** v1 (`xQDabttYmLaY8qtr`) / v3 (`tOGMiC6qOJPOY89E`) -**最新开发版本:** v4 (`iOf32aOKvTjfTDSM`) — 未激活 +### 输出要求(重要!) + +**必须同时输出两个版本:** + +| 输出文件 | 路径 | 格式 | 用途 | +|---------|------|------|------| +| **Markdown 源文件** | `content-output/{原文件名}.md` | 中文 Markdown | Obsidian 留存、溯源 | +| **公众号 HTML** | `content-output/{原文件名}.html` | 带样式的 HTML | 直接复制到公众号编辑器 | + +### Obsidian 目录结构 + +``` +~/Workspace/nexus/openclaw/ +├── content-queue/ # 原始英文文章(输入) +│ └── 2026-03-29-ai-solopreneur.md +│ +└── content-output/ # 成品(输出) + ├── 2026-03-29-ai-solopreneur.md # 翻译后 Markdown + └── 2026-03-29-ai-solopreneur.html # 公众号 HTML(新增) +``` + +--- + +## 📋 工作流概述 ``` OpenClaw (发现文章) @@ -18,35 +40,36 @@ OpenClaw (发现文章) ↓ (触发 Webhook) ┌─────────────────────────────────────────────────────────────┐ -│ N8N 工作流 (v4): content-translation-pipeline-v4 │ +│ N8N 工作流 (v5): content-translation-pipeline-v5 │ │ │ │ [Webhook] → [Read File] → [Extract Text] → [AI Agent] │ -│ ↓ ↑ (DeepSeek) │ -│ [Convert to File] → [Write File] → [Send Telegram] │ +│ ↓ ↑ (DeepSeek) │ +│ [Build Markdown] → [Write .md] → [Build HTML] → [Write .html] │ +│ ↓ │ +│ [Send Telegram] │ └─────────────────────────────────────────────────────────────┘ ``` --- -## 🔌 节点详细设计(v4) +## 🔌 节点详细设计(v5) ### 节点 1️⃣:Webhook Trigger **类型:** Webhook **名称:** `Webhook Trigger` -**Path:** `/content-translation-v4` +**Path:** `/content-translation-v5`(新建 path) **Method:** POST **接收数据格式:** ```json { - "note_name": "article-2026-03-29.md", + "note_name": "2026-03-29-ai-solopreneur.md", + "source_path": "/Users/weishen/Workspace/nexus/openclaw/content-queue/2026-03-29-ai-solopreneur.md", "callback_url": "http://192.168.3.189:18789/webhook/yunce" } ``` -**注意:** v4 使用 `note_name`(文件名)而非 `note_path`,文件需预先上传到 n8n 容器的 `/home/node/.n8n-files/` 目录。 - --- ### 节点 2️⃣:Read Obsidian Note @@ -56,9 +79,6 @@ OpenClaw (发现文章) **配置:** - File Path: `=/home/node/.n8n-files/{{ $json.body.note_name }}` -- n8n 容器内文件路径: `/home/node/.n8n-files/` - -**输出:** 二进制文件数据,传递给 Extract from File 节点 --- @@ -68,33 +88,23 @@ OpenClaw (发现文章) **名称:** `Extract from File` **Operation:** `text` -**功能:** 从二进制文件提取文本内容 - -**输出变量:** -- `original_content`(原文内容) -- `note_name`(文件名) -- `callback_url`(回调地址) +**输出:** +```json +{ + "original_content": "...", + "note_name": "2026-03-29-ai-solopreneur.md", + "source_path": "/Users/weishen/Workspace/nexus/openclaw/content-queue/..." +} +``` --- -### 节点 4️⃣:DeepSeek Chat Model - -**类型:** LM Chat DeepSeek -**名称:** `DeepSeek Chat Model` - -**配置:** -- Model: `deepseek-chat` -- Credentials: `DeepSeek account`(在 n8n 中配置) - -**连接:** → AI Agent(作为 languageModel 输入) - ---- - -### 节点 5️⃣:AI Agent +### 节点 4️⃣:AI Agent(翻译+改写) **类型:** LangChain Agent **名称:** `AI Agent` **Version:** 3.1 +**Model:** DeepSeek Chat Model **Prompt 模板:** ``` @@ -137,58 +147,242 @@ OpenClaw (发现文章) --- -### 节点 6️⃣:Convert to File +### 节点 5️⃣:Build Markdown(新增) -**类型:** Convert to File -**名称:** `Convert to File` -**Operation:** `toJson` +**类型:** Code +**名称:** `Build Markdown` -**功能:** 将 AI Agent 输出转换为 JSON 格式文件 +**功能:** 将 AI 输出组装成 Markdown 文件 + +```javascript +const aiResult = $input.first().json.message; +const data = typeof aiResult === 'string' ? JSON.parse(aiResult) : aiResult; + +const noteName = $('Webhook Trigger').first().json.body.note_name; +// 去掉 .md 后缀,输出到 content-output +const outputName = noteName.replace('.md', '.md'); +const outputPath = '/Users/weishen/Workspace/nexus/openclaw/content-output/' + outputName; + +const markdown = `# ${data.wechat_title} + +${data.wechat_content} --- -### 节点 7️⃣:Read/Write Files from Disk +## X/Twitter 文案 -**类型:** Read/Write File -**名称:** `Read/Write Files from Disk` -**Operation:** `write` +${data.twitter_copy} + +--- + +## 视频信息 + +**标题:** ${data.video_title} + +**口播脚本:** + +${data.video_script} + +--- + +*封面图关键词:${data.cover_keywords?.join(', ')}* +`; + +return { + json: { + output_path: outputPath, + output_content: markdown, + source_path: $('Webhook Trigger').first().json.body.source_path + } +}; +``` + +--- + +### 节点 6️⃣:Write .md File(新增) + +**类型:** Write Binary File / ReadWriteFile +**名称:** `Write Markdown Note` **配置:** -- File Name: `=/home/node/.n8n-files/{{ $('Webhook Trigger').item.json.body.note_name }}_output.md` - -**输出变量:** -- `output_file_name` -- `output_content` +- Operation: `write` +- File Path: `={{ $json.output_path }}` +- Content: `={{ $json.output_content }}` --- -### 节点 8️⃣:Send Telegram Message +### 节点 7️⃣:Build HTML(新增,核心) + +**类型:** Code +**名称:** `Build WeChat HTML` + +**功能:** 将 Markdown 转为带样式的公众号 HTML + +```javascript +const aiResult = $input.first().json.message; +const data = typeof aiResult === 'string' ? JSON.parse(aiResult) : aiResult; + +const noteName = $('Webhook Trigger').first().json.body.note_name; +const htmlPath = '/Users/weishen/Workspace/nexus/openclaw/content-output/' + noteName.replace('.md', '.html'); + +// 公众号 HTML 模板 +const html = ` + +
+ + + + + +${line}
`; +}).join('\n')} + +