{
  "name": "SEO内容生产工作流",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            { "field": "cronExpression", "expression": "0 9 * * *" }
          ]
        }
      },
      "name": "每天9点触发",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [0, 0]
    },
    {
      "parameters": {
        "url": "YOUR_RSS_FEED_URL_1",
        "options": {}
      },
      "name": "抓取RSS源A",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1,
      "position": [220, -120]
    },
    {
      "parameters": {
        "url": "YOUR_RSS_FEED_URL_2",
        "options": {}
      },
      "name": "抓取RSS源B",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1,
      "position": [220, 120]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            { "name": "topic_payload", "value": "={{$json.title}}\n{{$json.contentSnippet}}\n{{$json.link}}" },
            { "name": "source_url", "value": "={{$json.link}}" }
          ]
        }
      },
      "name": "选题合并去重",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [440, 0]
    },
    {
      "parameters": {
        "url": "https://api.moonshot.cn/v1/chat/completions",
        "method": "POST",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_LLM_API_KEY" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"model\":\"moonshot-v1-8k\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"你是资深SEO内容编辑。对每条选题按搜索潜力(1-4)/时效(1-3)/可操作性(1-3)打1-10分。仅输出JSON：score,action(write或pool),focus_keyword,reason,category(review|sop|hotspot|resource)。score>=7时action为write否则pool。不编造搜索量,信息不足标待补充\"},{\"role\":\"user\",\"content\":\"={{$json.topic_payload}}\"}]}",
        "options": {}
      },
      "name": "LLM选题打分",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [660, 0]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            { "value1": "={{JSON.parse($json.choices[0].message.content).action}}", "value2": "write" }
          ]
        }
      },
      "name": "选题分流",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [880, 0]
    },
    {
      "parameters": {
        "url": "https://api.moonshot.cn/v1/chat/completions",
        "method": "POST",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_LLM_API_KEY" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"model\":\"moonshot-v1-32k\",\"temperature\":0.3,\"messages\":[{\"role\":\"system\",\"content\":\"你是资深内容写手。按结构出1500-2500字初稿：1)开头钩子用场景或数据切入 2)3-4个H2小节配实操步骤 3)结尾总结+引导。引用要真实,不可编造论文或链接,无把握就不引。仅输出Markdown正文\"},{\"role\":\"user\",\"content\":\"选题：{{$node[\\\"选题合并去重\\\"].json.topic_payload}}\\n主关键词：{{JSON.parse($json.choices[0].message.content).focus_keyword}}\"}]}",
        "options": {}
      },
      "name": "LLM写作",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [1100, -120]
    },
    {
      "parameters": {
        "url": "https://api.moonshot.cn/v1/chat/completions",
        "method": "POST",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_LLM_API_KEY" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"model\":\"moonshot-v1-8k\",\"temperature\":0,\"messages\":[{\"role\":\"system\",\"content\":\"你是SEO专家。基于初稿生成发布元数据。输出JSON：title(<=60字符含主关键词前置),meta_description(<=155字符含主关键词+号召),focus_keyword,long_tail_keywords(5-8个),slug(kebab英文),faq(3-5条问答),json_ld(FAQPage JSON-LD字符串),quality(pass或rewrite)。quality规则:字数>=1500且标题<=60且主词在首段为pass否则rewrite。标题别堆砌,meta要读得通顺\"},{\"role\":\"user\",\"content\":\"={{$json.choices[0].message.content}}\"}]}",
        "options": {}
      },
      "name": "SEO优化",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [1320, -120]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            { "value1": "={{JSON.parse($json.choices[0].message.content).quality}}", "value2": "pass" }
          ]
        }
      },
      "name": "质量校验",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [1540, -120]
    },
    {
      "parameters": {
        "url": "YOUR_CMS_API_URL",
        "method": "POST",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_CMS_API_TOKEN" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"title\":\"{{JSON.parse($json.choices[0].message.content).title}}\",\"content\":\"{{$node[\\\"LLM写作\\\"].json.choices[0].message.content}}\",\"slug\":\"{{JSON.parse($json.choices[0].message.content).slug}}\",\"meta_description\":\"{{JSON.parse($json.choices[0].message.content).meta_description}}\",\"focus_keyword\":\"{{JSON.parse($json.choices[0].message.content).focus_keyword}}\",\"json_ld\":\"{{JSON.parse($json.choices[0].message.content).json_ld}}\",\"status\":\"draft\"}",
        "options": {}
      },
      "name": "发布到CMS",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [1760, -240]
    },
    {
      "parameters": {
        "url": "YOUR_FEISHU_OR_NOTION_API_URL",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{$json.choices[0].message.content}}",
        "options": {}
      },
      "name": "存档选题池",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [1100, 120]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            { "name": "status", "value": "rewrite_needed" }
          ]
        }
      },
      "name": "标记重写",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [1760, 0]
    }
  ],
  "connections": {
    "每天9点触发": { "main": [ [{ "node": "抓取RSS源A", "type": "main", "index": 0 }], [{ "node": "抓取RSS源B", "type": "main", "index": 0 }] ] },
    "抓取RSS源A": { "main": [ [{ "node": "选题合并去重", "type": "main", "index": 0 }] ] },
    "抓取RSS源B": { "main": [ [{ "node": "选题合并去重", "type": "main", "index": 0 }] ] },
    "选题合并去重": { "main": [ [{ "node": "LLM选题打分", "type": "main", "index": 0 }] ] },
    "LLM选题打分": { "main": [ [{ "node": "选题分流", "type": "main", "index": 0 }] ] },
    "选题分流": { "main": [ [{ "node": "LLM写作", "type": "main", "index": 0 }], [{ "node": "存档选题池", "type": "main", "index": 0 }] ] },
    "LLM写作": { "main": [ [{ "node": "SEO优化", "type": "main", "index": 0 }] ] },
    "SEO优化": { "main": [ [{ "node": "质量校验", "type": "main", "index": 0 }] ] },
    "质量校验": { "main": [ [{ "node": "发布到CMS", "type": "main", "index": 0 }], [{ "node": "标记重写", "type": "main", "index": 0 }] ] }
  }
}
