8
n8n 中文网amn8n.com

选题捕手模板

高级

这是一个Market Research, AI Summarization领域的自动化工作流,包含 34 个节点。主要使用 If, Set, Code, Gmail, Merge 等节点。 使用Gemini分析Reddit、YouTube和X生成内容策略报告

前置要求
  • Google 账号和 Gmail API 凭证
  • Twitter API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "qS9W7d2IVCxZZKaN",
  "meta": {
    "instanceId": "a912b1ffbf54f9a698ae2f03f134609ff21aef9627c34b8e5437966acbdecf88",
    "templateCredsSetupCompleted": true
  },
  "name": "选题捕手模板",
  "tags": [
    {
      "id": "yz1g2PbPKQgVLlgc",
      "name": "选题捕手",
      "createdAt": "2025-06-25T01:29:38.391Z",
      "updatedAt": "2025-06-25T01:29:38.391Z"
    }
  ],
  "nodes": [
    {
      "id": "9fed71e8-52e3-4c6e-9e95-22c387915f81",
      "name": "Apify 抓取 X 推文",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2780,
        1120
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/nfp1fpt5gUlBwPcor/run-sync-get-dataset-items",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "input",
              "value": "=={{ JSON.stringify({\n    \"queries\": [$(\"Analysis Parameters\").item.json.keyword],\n    \"tweets_desired\": 20,\n    \"proxyConfiguration\": {\n        \"useApifyProxy\": true\n    }\n}) }}"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "YTr69keQFFaEDz0m",
          "name": "My Apify API Key"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "858cf619-ed1b-4b9d-aa7d-6c99872641d5",
      "name": "ScrapingBee 抓取 X 推文",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2980,
        1120
      ],
      "parameters": {
        "url": "https://api.scrapingbee.com/api/v1",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ \"https://x.com/search?q=\" + encodeURIComponent($json.keyword) }}"
            },
            {
              "name": "render_js",
              "value": "true"
            },
            {
              "name": "wait",
              "value": "3000"
            }
          ]
        }
      },
      "credentials": {
        "httpQueryAuth": {
          "id": "cSbiAkc95apO2jUK",
          "name": "My ScrapingBee Key"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "68a4588f-9086-4974-ac6e-57c5269b801f",
      "name": "Twitter API 抓取 X 推文",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2580,
        1120
      ],
      "parameters": {
        "url": "https://api.twitterapi.io/twitter/user/last_tweets",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "userName",
              "value": "={{ $('分成多条').item.json.users }}"
            },
            {
              "name": "cursor",
              "value": "={{ $json.cursor }}"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "kAPoPiTshPILpDam",
          "name": "抓取x博主推文"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "632ab262-c571-46b7-a2af-37b7e430522b",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -2200,
        360
      ],
      "parameters": {
        "options": {},
        "batchSize": 10
      },
      "typeVersion": 3
    },
    {
      "id": "9fb2d5ce-5f69-4c22-8f3a-6b4a681ab11e",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2980,
        840
      ],
      "parameters": {
        "color": 6,
        "width": 260,
        "height": 240,
        "content": "## X 第三方抓取工具"
      },
      "typeVersion": 1
    },
    {
      "id": "40f49eac-3232-40d1-b6ad-c093d862cbbc",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2040,
        700
      ],
      "parameters": {
        "color": 6,
        "width": 220,
        "height": 140,
        "content": "## LLM 节点"
      },
      "typeVersion": 1
    },
    {
      "id": "7a0fbe60-d027-4be0-9a64-c2f652db85ed",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        220
      ],
      "parameters": {
        "color": 6,
        "content": "## URL 配置设置"
      },
      "typeVersion": 1
    },
    {
      "id": "12041c3c-5e45-4ae3-aeec-7769e9599f36",
      "name": "表单触发器",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -3340,
        300
      ],
      "webhookId": "253ac9e8-08aa-4cf5-af18-287fcb5b496b",
      "parameters": {
        "options": {},
        "formTitle": "选题捕手",
        "formFields": {
          "values": [
            {
              "fieldLabel": "keyword",
              "placeholder": "e.g.AI",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Please enter the core keywords you want to analyze, then click Submit."
      },
      "typeVersion": 2.2
    },
    {
      "id": "b6164739-04d2-48f3-a22b-d4e4e3a57c9e",
      "name": "分析参数",
      "type": "n8n-nodes-base.set",
      "position": [
        -3160,
        300
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "keyword-assignment",
              "name": "keyword",
              "type": "string",
              "value": "={{ $json.body.keyword || $json.query.keyword || 'AI' }}"
            },
            {
              "id": "date-assignment",
              "name": "search_date",
              "type": "string",
              "value": "={{ $now.toFormat('yyyy-MM-dd') }}"
            },
            {
              "id": "analysis-id",
              "name": "analysis_id",
              "type": "string",
              "value": "={{ $now.toFormat('yyyyMMddHHmmss') }}_{{ ($json.body.keyword || $json.query.keyword || 'default').replace(' ', '_') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "70bfecff-afa0-4423-810e-d570d86512fb",
      "name": "Reddit:搜索帖子",
      "type": "n8n-nodes-base.reddit",
      "position": [
        -2940,
        160
      ],
      "parameters": {
        "keyword": "={{ $('Analysis Parameters').item.json.keyword }}",
        "location": "allReddit",
        "operation": "search",
        "additionalFields": {}
      },
      "credentials": {
        "redditOAuth2Api": {
          "id": "sMlNkr0t1SHte16l",
          "name": "Reddit account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "77808c17-0b0b-4c52-a0e7-095d79de44b5",
      "name": "格式化 Reddit 数据",
      "type": "n8n-nodes-base.set",
      "position": [
        -2760,
        160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "reddit-weight",
              "name": "source_weight",
              "type": "number",
              "value": 0.7
            },
            {
              "id": "reddit-source",
              "name": "source_type",
              "type": "string",
              "value": "reddit"
            },
            {
              "id": "reddit-content",
              "name": "content",
              "type": "string",
              "value": "={{ $json.title + ' ' + ($json.selftext || '') }}"
            },
            {
              "id": "reddit-url",
              "name": "url",
              "type": "string",
              "value": "={{ $json.url }}"
            },
            {
              "id": "reddit-score",
              "name": "engagement_score",
              "type": "number",
              "value": "={{ $json.ups }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fa853181-835f-4f89-98c6-63dd093c8ac7",
      "name": "YouTube:搜索视频",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2940,
        340
      ],
      "parameters": {
        "url": "https://www.googleapis.com/youtube/v3/search",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "part",
              "value": "snippet"
            },
            {
              "name": "q",
              "value": "={{ $('Analysis Parameters').item.json.keyword }}"
            },
            {
              "name": "type",
              "value": "video"
            },
            {
              "name": "order",
              "value": "relevance"
            },
            {
              "name": "maxResults",
              "value": "15"
            },
            {
              "name": "publishedAfter",
              "value": "={{ $now.minus({days: 7}).toISO() }}"
            }
          ]
        }
      },
      "credentials": {
        "httpQueryAuth": {
          "id": "Mt9JvwGreY6YHYTr",
          "name": "My YouTube API Key"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "82c25f04-f65f-4c7e-bbf7-661ba36a9a6b",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -2760,
        340
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "items"
      },
      "typeVersion": 1
    },
    {
      "id": "224a28a8-42f0-441a-b5ba-744d327c62c0",
      "name": "X:搜索推文",
      "type": "n8n-nodes-base.twitter",
      "position": [
        -2940,
        520
      ],
      "parameters": {
        "operation": "search",
        "searchText": "={{ $json.keyword }}",
        "additionalFields": {}
      },
      "credentials": {
        "twitterOAuth2Api": {
          "id": "EqYf1S4xveBy4e6t",
          "name": "X account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "af9dbdce-c8dc-432d-8f06-a86f6110032f",
      "name": "解析 Twitter 数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -2760,
        520
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// 新代码:输出与其他平台完全一致的格式,并增加 engagement_score\ntry {\n  const tweetObject = $input.item.json;\n\n  // 从推文的公开指标(public_metrics)中计算一个综合的互动分数\n  // 同时增加安全检查,防止某些指标不存在时报错\n  const metrics = tweetObject.public_metrics || {};\n  const likeCount = metrics.like_count || 0;\n  const retweetCount = metrics.retweet_count || 0;\n  const replyCount = metrics.reply_count || 0;\n  const quoteCount = metrics.quote_count || 0;\n  const engagementScore = likeCount + retweetCount + replyCount + quoteCount;\n\n  // 构建与其他平台格式完全一致的result对象\n  const result = {\n    source_weight: 0.9,                        // 权重\n    source_type: 'twitter',                    // 来源类型\n    content: tweetObject.text,                 // 推文内容\n    url: `https://x.com/anyuser/status/${tweetObject.id}`, // 推文链接\n    engagement_score: engagementScore          // 互动分数\n  };\n\n  return { json: result };\n\n} catch (error) {\n  console.error('处理推文JSON时出错:', error);\n  return { json: { error: '处理推文JSON失败', raw_data: $input.item.json } };\n}"
      },
      "typeVersion": 2,
      "alwaysOutputData": false
    },
    {
      "id": "2a76c59f-7626-41a9-b72d-9197b1173a67",
      "name": "格式化 YouTube 数据",
      "type": "n8n-nodes-base.set",
      "position": [
        -2580,
        340
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "youtube-weight",
              "name": "source_weight",
              "type": "number",
              "value": 0.8
            },
            {
              "id": "youtube-source",
              "name": "source_type",
              "type": "string",
              "value": "youtube"
            },
            {
              "id": "youtube-content",
              "name": "content",
              "type": "string",
              "value": "={{ $json.snippet.title + ' ' + $json.snippet.description }}"
            },
            {
              "id": "youtube-url",
              "name": "url",
              "type": "string",
              "value": "=https://www.youtube.com/watch?v={{ $json.id.videoId }}"
            },
            {
              "id": "youtube-channel",
              "name": "channel",
              "type": "string",
              "value": "={{ $json.snippet.channelTitle }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "21d91bbc-8116-4c48-9f51-f81445e8684c",
      "name": "合并:所有来源",
      "type": "n8n-nodes-base.merge",
      "position": [
        -2360,
        360
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3
    },
    {
      "id": "1d5341a4-1429-4d7a-afcb-8074e43ff748",
      "name": "AI 预过滤",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -2040,
        360
      ],
      "parameters": {
        "text": "你是一位敏锐的选题策划,你的任务是为编辑发掘有潜力的内容,而不是过滤信息,同时需要【保留原始内容】。\n\n请根据给定的关键词,为每一条内容进行判断。如果内容满足【以下任一条件】,就必须标记为\"YES\",否则标记为\"NO\":\n1. 包含强烈的个人观点、情绪或独特的个人经历。\n2. 引发了争议或多人参与的讨论。\n3. 提出了一个新颖的问题或与众不同的见解。\n4. 虽然简短,但可能是一个新兴趋势或网络“梗”的苗头。\n\n你的目标是“宁滥勿缺”,只要内容有任何可能成为好选题的火花,都应标记为YES。纯粹的广告或垃圾信息才应标记为NO。\n\n你的回复必须遵循以下规则:\n1. 返回一个严格的JSON数组格式的字符串,不要包含任何markdown标记 (如```json)。\n2. 该数组的长度必须与输入数组完全一致。\n3. 数组中的每个对象都必须包含以下三个字段:\n   - `url`: 原始内容的URL。\n   - `decision`: 你的判断结果,值为 'YES' 或 'NO'。\n   - `content`: 必须原封不动地返回原始内容。\n\n示例输出格式:\n[\n  { \"url\": \"[http://example.com/article1](http://example.com/article1)\", \"decision\": \"YES\", \"content\": \"这是第一篇文章的内容...\" },\n  { \"url\": \"[http://example.com/article2](http://example.com/article2)\", \"decision\": \"NO\", \"content\": \"这是第二篇文章的内容...\" }\n]\n\n关键词: {{ $('设置分析参数').item.json.keyword }}\n\n待处理内容数组:\n{{ JSON.stringify($json.data) }}",
        "batching": {
          "batchSize": 20
        },
        "messages": {
          "messageValues": [
            {
              "message": "=关键词: {{ $('Analysis Parameters').item.json.keyword }}  待处理内容数组: {{ JSON.stringify($json) }}"
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "5198dc72-a270-453f-9e68-78204b6eb9e7",
      "name": "预过滤内容",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -2040,
        540
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "S1FgINMN5qUQ5Z61",
          "name": "n8n workflow项目2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cdc21593-af88-4d1e-8c0c-79cd831673c7",
      "name": "解析 AI 过滤结果",
      "type": "n8n-nodes-base.code",
      "position": [
        -1740,
        360
      ],
      "parameters": {
        "jsCode": "// 最终代码:在\"Run Once for All Items\"模式下,处理所有批次并返回所有结果\n\n// 1. 创建一个空数组,用来存放所有批次解析后的最终结果。\nconst allParsedItems = [];\n\n// 2. 遍历所有输入的项目(您这里的10个批次)。\n//    $input.all() 可以获取全部的输入项。\nfor (const batchItem of $input.all()) {\n  try {\n    const contentString = batchItem.json.text;\n    if (!contentString) continue; // 如果某个批次的text为空,则跳过\n\n    const cleanedContent = contentString.replace(/```json/g, '').replace(/```/g, '').trim();\n\n    // 3. 解析当前批次中的JSON字符串。\n    const itemsInBatch = JSON.parse(cleanedContent);\n\n    // 4. 将解析出的项目(一个数组)添加到我们最终的总结果数组中。\n    if (Array.isArray(itemsInBatch)) {\n      allParsedItems.push(...itemsInBatch);\n    }\n\n  } catch (error) {\n    // 如果某个批次解析失败,在控制台打印错误并继续处理下一个批次。\n    console.error(`一个批次解析失败。错误: ${error.message}. 批次内容: ${batchItem.json.text}`);\n  }\n}\n\n// 5. 循环结束后,将包含了所有结果的总数组,格式化成n8n需要的格式并返回。\nreturn allParsedItems.map(item => ({ json: item }));"
      },
      "typeVersion": 2
    },
    {
      "id": "2e736b35-d703-4ef6-9af6-1a681563f2e3",
      "name": "IF:内容是否相关",
      "type": "n8n-nodes-base.if",
      "position": [
        -1560,
        360
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "filter-condition",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.decision }}",
              "rightValue": "YES"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bb893ede-d07b-4c46-81f3-7985ab45dac4",
      "name": "处理过滤错误",
      "type": "n8n-nodes-base.code",
      "position": [
        -1340,
        520
      ],
      "parameters": {
        "jsCode": "try {\n  const errorInfo = {\n    error: '工作流执行出错',\n    timestamp: new Date().toISOString(),\n    node_error: $input.item(0).json.error || '未知错误',\n    analysis_id: $('Analysis Parameters').item.json.analysis_id || 'unknown'\n  };\n  \n  console.error('工作流错误:', errorInfo);\n  return { json: errorInfo };\n} catch (e) {\n  return { \n    json: { \n      error: '严重错误: 错误处理节点也失败了',\n      timestamp: new Date().toISOString()\n    } \n  };\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "937a9584-02d5-42b4-af30-49346f90ee0f",
      "name": "聚合:相关项",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -1340,
        240
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "191fe689-acd1-45bb-a8d4-92b88967c95a",
      "name": "AI 深度分析",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -1180,
        240
      ],
      "parameters": {
        "text": "=你是一个具备媒体素养和新闻敏感度的信息分析专家。你将收到一个 JSON 数组,每个元素包含一篇文章的内容与基础信息。请逐条进行深度结构化分析,并输出统一格式的 JSON 结果。\n\n分析目标:\n1. 提取文章的核心信息;\n2. 评估其用户情绪与传播潜力;\n3. 给出可衍生的新选题建议。\n\n请严格遵循以下输出格式,返回一个JSON字符串,不要包含任何markdown标记 (如```json):\n\n{\n  \"analyses\": [\n    {\n      \"original_url\": \"...\",\n      \"summary\": \"一句话核心摘要\",\n      \"topic\": \"文章主话题\",\n      \"sentiment\": \"positive | negative | mixed\",\n      \"key_arguments\": [\"要点A\", \"要点B\", \"要点C\"],\n      \"trending_potential\": 1-10之间的数字(基于该内容的热点潜力),\n      \"audience_interest\": 1-10之间的数字(基于普通用户的兴趣度),\n      \"news_value\": 1-10之间的数字(基于该内容的信息价值),\n      \"angle_suggestions\": [\"可衍生选题角度1\", \"可衍生选题角度2\"]\n    }\n  ]\n}\n\n请确保:\n- 分析维度客观中立。\n- 输出 JSON 严格符合格式要求。\n- 每条分析完整、无缺漏字段。\n- `original_url` 字段必须存在并且与输入内容一致。\n\n关键词: {{ $('Analysis Parameters').item.json.keyword }}\n\n待分析内容数组:\n{{ JSON.stringify($json.data) }}",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "9ca30e5e-aa64-4da4-9586-9720b23e2f65",
      "name": "深度分析",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -1180,
        400
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "LkH0TapWjEfUVaSr",
          "name": "n8n workflow api"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "606529dc-6f29-437d-be61-d74b987a37ad",
      "name": "结构化分析结果",
      "type": "n8n-nodes-base.code",
      "position": [
        -840,
        240
      ],
      "parameters": {
        "jsCode": "// 新代码:增加了清理步骤\ntry {\n  // 1. 从 'text' 字段获取AI返回的原始字符串\n  let contentString = $input.item.json.text;\n  \n  // 2. **新增的关键步骤:清理字符串,去掉AI可能添加的markdown标记**\n  contentString = contentString.replace(/```json/g, '').replace(/```/g, '').trim();\n  \n  // 3. 解析这个干净的字符串\n  const aiResults = JSON.parse(contentString);\n  \n  // 4. 从上游的\"聚合1\"节点获取原始数据项\n  const originalItems = $('Aggregate: Relevant Items').all();\n\n  // 5. 检查AI输出是否是我们期望的格式\n  if (!aiResults.analyses || !Array.isArray(aiResults.analyses)) {\n    throw new Error(\"AI output is not in the expected format: { \\\"analyses\\\": [...] }\");\n  }\n\n  // 6. 将AI分析结果与原始数据进行匹配和合并\n  const enrichedAnalyses = aiResults.analyses.map(analysis => {\n    const originalItem = originalItems.find(item => item.json.url === analysis.original_url);\n    \n    return {\n      json: {\n        ...analysis,\n        source_info: originalItem ? {\n          type: originalItem.json.source_type,\n          weight: originalItem.json.source_weight,\n          engagement_score: originalItem.json.engagement_score || 0\n        } : {\n          type: 'unknown',\n          url: analysis.original_url\n        },\n        analysis_timestamp: new Date().toISOString()\n      }\n    };\n  });\n  \n  // 7. 返回包含所有合并后结果的数组\n  return enrichedAnalyses;\n\n} catch (error) {\n  console.error('成型分析结果节点错误:', error);\n  return [{ \n    json: { \n      error: `成型分析结果失败: ${error.message}`,\n      raw_content: $input.item.json.text || 'No raw content available'\n    } \n  }];\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "1223e62f-1e4a-48cc-8f65-6daa0baf5913",
      "name": "聚合:深度分析结果",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -600,
        240
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "2b28a672-9be6-4400-9fc1-7ce546c64637",
      "name": "AI:合成最终报告",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -440,
        240
      ],
      "parameters": {
        "text": "={{ `你是一位顶级的图书编辑和内容策略师。你现在拥有 ${$json.length} 篇关于“${$('Analysis Parameters').item.json.keyword}”的高质量文章的结构化分析数据(JSON 格式)。\n\n分析数据如下:\n${JSON.stringify($json)}\n\n请基于这些数据,完成以下任务,并直接输出一份可以直接用于发送邮件的、格式优美的**HTML代码**。请使用 <h1>, <h2>, <h3>作为各级标题,使用<ul>和<li>创建列表,使用<strong>或<b> 对关键点进行加粗。请确保你的回复只包含纯粹的HTML代码,不要有任何额外的解释或Markdown标记。\n1. **聚类分析**:识别出 3-5 个最热门或最核心的讨论焦点。\n2. **趋势预测**:基于用户情绪和讨论热度,预测哪个焦点在未来最有潜力成为爆款。\n3. **选题生成**:为每个核心焦点,生成 2 个具有爆款潜力的选题。每个选题需提供:\n   - **标题 (Catchy Title)**\n   - **核心大纲 (Outline)**\n   - **关键论点 (Key Arguments)**` }}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "cae79054-712a-40eb-8792-909fc287c246",
      "name": "合成",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -440,
        420
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "S1FgINMN5qUQ5Z61",
          "name": "n8n workflow项目2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5d00f35a-4043-4d3f-a46f-058c0038ea48",
      "name": "格式化报告载荷",
      "type": "n8n-nodes-base.set",
      "position": [
        -120,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "27744290-a4c0-4afb-b948-bf19f3998b38",
              "name": "report_title",
              "type": "string",
              "value": "={{ '【' + $('Analysis Parameters').item.json.keyword + '】热点分析报告 (' + $('Analysis Parameters').item.json.search_date + ')' }}"
            },
            {
              "id": "9380ff58-c183-4f97-a588-35a7d06a8085",
              "name": "report_content",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "915a7cac-30dd-44fc-8b1b-4c5fbc29cbff",
              "name": "analysis_summary",
              "type": "string",
              "value": "={{ '本次分析共合并了 ' + $('Merge: All Sources').all().length + ' 条原始数据,筛选后深度分析了 ' + $('Aggregate: Relevant Items').item.json.data.length + ' 条高价值内容。' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8ec130d7-fcc8-4160-8c45-5bd976a4d978",
      "name": "拼接最终报告",
      "type": "n8n-nodes-base.set",
      "position": [
        120,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "76202dc1-18f1-47eb-b533-14395a4c01ab",
              "name": "final_report_text",
              "type": "string",
              "value": "={{ $json.report_title + '\\n\\n**分析概要**:\\n' + $json.analysis_summary + '\\n\\n**详细报告**:\\n' + $json.report_content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4f6d8ef7-c662-49c4-8e8a-2550366a0cd5",
      "name": "发送 HTML 报告",
      "type": "n8n-nodes-base.gmail",
      "position": [
        320,
        0
      ],
      "webhookId": "22ffd326-3962-4fa9-adf9-5580be6701a4",
      "parameters": {
        "message": "={{ $json.final_report_text }}",
        "options": {},
        "subject": "={{ $('Format Report Payloads').item.json.report_title }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "uY3e74Pt4SFoyVaW",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "7a964d92-4caa-43b0-b14a-07ee5c902201",
      "name": "发送飞书卡片",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        140,
        240
      ],
      "parameters": {
        "method": "POST",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "msg_type",
              "value": "interactive"
            },
            {
              "name": "card",
              "value": "={{\n  {\n    \"config\": {\n      \"wide_screen_mode\": true\n    },\n    \"header\": {\n      \"template\": \"blue\",\n      \"title\": {\n        \"tag\": \"plain_text\",\n        \"content\": $json.report_title\n      }\n    },\n    \"elements\": [\n      {\n        \"tag\": \"div\",\n        \"text\": {\n          \"tag\": \"lark_md\",\n          \"content\": $json.analysis_summary\n        }\n      },\n      {\n        \"tag\": \"hr\"\n      },\n      {\n        \"tag\": \"note\",\n        \"elements\": [\n          {\n            \"tag\": \"plain_text\",\n            \"content\": \"✅ 报告已生成,完整的详细报告已发送至您的Gmail邮箱。\"\n          }\n        ]\n      }\n    ]\n  }\n}}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1f3f314f-7f2d-42c8-96e0-1c7cd419e131",
      "name": "归档数据",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        140,
        480
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "uBYTAwRuGBn9fTxi",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "b74fa61d-bbc3-4487-ac13-07606b8f92a3",
  "connections": {
    "Split Out": {
      "main": [
        [
          {
            "node": "Format YouTube Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Synthesis": {
      "ai_languageModel": [
        [
          {
            "node": "AI: Synthesize Final Report",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Form Trigger": {
      "main": [
        [
          {
            "node": "Analysis Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Deep Analysis": {
      "ai_languageModel": [
        [
          {
            "node": "AI Deep Analysis",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "AI Pre-filtering",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Deep Analysis": {
      "main": [
        [
          {
            "node": "Structure Analysis Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Pre-filtering": {
      "main": [
        [
          {
            "node": "Parse AI Filter Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "X: Search Tweets": {
      "main": [
        [
          {
            "node": "Parse Twitter Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Reddit Data": {
      "main": [
        [
          {
            "node": "Merge: All Sources",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge: All Sources": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Twitter Data": {
      "main": [
        [
          {
            "node": "Merge: All Sources",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Pre-filter Content": {
      "ai_languageModel": [
        [
          {
            "node": "AI Pre-filtering",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Analysis Parameters": {
      "main": [
        [
          {
            "node": "YouTube: Search Videos",
            "type": "main",
            "index": 0
          },
          {
            "node": "Reddit: Search Posts",
            "type": "main",
            "index": 0
          },
          {
            "node": "X: Search Tweets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format YouTube Data": {
      "main": [
        [
          {
            "node": "Merge: All Sources",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Reddit: Search Posts": {
      "main": [
        [
          {
            "node": "Format Reddit Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Splicing final report": {
      "main": [
        [
          {
            "node": "Send HTML Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Report Payloads": {
      "main": [
        [
          {
            "node": "Archive Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Splicing final report",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Feishu Card",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "YouTube: Search Videos": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF: Is Content Relevant": {
      "main": [
        [
          {
            "node": "Aggregate: Relevant Items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Filter Errors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Filter Results": {
      "main": [
        [
          {
            "node": "IF: Is Content Relevant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate: Relevant Items": {
      "main": [
        [
          {
            "node": "AI Deep Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structure Analysis Result": {
      "main": [
        [
          {
            "node": "Aggregate: Deep Analysis Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI: Synthesize Final Report": {
      "main": [
        [
          {
            "node": "Format Report Payloads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate: Deep Analysis Results": {
      "main": [
        [
          {
            "node": "AI: Synthesize Final Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 市场调研, AI 摘要总结

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量34
分类2
节点类型17
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流