yunce: 更新v5工作流 - 明确n8n只读写n8n-files,OpenClaw负责搬运到Obsidian
This commit is contained in:
@@ -206,9 +206,11 @@ return {
|
|||||||
|
|
||||||
**配置:**
|
**配置:**
|
||||||
- Operation: `write`
|
- Operation: `write`
|
||||||
- File Path: `={{ $json.output_path }}`
|
- File Path: `=/home/node/.n8n-files/{{ $json.body.output_name }}_output.md`
|
||||||
- Content: `={{ $json.output_content }}`
|
- Content: `={{ $json.output_content }}`
|
||||||
|
|
||||||
|
**注意:** 输出到 n8n-files/ 目录,由 OpenClaw 负责复制回 Obsidian。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### 节点 7️⃣:Build HTML(新增,核心)
|
### 节点 7️⃣:Build HTML(新增,核心)
|
||||||
@@ -222,8 +224,8 @@ return {
|
|||||||
const aiResult = $input.first().json.message;
|
const aiResult = $input.first().json.message;
|
||||||
const data = typeof aiResult === 'string' ? JSON.parse(aiResult) : aiResult;
|
const data = typeof aiResult === 'string' ? JSON.parse(aiResult) : aiResult;
|
||||||
|
|
||||||
const noteName = $('Webhook Trigger').first().json.body.note_name;
|
const outputName = $('Webhook Trigger').first().json.body.output_name;
|
||||||
const htmlPath = '/Users/weishen/Workspace/nexus/openclaw/content-output/' + noteName.replace('.md', '.html');
|
const htmlPath = '/home/node/.n8n-files/' + outputName + '_output.html';
|
||||||
|
|
||||||
// 公众号 HTML 模板
|
// 公众号 HTML 模板
|
||||||
const html = `<!DOCTYPE html>
|
const html = `<!DOCTYPE html>
|
||||||
@@ -346,9 +348,11 @@ return {
|
|||||||
|
|
||||||
**配置:**
|
**配置:**
|
||||||
- Operation: `write`
|
- Operation: `write`
|
||||||
- File Path: `={{ $json.html_path }}`
|
- File Path: `=/home/node/.n8n-files/{{ $json.body.output_name }}_output.html`
|
||||||
- Content: `={{ $json.html_content }}`
|
- Content: `={{ $json.html_content }}`
|
||||||
|
|
||||||
|
**注意:** 输出到 n8n-files/ 目录,由 OpenClaw 负责复制回 Obsidian。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### 节点 9️⃣:Send Telegram Message
|
### 节点 9️⃣:Send Telegram Message
|
||||||
@@ -363,12 +367,14 @@ return {
|
|||||||
✅ 文章转换完成!
|
✅ 文章转换完成!
|
||||||
|
|
||||||
📝 标题:{{ $json.wechat_title }}
|
📝 标题:{{ $json.wechat_title }}
|
||||||
📁 Markdown:{{ $json.output_path }}
|
📁 Markdown:/home/node/.n8n-files/{{ $json.body.output_name }}_output.md
|
||||||
🌐 HTML:{{ $json.html_path }}
|
🌐 HTML:/home/node/.n8n-files/{{ $json.body.output_name }}_output.html
|
||||||
🐦 Twitter 文案:{{ $json.twitter_copy }}
|
🐦 Twitter 文案:{{ $json.twitter_copy }}
|
||||||
```
|
```
|
||||||
- Credentials: `Telegram XingJiang Bot`
|
- Credentials: `Telegram XingJiang Bot`
|
||||||
|
|
||||||
|
**注意:** Telegram 只通知完成,OpenClaw 收到通知后负责将文件复制回 Obsidian。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🔗 完整节点连接图(v5)
|
## 🔗 完整节点连接图(v5)
|
||||||
@@ -440,18 +446,87 @@ return {
|
|||||||
|
|
||||||
## 🔄 调用方式(OpenClaw 侧)
|
## 🔄 调用方式(OpenClaw 侧)
|
||||||
|
|
||||||
```bash
|
**重要说明:n8n 只能读写 `/home/node/.n8n-files/` 目录,无法直接访问 Obsidian 目录。因此 OpenClaw 负责文件搬运,n8n 专注处理。**
|
||||||
# 1. 将文章文件复制到 n8n-files 目录
|
|
||||||
scp /path/to/article.md macmini:/tmp/article.md
|
|
||||||
|
|
||||||
# 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" \
|
curl -X POST "https://n8n.ishenwei.online/webhook/content-translation-v5" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
"note_name": "article-2026-03-29.md",
|
"note_name": "article-2026-03-29.md",
|
||||||
"source_path": "/Users/weishen/Workspace/nexus/openclaw/content-queue/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"
|
"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/
|
~/Workspace/nexus/openclaw/
|
||||||
├── content-queue/ # 输入
|
├── content-queue/ # 原始英文(输入,OpenClaw 放置)
|
||||||
│ └── article-2026-03-29.md # 原始英文
|
│ └── article-2026-03-29.md
|
||||||
│
|
│
|
||||||
└── content-output/ # 输出(v5 新增)
|
└── content-output/ # 成品(OpenClaw 从 n8n-files/ 复制回来)
|
||||||
├── article-2026-03-29.md # 中文 Markdown
|
├── article-2026-03-29.md # 中文 Markdown ✅
|
||||||
└── article-2026-03-29.html # 公众号 HTML ✅
|
└── article-2026-03-29.html # 公众号 HTML ✅
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**文件来源说明:**
|
||||||
|
- n8n 工作流只读写 `/home/node/.n8n-files/` 目录
|
||||||
|
- OpenClaw 在工作流完成后负责将输出文件复制到 Obsidian 目录
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## ✅ 验收标准
|
## ✅ 验收标准
|
||||||
|
|||||||
Reference in New Issue
Block a user