From 78a8352089d45f86b97a3e388f3b9cc7ffb7afd0 Mon Sep 17 00:00:00 2001 From: weishen Date: Sun, 29 Mar 2026 16:23:26 +0800 Subject: [PATCH] =?UTF-8?q?yunce:=20=E6=9B=B4=E6=96=B0v5=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=20-=20=E6=98=8E=E7=A1=AEn8n=E5=8F=AA=E8=AF=BB?= =?UTF-8?q?=E5=86=99n8n-files=EF=BC=8COpenClaw=E8=B4=9F=E8=B4=A3=E6=90=AC?= =?UTF-8?q?=E8=BF=90=E5=88=B0Obsidian?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunce/n8n-content-pipeline-workflow.md | 107 +++++++++++++++--- 1 file changed, 93 insertions(+), 14 deletions(-) diff --git a/openclaw/yunce/n8n-content-pipeline-workflow.md b/openclaw/yunce/n8n-content-pipeline-workflow.md index 3106d3f6..6755b072 100644 --- a/openclaw/yunce/n8n-content-pipeline-workflow.md +++ b/openclaw/yunce/n8n-content-pipeline-workflow.md @@ -206,9 +206,11 @@ return { **配置:** - Operation: `write` -- File Path: `={{ $json.output_path }}` +- File Path: `=/home/node/.n8n-files/{{ $json.body.output_name }}_output.md` - Content: `={{ $json.output_content }}` +**注意:** 输出到 n8n-files/ 目录,由 OpenClaw 负责复制回 Obsidian。 + --- ### 节点 7️⃣:Build HTML(新增,核心) @@ -222,8 +224,8 @@ return { 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'); +const outputName = $('Webhook Trigger').first().json.body.output_name; +const htmlPath = '/home/node/.n8n-files/' + outputName + '_output.html'; // 公众号 HTML 模板 const html = ` @@ -346,9 +348,11 @@ return { **配置:** - Operation: `write` -- File Path: `={{ $json.html_path }}` +- File Path: `=/home/node/.n8n-files/{{ $json.body.output_name }}_output.html` - Content: `={{ $json.html_content }}` +**注意:** 输出到 n8n-files/ 目录,由 OpenClaw 负责复制回 Obsidian。 + --- ### 节点 9️⃣:Send Telegram Message @@ -363,12 +367,14 @@ return { ✅ 文章转换完成! 📝 标题:{{ $json.wechat_title }} -📁 Markdown:{{ $json.output_path }} -🌐 HTML:{{ $json.html_path }} +📁 Markdown:/home/node/.n8n-files/{{ $json.body.output_name }}_output.md +🌐 HTML:/home/node/.n8n-files/{{ $json.body.output_name }}_output.html 🐦 Twitter 文案:{{ $json.twitter_copy }} ``` - Credentials: `Telegram XingJiang Bot` +**注意:** Telegram 只通知完成,OpenClaw 收到通知后负责将文件复制回 Obsidian。 + --- ## 🔗 完整节点连接图(v5) @@ -440,18 +446,87 @@ return { ## 🔄 调用方式(OpenClaw 侧) -```bash -# 1. 将文章文件复制到 n8n-files 目录 -scp /path/to/article.md macmini:/tmp/article.md +**重要说明:n8n 只能读写 `/home/node/.n8n-files/` 目录,无法直接访问 Obsidian 目录。因此 OpenClaw 负责文件搬运,n8n 专注处理。** -# 2. 触发 n8n 工作流 +### OpenClaw 完整流程: + +```bash +# ============================================= +# 步骤 1:OpenClaw 复制原文到 n8n-files 目录 +# ============================================= +# SSH 到 MacMini,将源文件复制到 n8n 容器可访问的目录 +scp /Users/weishen/Workspace/nexus/openclaw/content-queue/article-2026-03-29.md \ + macmini:/home/node/.n8n-files/article-2026-03-29.md + +# ============================================= +# 步骤 2:OpenClaw 触发 n8n Webhook +# ============================================= curl -X POST "https://n8n.ishenwei.online/webhook/content-translation-v5" \ -H "Content-Type: application/json" \ -d '{ "note_name": "article-2026-03-29.md", "source_path": "/Users/weishen/Workspace/nexus/openclaw/content-queue/article-2026-03-29.md", + "output_name": "article-2026-03-29", "callback_url": "http://192.168.3.189:18789/webhook/yunce" }' + +# ============================================= +# 步骤 3:n8n 流程执行中... +# ============================================= +# n8n 读取 /home/node/.n8n-files/article-2026-03-29.md +# 处理(翻译、改写) +# 输出到 /home/node/.n8n-files/article-2026-03-29_output.md +# 输出到 /home/node/.n8n-files/article-2026-03-29_output.html +# 发送 Telegram 通知 + +# ============================================= +# 步骤 4:OpenClaw 复制输出文件回 Obsidian(工作流完成后) +# ============================================= +# 复制 Markdown 成品 +scp macmini:/home/node/.n8n-files/article-2026-03-29_output.md \ + /Users/weishen/Workspace/nexus/openclaw/content-output/article-2026-03-29.md + +# 复制 HTML 成品 +scp macmini:/home/node/.n8n-files/article-2026-03-29_output.html \ + /Users/weishen/Workspace/nexus/openclaw/content-output/article-2026-03-29.html + +# ============================================= +# 步骤 5:清理 n8n-files 临时文件(可选) +# ============================================= +ssh macmini "rm /home/node/.n8n-files/article-2026-03-29.md \ + /home/node/.n8n-files/article-2026-03-29_output.md \ + /home/node/.n8n-files/article-2026-03-29_output.html" +``` + +### 简化版 OpenClaw 代码流程: + +```python +import subprocess + +note_name = "article-2026-03-29.md" +source_path = "/Users/weishen/Workspace/nexus/openclaw/content-queue/" + note_name +output_name = note_name.replace('.md', '') +n8n_files = "/home/node/.n8n-files" + +# 1. 复制原文到 n8n-files +subprocess.run(['scp', source_path, f'macmini:{n8n_files}/{note_name}']) + +# 2. 触发 Webhook +subprocess.run(['curl', '-X', 'POST', + 'https://n8n.ishenwei.online/webhook/content-translation-v5', + '-H', 'Content-Type: application/json', + '-d', f'{{"note_name": "{note_name}", "output_name": "{output_name}", ...}}' +]) + +# 3. 等待 Telegram 通知(工作流完成) + +# 4. 复制输出回 Obsidian +subprocess.run(['scp', + f'macmini:{n8n_files}/{output_name}_output.md', + f'/Users/weishen/Workspace/nexus/openclaw/content-output/{output_name}.md']) +subprocess.run(['scp', + f'macmini:{n8n_files}/{output_name}_output.html', + f'/Users/weishen/Workspace/nexus/openclaw/content-output/{output_name}.html']) ``` --- @@ -460,14 +535,18 @@ curl -X POST "https://n8n.ishenwei.online/webhook/content-translation-v5" \ ``` ~/Workspace/nexus/openclaw/ -├── content-queue/ # 输入 -│ └── article-2026-03-29.md # 原始英文 +├── content-queue/ # 原始英文(输入,OpenClaw 放置) +│ └── article-2026-03-29.md │ -└── content-output/ # 输出(v5 新增) - ├── article-2026-03-29.md # 中文 Markdown +└── content-output/ # 成品(OpenClaw 从 n8n-files/ 复制回来) + ├── article-2026-03-29.md # 中文 Markdown ✅ └── article-2026-03-29.html # 公众号 HTML ✅ ``` +**文件来源说明:** +- n8n 工作流只读写 `/home/node/.n8n-files/` 目录 +- OpenClaw 在工作流完成后负责将输出文件复制到 Obsidian 目录 + --- ## ✅ 验收标准