8
n8n 中文网amn8n.com

使用Gemini AI和CoinGecko将自动化加密市场摘要发送到Discord

高级

这是一个Crypto Trading, AI Summarization领域的自动化工作流,包含 18 个节点。主要使用 Code, Merge, Discord, Function, HttpRequest 等节点。 使用Gemini AI和CoinGecko数据的自动化加密市场摘要

前置要求
  • Discord Bot Token 或 Webhook
  • 可能需要目标 API 的认证凭证
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "vdiGM9CVl45uLWNS",
  "meta": {
    "instanceId": "c4eae34af81eeff658410c97c38d8a485e4c73ba5cea5b25eef189aa5e5a73b9",
    "templateCredsSetupCompleted": true
  },
  "name": "使用Gemini AI和CoinGecko将自动化加密市场摘要发送到Discord",
  "tags": [],
  "nodes": [
    {
      "id": "1743c462-8ac0-4fcd-8292-3044723128a9",
      "name": "每日上午8点",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -48,
        16
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f23773ff-70db-4f38-b6e0-2b059eb4631b",
      "name": "情绪数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        272,
        -80
      ],
      "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"
            },
            {
              "name": "language",
              "value": "en"
            },
            {
              "name": "sortBy",
              "value": "publishedAt"
            },
            {
              "name": "pageSize",
              "value": "10"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "dX3eyicfCIeMJzdO",
          "name": "News API"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "af2d66f9-0daf-46bf-b82e-ef39a02efb29",
      "name": "市场数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        272,
        112
      ],
      "parameters": {
        "url": "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=bitcoin,ethereum,solana",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "7a09fb3c-bd9c-4ed9-9c4a-96f65769077c",
      "name": "合并数据",
      "type": "n8n-nodes-base.code",
      "position": [
        784,
        16
      ],
      "parameters": {
        "jsCode": "// Extract merged inputs\nconst newsData = items[0].json.articles || [];\nconst marketData = items.slice(1).map(item => item.json);\n\n// Prepare clean dataset\nconst formatted = marketData.map(market => {\n  // Filter relevant articles (mentioning BTC, ETH, SOL)\n  const symbol = market.symbol.toUpperCase();\n  const relatedArticles = newsData\n    .filter(a =>\n      a.title?.toLowerCase().includes(symbol.toLowerCase()) ||\n      a.description?.toLowerCase().includes(symbol.toLowerCase())\n    )\n    .slice(0, 5) // limit to 5 for AI token efficiency\n    .map(a => ({\n      title: a.title,\n      description: a.description,\n      source: a.source?.name,\n      publishedAt: a.publishedAt,\n      url: a.url\n    }));\n\n  return {\n    symbol,\n    market_overview: {\n      current_price: market.current_price,\n      price_change_24h: market.price_change_24h,\n      price_change_percentage_24h: market.price_change_percentage_24h,\n      volume_24h: market.total_volume,\n      market_cap: market.market_cap,\n      high_24h: market.high_24h,\n      low_24h: market.low_24h\n    },\n    related_news: relatedArticles\n  };\n});\n\n// Output one item per crypto asset\nreturn formatted.map(f => ({ json: f }));"
      },
      "typeVersion": 2
    },
    {
      "id": "5145760a-c928-45fb-a236-3edd3ece1c7f",
      "name": "研究分析师",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1408,
        16
      ],
      "parameters": {
        "text": "=Analyze the following market and sentiment data, then produce a concise and insightful investment summary.\n\nMarket Data:\n{{ $json.market_overview[0] }}\n{{ $json.market_overview[1] }}\n{{ $json.market_overview[2] }}\n\nSentiment Headlines:\n{{ $json.related_news[0] }}\n{{ $json.related_news[1] }}\n{{ $json.related_news[2] }}\n{{ $json.related_news[3] }}\n\nPerform the following tasks:\n1. Summarize the overall market direction and volatility based on the price changes, highs/lows, and trading volume.\n2. Highlight the top 3 cryptocurrencies by 24h performance and describe what’s driving their movement (e.g., technical strength, on-chain trend, or narrative).\n3. Analyze sentiment — what narratives, themes, or risks dominate current discussions?\n4. Provide a short actionable takeaway (e.g., “Neutral short-term, bullish mid-term” or “High volatility ahead, watch key support zones”).\n5. Assign a **confidence score** (0–100) to your market bias based on alignment between sentiment and market data.\n\nReturn your final answer strictly in this JSON format:\n{\n  \"market_summary\": \"\",\n  \"top_coins\": [\n    {\n      \"symbol\": \"\",\n      \"performance_summary\": \"\",\n      \"driver\": \"\"\n    },\n    {\n      \"symbol\": \"\",\n      \"performance_summary\": \"\",\n      \"driver\": \"\"\n    },\n    {\n      \"symbol\": \"\",\n      \"performance_summary\": \"\",\n      \"driver\": \"\"\n    }\n  ],\n  \"sentiment_summary\": \"\",\n  \"actionable_takeaway\": \"\",\n  \"confidence_score\": \"\",\n  \"discord_message\": \"🔥 **Daily Crypto Market Briefing** 🔥\\n\\n**Market Summary:** ...\\n**Top Performers:** ...\\n**Sentiment:** ...\\n**Takeaway:** ...\\n\\nConfidence: ...\\n\\n*This is for informational purposes only and not financial advice.*\"\n}",
        "options": {
          "systemMessage": "You are a professional financial analyst with expertise in crypto fundamentals, market structure, and sentiment research.\n\nYour tone should be analytical yet engaging — like a daily market newsletter.\nYou must remain objective, concise, and data-driven.\n\nRules:\n\t•\tUse only the data provided.\n\t•\tNever speculate beyond observable data.\n\t•\tFormat clearly for readability in Discord (markdown-friendly).\n\t•\tAlways end with a one-line summary: “This is for informational purposes only, not financial advice.”\n\nYour goal: Deliver a polished, professional market insight post ready to publish to Discord."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "101175a4-e194-43dc-a679-a380c2d74175",
      "name": "发布消息",
      "type": "n8n-nodes-base.discord",
      "position": [
        2112,
        16
      ],
      "webhookId": "6e688502-6f46-476d-935b-f041687deec8",
      "parameters": {
        "content": "=🔥 **Daily Crypto Market Briefing** 🔥  \n📅 {{ $json.date || (new Date().toISOString().slice(0,10)) }}\n\n**📊 Market Summary:**  \n{{ $json.reports[0].market_summary }}\n\n**🏆 Top Coins:**  \n- **{{ $json.reports[0].top_coins[0].symbol }}** → {{ $json.reports[0].top_coins[0].performance_summary }}\n_Driver:_ {{ $json.reports[0].top_coins[0].driver }}\n- **{{ $json.reports[0].top_coins[1].symbol }}**→ {{ $json.reports[0].top_coins[1].performance_summary }}\n_Driver:_ {{ $json.reports[0].top_coins[1].driver }}\n- **{{ $json.reports[0].top_coins[2].symbol }}**→ {{ $json.reports[0].top_coins[2].performance_summary }}\n_Driver:_ {{ $json.reports[0].top_coins[2].driver }}\n\n**📰 Sentiment Overview:**  \n{{ $json.reports[0].sentiment_summary }}\n\n**💡 Takeaway:**  \n{{ $json.reports[0].actionable_takeaway }}\n\n**📈 Confidence:** {{ $json.reports[0].confidence_score }}/100\n\n---\n📢 _This is for informational purposes only, not financial advice._",
        "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": "02f04821-bcd6-4106-88a2-4b6c41fdb8d0",
      "name": "提取关键词",
      "type": "n8n-nodes-base.function",
      "position": [
        1840,
        16
      ],
      "parameters": {
        "functionCode": "// 🧠 AI Output Parser for n8n\n// Handles multiple outputs with ```json ... ``` wrappers\n\nconst parsedReports = [];\n\nfor (const item of items) {\n  const raw = item.json.output;\n  if (!raw || typeof raw !== \"string\") continue;\n\n  // Extract JSON inside ```json ... ```\n  const match = raw.match(/```json([\\s\\S]*?)```/);\n  if (!match) continue;\n\n  try {\n    const parsed = JSON.parse(match[1].trim());\n\n    // Filter out placeholder reports (no real data)\n    if (\n      parsed.market_summary &&\n      !parsed.market_summary.toLowerCase().includes(\"not provided\") &&\n      !parsed.market_summary.toLowerCase().includes(\"no market data\")\n    ) {\n      parsedReports.push(parsed);\n    }\n  } catch (err) {\n    console.error(\"❌ Failed to parse AI output:\", err.message);\n  }\n}\n\n// If no valid reports were parsed\nif (parsedReports.length === 0) {\n  return [\n    {\n      json: {\n        message: \"⚠️ No valid AI reports found.\",\n        merged_discord_message: \"⚠️ No valid AI reports found.\",\n        reports: [],\n        avg_confidence: 0\n      }\n    }\n  ];\n}\n\n// Merge reports into one summary object\nconst mergedMessage = parsedReports\n  .map(r => r.discord_message)\n  .filter(Boolean)\n  .join(\"\\n\\n---\\n\\n\");\n\nconst avgConfidence = Math.round(\n  parsedReports.reduce((sum, r) => sum + (Number(r.confidence_score) || 0), 0) /\n  parsedReports.length\n);\n\nreturn [\n  {\n    json: {\n      total_reports: parsedReports.length,\n      avg_confidence: avgConfidence,\n      merged_discord_message: mergedMessage,\n      reports: parsedReports\n    }\n  }\n];"
      },
      "typeVersion": 1
    },
    {
      "id": "ff3c7874-f1da-469d-b670-79d068ca95a8",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        624,
        16
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "25879578-b139-4395-b8d1-f4d821b0292b",
      "name": "解析数据",
      "type": "n8n-nodes-base.code",
      "position": [
        1088,
        16
      ],
      "parameters": {
        "jsCode": "const data = items.map(i => i.json);\n\nconst merged = {\n  market_overview: data.map(d => ({\n    symbol: d.symbol,\n    ...d.market_overview\n  })),\n  related_news: data.flatMap(d => \n    d.related_news.map(n => ({\n      symbol: d.symbol,\n      ...n\n    }))\n  )\n};\n\nreturn [{ json: merged }];"
      },
      "typeVersion": 2
    },
    {
      "id": "f595a543-332d-4e6d-8e2d-1352b8b1d206",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1408,
        192
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "rJzDGbm8eDazr9g5",
          "name": "Google Gemini API"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "35e848bf-1da0-43c7-a6ce-9fffb770ad2e",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -176
      ],
      "parameters": {
        "width": 256,
        "height": 432,
        "content": "### 计划触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "12d5ee8c-0a6f-4528-8b81-a094014aa3d5",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        -512
      ],
      "parameters": {
        "color": 2,
        "width": 368,
        "height": 768,
        "content": "### CoinGecko API — 市场概览"
      },
      "typeVersion": 1
    },
    {
      "id": "408b1da5-a9bd-4b08-8a4a-4f5a82d90ddf",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        -144
      ],
      "parameters": {
        "color": 3,
        "width": 432,
        "height": 400,
        "content": "### 数据合并器"
      },
      "typeVersion": 1
    },
    {
      "id": "510a7cd8-3750-4e6d-b7b1-f4aebbfde89d",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        976,
        -192
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 448,
        "content": "### 市场数据格式化器"
      },
      "typeVersion": 1
    },
    {
      "id": "cc3abf93-eb89-4d22-a7da-5dbb43206958",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1312,
        -384
      ],
      "parameters": {
        "color": 5,
        "width": 416,
        "height": 704,
        "content": "### AI市场分析师(Gemini模型)"
      },
      "typeVersion": 1
    },
    {
      "id": "be9ff135-8b9a-468d-8f1e-78a01b762e1b",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        -224
      ],
      "parameters": {
        "color": 6,
        "width": 272,
        "height": 544,
        "content": "### 市场摘要格式化器"
      },
      "typeVersion": 1
    },
    {
      "id": "037f9870-33c2-4ef7-9f73-e2af5ebb90e4",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2032,
        -224
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 544,
        "content": "### Discord自动发布器"
      },
      "typeVersion": 1
    },
    {
      "id": "7117884e-da79-465f-b006-4c8f683eb943",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2304,
        -592
      ],
      "parameters": {
        "width": 752,
        "height": 912,
        "content": "## 使用Gemini AI和CoinGecko将自动化加密市场摘要发送到Discord"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3bd52abd-c5e9-441c-b5df-53d209a2fff7",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Merge Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Data": {
      "main": [
        [
          {
            "node": "Parse Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Data": {
      "main": [
        [
          {
            "node": "Research Analyst",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Market Data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "8AM Everyday": {
      "main": [
        [
          {
            "node": "Market Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Sentiment Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sentiment Data": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Keywords": {
      "main": [
        [
          {
            "node": "Post Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Research Analyst": {
      "main": [
        [
          {
            "node": "Extract Keywords",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Research Analyst",
            "type": "ai_languageModel",
            "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 查看

分享此工作流