Files
nexus/openclaw/yunce/n8n-content-pipeline-workflow.md
weishen f9e2b4dcf7 云策:同步全部文档到专属笔记目录 (2026-03-29)
- AGENTS.md, MEMORY.md, SOUL.md, IDENTITY.md, USER.md, TOOLS.md
- LEARNINGS.md, n8n-content-pipeline-workflow.md
- 星枢-Agent任务解耦方案.md
2026-03-29 12:28:53 +08:00

368 lines
9.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# N8N 内容转化流水线工作流设计
> 用于AI 英文文章 → 中文公众号/X/视频 内容转化
> 触发方式OpenClaw 通过 Webhook 调用
> 管理平台Mac mini 上的 n8n
---
## 📋 工作流概述
```
OpenClaw (发现文章)
↓ (保存 Obsidian)
↓ (触发 Webhook)
┌─────────────────────────────────────────────────────────────┐
│ N8N 工作流: content-translation-pipeline │
│ │
│ [Webhook] → [Read Obsidian] → [AI 翻译改写] → [配图搜索] │
│ ↓ │
│ [写回 Obsidian] → [通知 OpenClaw] │
└─────────────────────────────────────────────────────────────┘
```
---
## 🔌 节点详细设计
### 节点 1Webhook Trigger触发器
**类型:** Webhook
**名称:** `webhook_trigger`
**配置:**
- Method: POST
- Path: `/content-translation`
- Authentication: None内部网络调用
**接收数据格式:**
```json
{
"note_path": "/Users/weishen/Workspace/nexus/openclaw/content-queue/2026-03-29-ai-solopreneur.md",
"source_url": "https://original-article-url",
"action": "translate",
"platforms": ["wechat", "twitter", "video"],
"callback_url": "http://192.168.3.189:18789/webhook/yunce"
}
```
**输出:** 向下游节点传递完整 payload
---
### 节点 2Read Obsidian Note读取原文笔记
**类型:** HTTP Request调用 Obsidian Local REST API 插件)
**名称:** `read_obsidian_note`
**配置:**
- Method: GET
- URL: `http://localhost:27123/vault/{{ $json.note_path }}`
- Headers:
- `Content-Type: application/json`
**备选方案(如果没有 Obsidian REST API**
使用 n8n Filesystem 节点直接读取文件路径。
**输出变量:**
- `original_title`(原文标题)
- `original_content`(原文内容)
- `source_url`(文章来源)
- `tags`(标签)
---
### 节点 3AI 翻译与本土化(核心节点)
**类型:** AI Agentn8n 内置)
**名称:** `translate_and_adapt`
**配置:**
- Provider: OpenAI / Claude通过环境变量配置
- Model: gpt-4o 或 claude-3-5-sonnet
**Prompt 模板:**
```
你是一个专业的中文内容编辑,擅长将英文文章转化为适合中国读者的高质量内容。
## 你的任务
将以下英文原文转化为:
1. 公众号风格的深度文章2000-3000字
2. X/Twitter 风格的短文案280字内带钩子
3. 视频口播脚本3-5分钟适合抖音/YouTube
## 内容要求
- 语言:地道中文,无翻译腔
- 风格:专业、有干货、适合中国读者
- 调性公众号大V风格有观点有案例
- 商业化:可自然植入 AI Agent / 知识管理相关内容(软性,不硬广)
## 文章主题方向(供校准时参考)
- AI Agent 落地实践与工具推荐
- AI 赋能商业的最佳实践
- AI 时代的网络安全与运维
## 输出格式(严格按此 JSON 返回)
{
"wechat_title": "中文标题",
"wechat_excerpt": "公众号摘要100字内",
"wechat_content": "完整公众号文章Markdown格式",
"twitter_copy": "X/Twitter文案280字内带emoji",
"video_title": "视频标题",
"video_script": "口播脚本(含时间戳和字幕)",
"cover_keywords": ["关键词1", "关键词2", "关键词3"]
}
## 原文内容
{{ $json.original_content }}
```
**输出变量:**
- `wechat_title`
- `wechat_excerpt`
- `wechat_content`
- `twitter_copy`
- `video_title`
- `video_script`
- `cover_keywords[]`
---
### 节点 4搜索封面图
**类型:** HTTP Request
**名称:** `search_cover_image`
**配置:**
- Method: GET
- URL: `https://api.unsplash.com/search/photos`
- Query Parameters:
- `query`: 第一张封面图关键词(取 cover_keywords[0]
- `per_page`: 1
- `orientation`: landscape
- Headers:
- `Authorization`: `Client-ID {{ $env.UNSPLASH_API_KEY }}`
**备选:** Pexels API如果用 Pexels
**备选:** 直接用搜索引擎图片 API
**输出变量:**
- `cover_image_url`
- `cover_image_credit`(图片来源归因)
---
### 节点 5构建 Obsidian 成品笔记
**类型:** Code数据转换
**名称:** `build_output_note`
**功能:** 将 AI 输出组装成 Obsidian 笔记的 Markdown 内容
**输出内容:**
```markdown
---
source: {{ source_url }}
title: {{ wechat_title }}
excerpt: {{ wechat_excerpt }}
cover_image: {{ cover_image_url }}
date: {{ current_date }}
tags: [ai-agent, translated, ready-to-publish]
status: ready-to-publish
platforms:
- wechat
- twitter
- video
---
# {{ wechat_title }}
{{ wechat_content }}
---
## X/Twitter 文案
{{ twitter_copy }}
---
## 视频信息
**标题:** {{ video_title }}
**口播脚本:**
{{ video_script }}
---
*封面图来源:{{ cover_image_credit }}*
```
**输出变量:**
- `output_note_path`: `原笔记路径``output/成品笔记文件名.md`
- `output_content`: Markdown 内容
---
### 节点 6写回 Obsidian保存成品
**类型:** HTTP RequestPOST 到 Obsidian REST API
**名称:** `write_obsidian_note`
**配置:**
- Method: PUT 或 POST
- URL: `http://localhost:27123/vault/{{ $json.output_note_path }}`
- Body: `{{ $json.output_content }}`
- Headers:
- `Content-Type: text/markdown`
**备选方案:** Filesystem Write 节点直接写文件
---
### 节点 7通知 OpenClaw回调
**类型:** HTTP Request
**名称:** `notify_openclaw`
**配置:**
- Method: POST
- URL: `{{ $json.callback_url }}`
- Body:
```json
{
"status": "completed",
"input_note": "{{ $json.input_note_path }}",
"output_note": "{{ $json.output_note_path }}",
"wechat_title": "{{ $json.wechat_title }}",
"twitter_copy": "{{ $json.twitter_copy }}",
"video_title": "{{ $json.video_title }}",
"cover_image": "{{ $json.cover_image_url }}"
}
```
---
### 节点 8Error Handler错误处理
**类型:** Error Trigger全局
**名称:** `error_handler`
**功能:**
- 捕获任意节点错误
- 发送错误通知到 OpenClaw
- 记录错误日志
---
## 🔗 完整节点连接图
```
┌─────────────────┐
│ Webhook │ (接收 OpenClaw 调用)
│ webhook_trigger│
└────────┬────────┘
┌─────────────────┐
│ Read Obsidian │ (读取原始笔记)
│ read_obsidian │
└────────┬────────┘
┌─────────────────┐
│ AI Agent │ (翻译+改写+脚本)
│ translate_ │
│ and_adapt │
└────────┬────────┘
┌─────────────────┐
│ Search Image │ (Unsplash API)
│ search_cover │
└────────┬────────┘
┌─────────────────┐
│ Code │ (组装 Markdown)
│ build_output │
└────────┬────────┘
┌─────────────────┐
│ Write Obsidian │ (保存成品笔记)
│ write_note │
└────────┬────────┘
┌─────────────────┐
│ HTTP Request │ (回调 OpenClaw)
│ notify_openclaw│
└─────────────────┘
```
---
## 🔧 环境变量要求
```bash
# n8n 所在服务器环境变量
export OPENAI_API_KEY="sk-..." # AI 翻译用
export UNSPLASH_API_KEY="..." # 图片搜索用
export OBSIDIAN_VAULT_PATH="/Users/weishen/Workspace/nexus"
```
---
## 📁 Obsidian 目录结构
```
nexus/
├── openclaw/
│ ├── content-queue/ # 原始文章待处理
│ │ └── 2026-03-29-ai-solopreneur.md
│ └── content-output/ # 成品输出
│ └── 2026-03-29-ai-solopreneur-translated.md
```
---
## 🔄 调用方式OpenClaw 侧)
```bash
# 触发 n8n 工作流
curl -X POST "http://macmini.local:5678/webhook/content-translation" \
-H "Content-Type: application/json" \
-d '{
"note_path": "/Users/weishen/Workspace/nexus/openclaw/content-queue/2026-03-29-ai-solopreneur.md",
"source_url": "https://original-article-url",
"action": "translate",
"platforms": ["wechat", "twitter", "video"],
"callback_url": "http://192.168.3.189:18789/webhook/yunce"
}'
```
---
## ✅ 验收标准
1. Webhook 被调用后,整个流程自动完成
2. 成品笔记包含所有字段(标题、摘要、正文、推文、脚本、封面图)
3. OpenClaw 收到完成回调
4. 任意节点失败时,错误被捕获并通知
---
## 📝 后续扩展方向Phase 2
- 加入人工审核节点(审批后再发布)
- 加入多语言支持(英文 + 中文)
- 加入视频字幕生成Whisper API
- 加入定时调度(自动抓取 RSS → 自动翻译)