8
n8n 中文网amn8n.com

自动化每日加密货币市场报告 - 涨幅最大者和跌幅最大者

中级

这是一个Crypto Trading, Multimodal AI领域的自动化工作流,包含 13 个节点。主要使用 Set, Code, Cron, WhatsApp, EmailSend 等节点。 使用CoinGecko、WhatsApp和邮件提醒的每日加密货币市场报告

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "65dLT87vPoyQexup",
  "meta": {
    "instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
    "templateCredsSetupCompleted": true
  },
  "name": "自动化每日加密货币市场报告 - 涨幅最大者和跌幅最大者",
  "tags": [],
  "nodes": [
    {
      "id": "d4575dcd-57c9-4ade-9746-be644aba5443",
      "name": "每日加密货币触发器",
      "type": "n8n-nodes-base.cron",
      "position": [
        0,
        240
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 0
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "39d4dd2e-6ec8-4970-b5b1-8e9c896529ef",
      "name": "设置配置变量",
      "type": "n8n-nodes-base.set",
      "position": [
        224,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "symbols-assignment",
              "name": "vs_currency",
              "type": "string",
              "value": "usd"
            },
            {
              "id": "whatsapp-number",
              "name": "whatsapp_number",
              "type": "string",
              "value": "+919988665533"
            },
            {
              "id": "email-recipient",
              "name": "email_recipient",
              "type": "string",
              "value": "abc@gmail.com"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "eef4d478-03bd-438b-88c9-83244dd4e1d0",
      "name": "从 CoinGecko 获取加密货币数据",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        448,
        240
      ],
      "parameters": {
        "url": "=https://api.coingecko.com/api/v3/coins/markets?vs_currency={{ $json.vs_currency }}&order=market_cap_desc&per_page=100&page=1&sparkline=false&locale=en&price_change_percentage=24h",
        "options": {
          "timeout": 30000
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "29507472-9f45-4854-a25c-e0cb35136fa9",
      "name": "处理加密货币变动",
      "type": "n8n-nodes-base.code",
      "position": [
        672,
        240
      ],
      "parameters": {
        "jsCode": "// Process crypto data and calculate movements\nlet processedStocks = [];\n\n// Log the raw input for debugging\nconsole.log('Raw API Input:', JSON.stringify($input.all(), null, 2));\n\n// Aggregate data from all input items\n$input.all().forEach(item => {\n  const stockData = item.json;\n  if (stockData && stockData.name && stockData.price_change_percentage_24h !== undefined) {\n    const percentChange = parseFloat(stockData.price_change_percentage_24h);\n    const price = parseFloat(stockData.current_price);\n    const change = parseFloat(stockData.price_change_24h);\n    \n    processedStocks.push({\n      name: stockData.name,\n      symbol: stockData.symbol.toUpperCase(),\n      price: isNaN(price) ? null : price,\n      change: isNaN(change) ? null : change,\n      percent_change: isNaN(percentChange) ? null : percentChange,\n      volume: stockData.total_volume ? parseInt(stockData.total_volume) : null,\n      high: stockData.high_24h ? parseFloat(stockData.high_24h) : null,\n      low: stockData.low_24h ? parseFloat(stockData.low_24h) : null,\n      movement_type: percentChange > 0 ? 'gain' : 'loss',\n      abs_percent_change: Math.abs(percentChange)\n    });\n  }\n});\n\n// Log processed stocks for debugging\nconsole.log('Processed Stocks:', JSON.stringify(processedStocks, null, 2));\n\n// Sort by absolute percentage change (biggest movers)\nprocessedStocks.sort((a, b) => b.abs_percent_change - a.abs_percent_change);\n\n// Take top 100 biggest movers, gainers, and losers\nconst topMovers = processedStocks.slice(0, 100);\nconst gainers = processedStocks.filter(stock => stock.percent_change > 0).slice(0, 100);\nconst losers = processedStocks.filter(stock => stock.percent_change < 0).slice(0, 100);\n\n// Set current date and time in IST (02:33 PM IST, August 22, 2025)\nconst currentDate = new Date('2025-08-22T14:33:00+05:30').toLocaleString('en-IN', {\n \n  year: 'numeric',\n  month: 'long',\n  day: 'numeric'\n});\n\nreturn [{\n  json: {\n    date: currentDate, // Reflects 02:33 PM IST, August 22, 2025\n    total_stocks: processedStocks.length,\n    top_gainers: gainers,\n    top_losers: losers,\n    biggest_movers: topMovers\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "65d484f2-0da1-4fba-86b3-eef7d8c59bb4",
      "name": "格式化 WhatsApp 消息",
      "type": "n8n-nodes-base.code",
      "position": [
        896,
        144
      ],
      "parameters": {
        "jsCode": "// Generate WhatsApp message\n const data = $input.first().json;\n\nlet message = `📈 *DAILY CRYPTO MARKET REPORT*\\n`;\nmessage += `📅 Date: ${data.date}\\n`;\nmessage += `📊 Analyzed: ${data.total_stocks} cryptos\\n\\n`;\n\n// Top Gainers\nmessage += `🟢 *TOP GAINERS*\\n`;\nmessage += `━━━━━━━━━━━━━━━━━━━━\\n`;\ndata.top_gainers.forEach((stock, index) => {\n  message += `${index + 1}. ${stock.symbol}\\n`;\n  message += `   💰 $${stock.price?.toFixed(2) || 'N/A'}\\n`;\n  message += `   📈 +${stock.percent_change?.toFixed(2)}% (+$${stock.change?.toFixed(2)})\\n\\n`;\n});\n\n// Top Losers\nmessage += `🔴 *TOP LOSERS*\\n`;\nmessage += `━━━━━━━━━━━━━━━━━━━━\\n`;\ndata.top_losers.forEach((stock, index) => {\n  message += `${index + 1}. ${stock.symbol}\\n`;\n  message += `   💰 $${stock.price?.toFixed(2) || 'N/A'}\\n`;\n  message += `   📉 ${stock.percent_change?.toFixed(2)}% ($${stock.change?.toFixed(2)})\\n\\n`;\n});\n\nmessage += `\\n⚡ Generated by Crypto Alert Bot`;\n\nreturn [{ json: { whatsapp_message: message } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "337719ad-85c1-49bc-8bf9-b578f8718211",
      "name": "格式化电子邮件内容",
      "type": "n8n-nodes-base.code",
      "position": [
        896,
        336
      ],
      "parameters": {
        "jsCode": "// Generate HTML Email content\n const data = $input.first().json;\n\nlet htmlContent = `\n<!DOCTYPE html>\n<html>\n<head>\n    <style>\n        body { font-family: Arial, sans-serif; margin: 20px; background-color: #f5f5f5; }\n        .container { max-width: 800px; margin: 0 auto; background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }\n        .header { text-align: center; border-bottom: 2px solid #007bff; padding-bottom: 15px; margin-bottom: 20px; }\n        .section { margin-bottom: 30px; }\n        .stock-table { width: 100%; border-collapse: collapse; margin-top: 10px; }\n        .stock-table th, .stock-table td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }\n        .stock-table th { background-color: #f8f9fa; font-weight: bold; }\n        .gain { color: #28a745; font-weight: bold; }\n        .loss { color: #dc3545; font-weight: bold; }\n        .symbol { font-weight: bold; color: #007bff; }\n        .stats { display: flex; justify-content: space-around; background: #f8f9fa; padding: 15px; border-radius: 5px; margin-bottom: 20px; }\n        .stat-item { text-align: center; }\n        .stat-number { font-size: 24px; font-weight: bold; color: #007bff; }\n    </style>\n</head>\n<body>\n    <div class=\"container\">\n        <div class=\"header\">\n            <h1>📈 Daily Crypto Market Report</h1>\n            <p><strong>Date:</strong> ${data.date}</p>\n        </div>\n        \n        <div class=\"stats\">\n            <div class=\"stat-item\">\n                <div class=\"stat-number\">${data.total_stocks}</div>\n                <div>Cryptos Analyzed</div>\n            </div>\n            <div class=\"stat-item\">\n                <div class=\"stat-number\">${data.top_gainers.length}</div>\n                <div>Top Gainers</div>\n            </div>\n            <div class=\"stat-item\">\n                <div class=\"stat-number\">${data.top_losers.length}</div>\n                <div>Top Losers</div>\n            </div>\n        </div>\n\n        <div class=\"section\">\n            <h2 style=\"color: #28a745;\">🟢 Top Gainers</h2>\n            <table class=\"stock-table\">\n                <thead>\n                    <tr>\n                        <th>Rank</th>\n                        <th>Symbol</th>\n                        <th>Price</th>\n                        <th>Change</th>\n                        <th>% Change</th>\n                        <th>Volume</th>\n                    </tr>\n                </thead>\n                <tbody>`;\n\ndata.top_gainers.forEach((stock, index) => {\n    htmlContent += `\n                    <tr>\n                        <td>${index + 1}</td>\n                        <td class=\"symbol\">${stock.symbol}</td>\n                        <td>$${stock.price?.toFixed(2) || 'N/A'}</td>\n                        <td class=\"gain\">+$${stock.change?.toFixed(2) || 'N/A'}</td>\n                        <td class=\"gain\">+${stock.percent_change?.toFixed(2)}%</td>\n                        <td>${stock.volume?.toLocaleString() || 'N/A'}</td>\n                    </tr>`;\n});\n\nhtmlContent += `\n                </tbody>\n            </table>\n        </div>\n\n        <div class=\"section\">\n            <h2 style=\"color: #dc3545;\">🔴 Top Losers</h2>\n            <table class=\"stock-table\">\n                <thead>\n                    <tr>\n                        <th>Rank</th>\n                        <th>Symbol</th>\n                        <th>Price</th>\n                        <th>Change</th>\n                        <th>% Change</th>\n                        <th>Volume</th>\n                    </tr>\n                </thead>\n                <tbody>`;\n\ndata.top_losers.forEach((stock, index) => {\n    htmlContent += `\n                    <tr>\n                        <td>${index + 1}</td>\n                        <td class=\"symbol\">${stock.symbol}</td>\n                        <td>$${stock.price?.toFixed(2) || 'N/A'}</td>\n                        <td class=\"loss\">$${stock.change?.toFixed(2) || 'N/A'}</td>\n                        <td class=\"loss\">${stock.percent_change?.toFixed(2)}%</td>\n                        <td>${stock.volume?.toLocaleString() || 'N/A'}</td>\n                    </tr>`;\n});\n\nhtmlContent += `\n                </tbody>\n            </table>\n        </div>\n        \n        <div style=\"text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #ddd; color: #666;\">\n            <p>⚡ Generated automatically by Crypto Alert System</p>\n            <p><small>Data provided by CoinGecko API</small></p>\n        </div>\n    </div>\n</body>\n</html>`;\n\n const plainText = `\nDAILY CRYPTO MARKET REPORT\\n========================\\nDate: ${data.date}\\nCryptos Analyzed: ${data.total_stocks}\\n\\nTOP GAINERS:\\n-----------\\n${data.top_gainers.map((stock, i) => `${i+1}. ${stock.symbol}: $${stock.price?.toFixed(2)} (+${stock.percent_change?.toFixed(2)}%)`).join('\\n')}\\n\\nTOP LOSERS:\\n----------\\n${data.top_losers.map((stock, i) => `${i+1}. ${stock.symbol}: $${stock.price?.toFixed(2)} (${stock.percent_change?.toFixed(2)}%)`).join('\\n')}\\n\\nGenerated by Crypto Alert System`;\n\nreturn [{\n    json: {\n        email_html: htmlContent,\n        email_text: plainText,\n        email_subject: `📈 Daily Crypto Report - ${data.date} | Top Movers Alert`\n    }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "e66985b9-91e8-4345-994d-9713557bc7cd",
      "name": "发送电子邮件警报",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1120,
        336
      ],
      "webhookId": "cead9a3f-5f37-422c-9755-7cfbdd18193d",
      "parameters": {
        "html": "={{ $json.email_html }}",
        "options": {},
        "subject": "={{ $json.email_subject }}",
        "toEmail": "={{ $('Set Configuration Variables\t').item.json.email_recipient }}",
        "fromEmail": "alert@gmail.com",
        "emailFormat": "html"
      },
      "credentials": {
        "smtp": {
          "id": "G1kyF8cSWTZ4vouN",
          "name": "SMTP -test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "7c7f1532-ef42-4537-b9c6-5fa1834dd832",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 180,
        "height": 200,
        "content": "每天 UTC 00:00 触发。"
      },
      "typeVersion": 1
    },
    {
      "id": "60622a0b-df55-46f3-8da7-961be1d89e61",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 180,
        "height": 200,
        "content": "在此处配置电话号码和电子邮件地址"
      },
      "typeVersion": 1
    },
    {
      "id": "1a47e027-c1d2-47aa-8083-b6a8dc033b09",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 180,
        "height": 200,
        "content": "使用 CoinGecko API 获取前 100 名加密货币的 24 小时数据"
      },
      "typeVersion": 1
    },
    {
      "id": "45c9aadb-c889-4aff-bffa-8a3940d1815d",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 180,
        "height": 200,
        "content": "处理并按 24 小时最大变动对加密货币进行排名"
      },
      "typeVersion": 1
    },
    {
      "id": "dd16268b-0178-4416-ae19-bb8e4cc6b34c",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1088,
        0
      ],
      "parameters": {
        "color": 6,
        "width": 200,
        "height": 200,
        "content": "通过 WhatsApp/Telegram 和电子邮件发送带有格式化报告的警报"
      },
      "typeVersion": 1
    },
    {
      "id": "bd9244db-2652-491e-9437-7b497098ee04",
      "name": "发送消息",
      "type": "n8n-nodes-base.whatsApp",
      "position": [
        1120,
        144
      ],
      "webhookId": "d5c8ef9f-32a8-4655-8baf-e91f60b81fe2",
      "parameters": {
        "textBody": "={{ $json.whatsapp_message }}",
        "operation": "send",
        "phoneNumberId": "=+919876543234",
        "additionalFields": {},
        "recipientPhoneNumber": "={{ $('Set Configuration Variables\t').item.json.whatsapp_number }}"
      },
      "credentials": {
        "whatsAppApi": {
          "id": "b0PxTDPdWzznWnfG",
          "name": "WhatsApp-test "
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "666f2f29-90e3-4f93-9267-a32bb6e03fc3",
  "connections": {
    "Daily Crypto Trigger\t": {
      "main": [
        [
          {
            "node": "Set Configuration Variables\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Email Content\t": {
      "main": [
        [
          {
            "node": "Send Email Alert\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format WhatsApp Message\t": {
      "main": [
        [
          {
            "node": "Send message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Crypto Movements\t": {
      "main": [
        [
          {
            "node": "Format WhatsApp Message\t",
            "type": "main",
            "index": 0
          },
          {
            "node": "Format Email Content\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Configuration Variables\t": {
      "main": [
        [
          {
            "node": "Fetch Crypto Data from CoinGecko\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Crypto Data from CoinGecko\t": {
      "main": [
        [
          {
            "node": "Process Crypto Movements\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 加密货币交易, 多模态 AI

需要付费吗?

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

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

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

作者
Oneclick AI Squad

Oneclick AI Squad

@oneclick-ai

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.

外部链接
在 n8n.io 查看

分享此工作流