{
  "name": "AI内容日历自动化工作流",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "weeksInterval": 1,
              "triggerAtDay": [1],
              "triggerAtHour": 9
            }
          ]
        }
      },
      "name": "每周触发",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [0, 200]
    },
    {
      "parameters": {
        "url": "YOUR_RSS_FEED_URL",
        "options": {}
      },
      "name": "抓取RSS源",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1,
      "position": [240, 80]
    },
    {
      "parameters": {
        "url": "YOUR_TRENDING_API_URL",
        "options": {}
      },
      "name": "抓取热点API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [240, 200]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "add-topic",
        "options": {}
      },
      "name": "手动加选题",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [240, 320]
    },
    {
      "parameters": {
        "mode": "append",
        "options": {}
      },
      "name": "合并多源选题",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2,
      "position": [480, 200]
    },
    {
      "parameters": {
        "url": "https://api.deepseek.com/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\":\"deepseek-chat\",\"messages\":[{\"role\":\"system\",\"content\":\"你是AI内容站选题排期编辑。对每条选题输出：1)摘要80字 2)选题价值打分1-10(时效3/热度3/写作空间2/受众匹配2) 3)建议发布日期YYYY-MM-DD 4)栏目分类(hotspot/review/sop/resource/prompt/workflow) 5)建议负责人。仅输出JSON：summary,score,suggestedPublishDate,category,assignee。不编造事实\"},{\"role\":\"user\",\"content\":\"={{$json.title}} {{$json.contentSnippet || $json.content || $json.description}}\"}]}",
        "options": {}
      },
      "name": "LLM打分排期",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [720, 200]
    },
    {
      "parameters": {
        "jsCode": "const resp = JSON.parse($json.choices[0].message.content);\nconst today = new Date();\nconst pub = new Date(resp.suggestedPublishDate);\nconst diff = Math.ceil((pub - today) / 86400000);\nreturn {\n  json: {\n    title: $('合并多源选题').item.json.title,\n    summary: resp.summary,\n    score: resp.score,\n    category: resp.category,\n    suggestedPublishDate: resp.suggestedPublishDate,\n    assignee: resp.assignee || 'editor',\n    daysUntilPublish: diff,\n    status: '待写'\n  }\n};"
      },
      "name": "解析LLM结果",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [960, 200]
    },
    {
      "parameters": {
        "url": "YOUR_FEISHU_BITABLE_OR_NOTION_API_URL",
        "method": "POST",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_CALENDAR_API_TOKEN" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"fields\":{\"标题\":\"={{$json.title}}\",\"摘要\":\"={{$json.summary}}\",\"栏目\":\"={{$json.category}}\",\"发布日期\":\"={{$json.suggestedPublishDate}}\",\"状态\":\"={{$json.status}}\",\"负责人\":\"={{$json.assignee}}\"}}",
        "options": {}
      },
      "name": "写入日历表",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [1200, 200]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json.daysUntilPublish}}",
              "value2": 1,
              "operation": "smallerEqual"
            }
          ]
        }
      },
      "name": "判断临近发布",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [1440, 200]
    },
    {
      "parameters": {
        "url": "YOUR_FEISHU_OR_SLACK_WEBHOOK_URL",
        "method": "POST",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"msg_type\":\"text\",\"content\":{\"text\":\"明天要发：{{$('解析LLM结果').item.json.title}}\\n栏目：{{$('解析LLM结果').item.json.category}}\\n发布日期：{{$('解析LLM结果').item.json.suggestedPublishDate}}\\n负责人：{{$('解析LLM结果').item.json.assignee}}\"}}",
        "options": {}
      },
      "name": "通知负责人",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [1680, 120]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "cms-publish-callback",
        "options": {}
      },
      "name": "CMS发布回调",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [1440, 380]
    },
    {
      "parameters": {
        "url": "YOUR_CALENDAR_API_URL",
        "method": "PATCH",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            { "name": "Authorization", "value": "Bearer YOUR_CALENDAR_API_TOKEN" },
            { "name": "Content-Type", "value": "application/json" }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"fields\":{\"状态\":\"已发布\"}}",
        "options": {}
      },
      "name": "状态回写已发布",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [1680, 380]
    }
  ],
  "connections": {
    "每周触发": {
      "main": [
        [ { "node": "抓取RSS源", "type": "main", "index": 0 } ],
        [ { "node": "抓取热点API", "type": "main", "index": 0 } ]
      ]
    },
    "抓取RSS源": {
      "main": [
        [ { "node": "合并多源选题", "type": "main", "index": 0 } ]
      ]
    },
    "抓取热点API": {
      "main": [
        [ { "node": "合并多源选题", "type": "main", "index": 0 } ]
      ]
    },
    "手动加选题": {
      "main": [
        [ { "node": "合并多源选题", "type": "main", "index": 1 } ]
      ]
    },
    "合并多源选题": {
      "main": [
        [ { "node": "LLM打分排期", "type": "main", "index": 0 } ]
      ]
    },
    "LLM打分排期": {
      "main": [
        [ { "node": "解析LLM结果", "type": "main", "index": 0 } ]
      ]
    },
    "解析LLM结果": {
      "main": [
        [ { "node": "写入日历表", "type": "main", "index": 0 } ]
      ]
    },
    "写入日历表": {
      "main": [
        [ { "node": "判断临近发布", "type": "main", "index": 0 } ]
      ]
    },
    "判断临近发布": {
      "main": [
        [ { "node": "通知负责人", "type": "main", "index": 0 } ],
        []
      ]
    },
    "CMS发布回调": {
      "main": [
        [ { "node": "状态回写已发布", "type": "main", "index": 0 } ]
      ]
    }
  }
}
