8
n8n 中文网amn8n.com

Bright Data关键词邮件新闻简报与AI摘要

中级

这是一个AI, Marketing领域的自动化工作流,包含 13 个节点。主要使用 If, Code, Wait, Markdown, EmailSend 等节点,结合人工智能技术实现智能自动化。 Bright Data关键词邮件新闻简报与AI摘要

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "71eb5622cf8abac565805540c0900dbae437dddbda45bf1b87bf3bfeea26393c"
  },
  "nodes": [
    {
      "id": "78600483-749e-452c-a1e0-cde275f2656c",
      "name": "快照进度",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        220,
        0
      ],
      "parameters": {
        "url": "=https://api.brightdata.com/datasets/v3/progress/{{ $('HTTP Request- Post API call to Bright Data').item.json.snapshot_id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2dbd6ad2-bcd7-4753-a150-6a4bff419d76",
      "name": "HTTP 请求 - 向 Bright Data 发送 API 调用",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -280,
        260
      ],
      "parameters": {
        "url": "https://api.brightdata.com/datasets/v3/trigger",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "keyword",
              "value": "={{ $json[\"Keyword\"] }}"
            },
            {
              "name": "sort",
              "value": "relevance"
            }
          ]
        },
        "queryParameters": {
          "parameters": [
            {
              "name": "dataset_id",
              "value": "gd_lyptx9h74wtlvpnfu"
            },
            {
              "name": "type",
              "value": "discover_new"
            },
            {
              "name": "discover_by",
              "value": "keyword"
            },
            {
              "name": "include_errors",
              "value": "true"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "dfd7a841-be32-4ea4-954c-95e24b6bb46a",
      "name": "等待 - 轮询 Bright Data",
      "type": "n8n-nodes-base.wait",
      "position": [
        0,
        0
      ],
      "webhookId": "8005a2b3-2195-479e-badb-d90e4240e699",
      "parameters": {
        "amount": 15
      },
      "executeOnce": false,
      "typeVersion": 1.1
    },
    {
      "id": "f9f032aa-5128-4705-94ab-af93965159fb",
      "name": "条件判断 - 检查快照状态 - 数据是否就绪",
      "type": "n8n-nodes-base.if",
      "position": [
        440,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7932282b-71bb-4bbb-ab73-4978e554de7e",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "running"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e5b658cd-c7df-4b17-ac1d-378cd58a1197",
      "name": "HTTP 请求 - 从 Bright Data 获取数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        660,
        0
      ],
      "parameters": {
        "url": "=https://api.brightdata.com/datasets/v3/snapshot/{{ $json.snapshot_id }}",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "format",
              "value": "json"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d2aa4201-f58c-4d63-81ae-ebb721297c31",
      "name": "当用户完成表单时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -500,
        260
      ],
      "webhookId": "41d0bffa-f5ca-4df7-b757-ca5a1e472b8a",
      "parameters": {
        "options": {
          "ignoreBots": true
        },
        "formTitle": "Search from Reuters by keyword",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Keyword",
              "placeholder": "e.g. \"energy shutdown\"",
              "requiredField": true
            }
          ]
        },
        "responseMode": "lastNode",
        "formDescription": "Provide a keyword to search and summarize relevant news"
      },
      "typeVersion": 2.2
    },
    {
      "id": "f45da408-0497-45ad-ace6-bef91660f8b3",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -340,
        440
      ],
      "parameters": {
        "height": 220,
        "content": "## 注意"
      },
      "typeVersion": 1
    },
    {
      "id": "9038d986-d23a-4f83-87c0-9ce213aa7021",
      "name": "代码 - 解析和清理 JSON 数据",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        0
      ],
      "parameters": {
        "language": "python",
        "pythonCode": "from datetime import datetime\n\nall_news = _input.all()\n\nvalid_news = []\nfor item in all_news:\n    news = item.json\n    date_str = news.get(\"publication_date\")\n    try:\n        date = datetime.strptime(date_str, \"%Y-%m-%dT%H:%M:%S.%fZ\")\n        valid_news.append((date, news))\n    except (TypeError, ValueError):\n        continue\n\nsorted_news = sorted(valid_news, key=lambda x: x[0], reverse=True)\n\ncleaned = []\nfor _, c in sorted_news[:10]:\n    topics = c.get(\"topics\") or []\n\n    cleaned.append({\n        \"headline\": c.get(\"headline\"),\n        \"url\": c.get(\"url\"),\n        \"author\": c.get(\"author\"),\n        \"publication_date\": c.get(\"publication_date\"),\n        \"type\": c.get(\"type\"),\n        \"content\": c.get(\"content\"),\n        \"keyword\": c.get(\"keyword\"),\n        \"topics\": \", \".join(topics)\n    })\n\nreturn [{\n    \"json\": {\n        \"news\": cleaned\n    }\n}]\n"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "21f43041-f540-4158-a23d-648921ac3cac",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        660,
        440
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash"
      },
      "typeVersion": 1
    },
    {
      "id": "90b674c1-c8f4-4256-b27c-999ea1d93ee6",
      "name": "邮件报告",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1480,
        260
      ],
      "webhookId": "1e6e9588-2bc6-4f05-8531-2d7ca8348d0c",
      "parameters": {
        "html": "={{ $json.html }}",
        "options": {},
        "subject": "=Your N8N report about Reuters News by keyword: {{ $('When User Completes Form').first().json['Keyword']}}",
        "toEmail": "your-mail@gmail.com",
        "fromEmail": "n8n-mail@example.com"
      },
      "typeVersion": 2.1
    },
    {
      "id": "53fc100e-a4ee-4d91-9b75-af96b6ba0fcd",
      "name": "Markdown",
      "type": "n8n-nodes-base.markdown",
      "position": [
        1040,
        260
      ],
      "parameters": {
        "mode": "markdownToHtml",
        "options": {},
        "markdown": "={{ $json.text }}",
        "destinationKey": "html"
      },
      "typeVersion": 1
    },
    {
      "id": "ba02c4c2-5b52-409b-9d83-d69ab9d762fd",
      "name": "代码 - 构建 HTML",
      "type": "n8n-nodes-base.code",
      "position": [
        1260,
        260
      ],
      "parameters": {
        "jsCode": "const rawHtml = $json.html;\n\nreturn [{\n  json: {\n    html: `\n      <html>\n        <head>\n          <style>\n            body { font-family: Arial, sans-serif; line-height: 1.5; font-size: 15px; }\n            h1, h2, h3 { color: #333; }\n            a { color: #1a73e8; text-decoration: none; }\n            ul { padding-left: 20px; }\n            li { margin-bottom: 6px; }\n          </style>\n        </head>\n        <body>\n          ${rawHtml}\n        </body>\n      </html>\n    `\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "a3241735-79ca-49ca-aebb-8b17b3ef9ad4",
      "name": "Google Gemini - 摘要分析",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        660,
        260
      ],
      "parameters": {
        "text": "={{$json}}",
        "messages": {
          "messageValues": [
            {
              "message": "=You are tasked with creating a news briefing. I will supply latest news articles about [keyword] which is interesting to user.\n\nYour goal is to produce a consolidated summary that captures the essence of these reports. Focus on:\n- What are the most important events, announcements, or findings?\n- Are there any recurring themes or common threads across the articles?\n- What is the overall sentiment or implication, if discernible from the facts presented?\n\nBe sure that every news article you are analyzing is closely related to [keyword]. Otherwise, skip it.\nProvide a brief, integrated summary.\nAlways include date range (from - to) about these news and use source links when mention exact news topics.\nThe [keyword] user requested initially: {{ $('When User Completes Form').first().json['Keyword']}}.\nDon't start your answer with 'Okay'."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    }
  ],
  "pinData": {},
  "connections": {
    "Markdown": {
      "main": [
        [
          {
            "node": "Code - Build HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code - Build HTML": {
      "main": [
        [
          {
            "node": "Email Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Snapshot Progress": {
      "main": [
        [
          {
            "node": "If - Checking status of Snapshot - if data is ready or not",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Google Gemini - Summary Analisys",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When User Completes Form": {
      "main": [
        [
          {
            "node": "HTTP Request- Post API call to Bright Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait - Polling Bright Data": {
      "main": [
        [
          {
            "node": "Snapshot Progress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code - Parse and Clean JSON Data": {
      "main": [
        [
          {
            "node": "Google Gemini - Summary Analisys",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini - Summary Analisys": {
      "main": [
        [
          {
            "node": "Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request- Post API call to Bright Data": {
      "main": [
        [
          {
            "node": "Wait - Polling Bright Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request - Getting data from Bright Data": {
      "main": [
        [
          {
            "node": "Code - Parse and Clean JSON Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If - Checking status of Snapshot - if data is ready or not": {
      "main": [
        [
          {
            "node": "Wait - Polling Bright Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request - Getting data from Bright Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 人工智能, 营销

需要付费吗?

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

工作流信息
难度等级
中级
节点数量13
分类2
节点类型10
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

外部链接
在 n8n.io 查看

分享此工作流