8
n8n 中文网amn8n.com

每日AI驱动的全球趋势分析(GDELT、NewsAPI和Discord)

高级

这是一个Market Research, AI Summarization领域的自动化工作流,包含 18 个节点。主要使用 Code, Merge, Discord, HttpRequest, Agent 等节点。 使用Gemini AI、GDELT、NewsAPI和Discord的每日全球趋势分析

前置要求
  • Discord Bot Token 或 Webhook
  • 可能需要目标 API 的认证凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "CJ1U1W5OJOhprfl5",
  "meta": {
    "instanceId": "c4eae34af81eeff658410c97c38d8a485e4c73ba5cea5b25eef189aa5e5a73b9",
    "templateCredsSetupCompleted": true
  },
  "name": "每日 AI 驱动的全球趋势分析与 GDELT、NewsAPI 和 Discord",
  "tags": [],
  "nodes": [
    {
      "id": "1938bff0-f1e4-4bf2-9b40-66bbe5335c5e",
      "name": "Hacker News(免费)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        48,
        416
      ],
      "parameters": {
        "url": "https://hn.algolia.com/api/v1/search?query=startup%20OR%20trend&tags=story&hitsPerPage=10",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "0a470151-ffe3-4cd1-a0f5-14333d7d2d5e",
      "name": "格式化趋势数据",
      "type": "n8n-nodes-base.code",
      "position": [
        608,
        416
      ],
      "parameters": {
        "jsCode": "// Combine & normalize data from GDELT, Hacker News, and NewsAPI\n\nconst mergedData = [];\n\nfor (const item of items) {\n\n  // --- GDELT ---\n  if (item.json.articles && Array.isArray(item.json.articles)) {\n    for (const article of item.json.articles) {\n      let publishedAt = '';\n\n      if (article.seendate) {\n        try {\n          // Convert 20250909T101500Z → 2025-09-09T10:15:00Z\n          const clean = article.seendate.replace(\n            /(\\d{4})(\\d{2})(\\d{2})T(\\d{2})(\\d{2})(\\d{2})Z/,\n            '$1-$2-$3T$4:$5:$6Z'\n          );\n          publishedAt = new Date(clean).toISOString();\n        } catch {\n          publishedAt = new Date().toISOString(); // fallback\n        }\n      } else {\n        publishedAt = new Date().toISOString(); // fallback for missing date\n      }\n\n      mergedData.push({\n        source: article.domain || 'GDELT',\n        title: article.title || '',\n        url: article.url || '',\n        image: article.socialimage || '',\n        publishedAt,\n        language: article.language || 'Unknown',\n        country: article.sourcecountry || 'Unknown',\n      });\n    }\n  }\n\n  // --- Hacker News ---\n  else if (item.json.hits && Array.isArray(item.json.hits)) {\n    for (const hit of item.json.hits) {\n      mergedData.push({\n        source: 'Hacker News',\n        title: hit.title || hit.story_title || '',\n        url: hit.url || hit.story_url || '',\n        image: '',\n        publishedAt: hit.created_at || new Date().toISOString(),\n        language: 'English',\n        country: 'Global',\n      });\n    }\n  }\n\n  // --- NewsAPI ---\n  else if (item.json.status === 'ok' && item.json.articles) {\n    for (const article of item.json.articles) {\n      mergedData.push({\n        source: article.source?.name || 'NewsAPI',\n        title: article.title || '',\n        url: article.url || '',\n        image: article.urlToImage || '',\n        publishedAt: article.publishedAt || new Date().toISOString(),\n        language: 'English',\n        country: '',\n      });\n    }\n  }\n}\n\n// Sort by date (newest first)\nmergedData.sort((a, b) => new Date(b.publishedAt) - new Date(a.publishedAt));\n\nreturn [\n  {\n    json: {\n      total_articles: mergedData.length,\n      extracted_at: new Date().toISOString(),\n      articles: mergedData,\n    },\n  },\n];"
      },
      "typeVersion": 1
    },
    {
      "id": "edad7cfc-30b8-4451-a95b-266d5417681c",
      "name": "解析 AI 输出",
      "type": "n8n-nodes-base.code",
      "position": [
        1360,
        416
      ],
      "parameters": {
        "jsCode": "const data = $json.output;\n\nreturn {\n  content: `🧭 **Global Trend Summary**\n${data.trend_summary}\n\n🌍 **Emerging Topics**\n${data.emerging_topics.map(t => `• ${t}`).join('\\n')}\n\n📍 **Regional Insights**\n${data.regional_insights.map(r => `- ${r}`).join('\\n')}\n\n📰 **Notable Mentions**\n${data.notable_mentions.map(n => `• *${n.title}* (${n.source})`).join('\\n')}`\n};"
      },
      "typeVersion": 1
    },
    {
      "id": "34144db3-1b89-4934-b35d-fba1b8d59476",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        352,
        400
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "48f89c07-e60c-4bf7-a333-3ce297bea0f5",
      "name": "AI 代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        896,
        416
      ],
      "parameters": {
        "text": "=You are given aggregated trend data from multiple APIs — GDELT Global Events, Hacker News, and NewsAPI.\n\nAnalyze the data and generate the following insights:\n\t1.\t📰 Top 5 Emerging Topics — Identify five recurring keywords or entities that appear across multiple sources.\n\t2.\t📈 Trend Summary — Write a concise summary (100–150 words) explaining what’s trending globally and why it matters.\n\t3.\t🌍 Regional Insights — Highlight 2–3 countries or regions showing notable activity or sentiment.\n\t4.\t🔥 Notable Mentions — List three interesting or viral article titles with their source names.\n\nUse the dataset below to extract your insights:\n{{ $json.articles }}",
        "options": {
          "systemMessage": "You are a global trend intelligence AI Agent that analyzes real-time multi-source data from news, events, and discussions.\nYour goal is to detect key insights, emerging trends, and unusual patterns from the aggregated dataset.\nFocus on clarity, synthesis, and relevance.\nAlways provide short, structured, and useful outputs that could be used in automated Telegram or Discord alerts.\nBe concise but insightful."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "bfdd1b07-2efc-4843-96f2-53f7d35e267b",
      "name": "发送消息",
      "type": "n8n-nodes-base.discord",
      "position": [
        1680,
        416
      ],
      "webhookId": "f4b13acf-2830-4265-a4df-750c59a31a35",
      "parameters": {
        "content": "={{ $json.content }}",
        "guildId": {
          "__rl": true,
          "mode": "list",
          "value": "1280652666577354803",
          "cachedResultUrl": "https://discord.com/channels/1280652666577354803",
          "cachedResultName": "Renz's server"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "1280652667408089210",
          "cachedResultUrl": "https://discord.com/channels/1280652666577354803/1280652667408089210",
          "cachedResultName": "general"
        }
      },
      "credentials": {
        "discordBotApi": {
          "id": "9ivVgYWgpq4MNHqd",
          "name": "Discord Bot Token"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "6e2ac3b5-d2c9-4ac9-97e5-28e45be4ab06",
      "name": "GDELT 全球事件",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        48,
        224
      ],
      "parameters": {
        "url": "https://api.gdeltproject.org/api/v2/doc/doc?query=crypto&format=json",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "1206f8c8-2690-4c87-a1d7-c73a447caa13",
      "name": "NewsAPI(免费)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        48,
        608
      ],
      "parameters": {
        "url": "=https://newsapi.org/v2/everything",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "q",
              "value": "crypto OR bitcoin OR ethereum OR solana OR defi OR nft OR blockchain OR web3 OR altcoin OR etf OR regulation"
            },
            {
              "name": "language",
              "value": "en"
            },
            {
              "name": "sortBy",
              "value": "publishedAt"
            },
            {
              "name": "pageSize",
              "value": "10"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "dX3eyicfCIeMJzdO",
          "name": "News API"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "18f96256-9b5f-4f96-b309-1c9a0bd30b24",
      "name": "多表:您可以连接多个表以实现有组织的数据结构",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1040,
        608
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"emerging_topics\": [\n    \"crypto regulation\",\n    \"AI funding\",\n    \"energy infrastructure\",\n    \"stablecoins\",\n    \"startup innovation\"\n  ],\n  \"trend_summary\": \"Global markets are seeing a renewed surge in crypto and AI-driven technologies. Stablecoins and digital asset regulation are trending across US and EU outlets, while emerging markets like Indonesia and UAE show major growth in digital finance adoption.\",\n  \"regional_insights\": [\n    \"UAE is positioning itself as a top crypto hub for investors.\",\n    \"Turkey and Germany show high media coverage on digital asset policies.\"\n  ],\n  \"notable_mentions\": [\n    {\n      \"title\": \"Crypto Markets Today: BTC Reclaims $111K, ETH Tops $4K After Last Week’s Sell-Off\",\n      \"source\": \"Biztoc\"\n    },\n    {\n      \"title\": \"USA Rare Earth Stock Jumps. Why This Analyst Says Buy Now\",\n      \"source\": \"Barron’s\"\n    },\n    {\n      \"title\": \"Show HN: A Tool to Analyze Hacker News Sentiment on Any Term in Seconds\",\n      \"source\": \"Hacker News\"\n    }\n  ]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "a2da9ace-be72-4606-a7e1-ea2a9cc3c2ca",
      "name": "每 6 小时",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -176,
        416
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ba6521d0-aa4a-4aad-bf35-a57cda7d5cc3",
      "name": "Google Gemini 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        896,
        608
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "rJzDGbm8eDazr9g5",
          "name": "Google Gemini API"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5e8548ef-605a-4edf-8868-6ced47b35efb",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        144
      ],
      "parameters": {
        "width": 192,
        "height": 624,
        "content": "### 计划触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "9ed12aac-21ef-41de-96d5-90fc54b59413",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -72,
        -288
      ],
      "parameters": {
        "color": 2,
        "width": 336,
        "height": 1056,
        "content": "### GDELT 全球媒体源"
      },
      "typeVersion": 1
    },
    {
      "id": "df85c7c8-343f-46b8-aff5-f6b81b074981",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        192
      ],
      "parameters": {
        "color": 3,
        "width": 246,
        "height": 576,
        "content": "### 数据合并器"
      },
      "typeVersion": 1
    },
    {
      "id": "02912617-8441-446f-a575-3d9318efc730",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        160
      ],
      "parameters": {
        "color": 4,
        "height": 608,
        "content": "### 数据规范化与结构化"
      },
      "typeVersion": 1
    },
    {
      "id": "8ea786aa-cfc4-42c9-bd20-40287e4b4101",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        -192
      ],
      "parameters": {
        "color": 5,
        "width": 448,
        "height": 960,
        "content": "### 全球趋势智能代理"
      },
      "typeVersion": 1
    },
    {
      "id": "0f01e4b5-4d8e-4849-9c45-d69556bf6f35",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        240
      ],
      "parameters": {
        "color": 6,
        "width": 320,
        "height": 528,
        "content": "### Discord 消息格式化器"
      },
      "typeVersion": 1
    },
    {
      "id": "9bc701ff-5d8e-4ca9-a85f-d111ea4ec579",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        208
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 560,
        "content": "### Discord 自动发布器"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "196f94af-b608-4e84-855c-db88a5495885",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Format Trend Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Parse AI Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every 6 Hours": {
      "main": [
        [
          {
            "node": "Hacker News (Free)",
            "type": "main",
            "index": 0
          },
          {
            "node": "NewsAPI (Free)",
            "type": "main",
            "index": 0
          },
          {
            "node": "GDELT Global Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "NewsAPI (Free)": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Parse AI Output": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Trend Data": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GDELT Global Event": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hacker News (Free)": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者

Automation expert and founder of AFK Crypto with over 5 years of experience in crypto automations.

外部链接
在 n8n.io 查看

分享此工作流