8
n8n 中文网amn8n.com

实时加密货币价格监控器和智能告警

高级

这是一个Crypto Trading, Multimodal AI领域的自动化工作流,包含 16 个节点。主要使用 If, Code, Cron, Discord, Telegram 等节点。 CoinGecko和多渠道警报的实时加密货币价格监控器

前置要求
  • Discord Bot Token 或 Webhook
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "gpZ5gnZftZFQDQK4",
  "meta": {
    "instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
    "templateCredsSetupCompleted": true
  },
  "name": "实时加密货币价格监控器和智能告警",
  "tags": [],
  "nodes": [
    {
      "id": "a74647d9-e5d4-4593-acc8-60b9d5dc0453",
      "name": "24/7 加密货币触发器",
      "type": "n8n-nodes-base.cron",
      "position": [
        -432,
        832
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "29541d43-fc8a-45c8-8911-b97ab3e4c080",
      "name": "读取加密货币观察列表",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -208,
        832
      ],
      "parameters": {
        "options": {},
        "sheetName": "Sheet1",
        "documentId": "YOUR_GOOGLE_SHEET_ID_HERE",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "ScSS2KxGQULuPtdy",
          "name": "Google Sheets- test"
        }
      },
      "typeVersion": 4
    },
    {
      "id": "af441c6d-0034-4d39-9ff1-60e9c56b8c01",
      "name": "解析加密货币数据",
      "type": "n8n-nodes-base.code",
      "position": [
        16,
        832
      ],
      "parameters": {
        "jsCode": "// Parse Google Sheets data and prepare for crypto API calls\nconst items = [];\nconst inputData = $input.all();\n\n// Skip header row, process data rows\nfor (let i = 1; i < inputData.length; i++) {\n  const row = inputData[i].json;\n  if (row.A && row.B && row.C) { // Check if required fields exist\n    \n    // Convert crypto symbol to CoinGecko format\n    let coinId = row.A.toLowerCase();\n    \n    // Handle common crypto pairs and convert to CoinGecko IDs\n    const cryptoMapping = {\n      'btc': 'bitcoin',\n      'btc/usdt': 'bitcoin',\n      'btc-usdt': 'bitcoin',\n      'bitcoin': 'bitcoin',\n      'eth': 'ethereum', \n      'eth/usdt': 'ethereum',\n      'eth-usdt': 'ethereum',\n      'ethereum': 'ethereum',\n      'bnb': 'binancecoin',\n      'bnb/usdt': 'binancecoin',\n      'bnb-usdt': 'binancecoin',\n      'ada': 'cardano',\n      'ada/usdt': 'cardano',\n      'ada-usdt': 'cardano',\n      'dot': 'polkadot',\n      'dot/usdt': 'polkadot',\n      'dot-usdt': 'polkadot',\n      'sol': 'solana',\n      'sol/usdt': 'solana',\n      'sol-usdt': 'solana',\n      'matic': 'matic-network',\n      'matic/usdt': 'matic-network',\n      'matic-usdt': 'matic-network',\n      'link': 'chainlink',\n      'link/usdt': 'chainlink',\n      'link-usdt': 'chainlink',\n      'avax': 'avalanche-2',\n      'avax/usdt': 'avalanche-2',\n      'avax-usdt': 'avalanche-2'\n    };\n    \n    const mappedCoinId = cryptoMapping[coinId] || coinId.split('/')[0].split('-')[0];\n    \n    items.push({\n      json: {\n        original_symbol: row.A,\n        coin_id: mappedCoinId,\n        upper_limit: parseFloat(row.B),\n        lower_limit: parseFloat(row.C),\n        direction: row.D || 'both',\n        cooldown_minutes: parseInt(row.E) || 10, // Shorter cooldown for crypto\n        last_alert_price: parseFloat(row.F) || 0,\n        last_alert_time: row.G || ''\n      }\n    });\n  }\n}\n\nreturn items;"
      },
      "typeVersion": 2
    },
    {
      "id": "ed3d40dc-fafe-4226-bb92-7e4f512594ae",
      "name": "获取实时加密货币价格",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        240,
        832
      ],
      "parameters": {
        "url": "=https://api.coingecko.com/api/v3/simple/price?ids={{ $json.coin_id }}&vs_currencies=usd&include_24hr_change=true&include_market_cap=true",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          }
        }
      },
      "typeVersion": 4.1
    },
    {
      "id": "571a5ffa-c589-4988-a985-e01a6b6d3c8d",
      "name": "智能加密货币告警逻辑",
      "type": "n8n-nodes-base.code",
      "position": [
        464,
        832
      ],
      "parameters": {
        "jsCode": "// Process crypto price and check alerts\nconst items = [];\nconst currentTime = new Date();\n\nfor (const item of $input.all()) {\n  const cryptoData = item.json;\n  \n  let priceResponse;\n  try {\n    priceResponse = JSON.parse(cryptoData.body || '{}');\n  } catch (e) {\n    continue; // Skip if invalid JSON\n  }\n  \n  const coinId = cryptoData.coin_id;\n  const coinPriceData = priceResponse[coinId];\n  \n  if (!coinPriceData || !coinPriceData.usd) {\n    continue; // Skip if no price data\n  }\n  \n  const currentPrice = parseFloat(coinPriceData.usd);\n  const change24h = coinPriceData.usd_24h_change || 0;\n  const marketCap = coinPriceData.usd_market_cap || 0;\n  \n  const symbol = cryptoData.original_symbol;\n  const upperLimit = cryptoData.upper_limit;\n  const lowerLimit = cryptoData.lower_limit;\n  const direction = cryptoData.direction;\n  const cooldownMinutes = cryptoData.cooldown_minutes;\n  const lastAlertPrice = cryptoData.last_alert_price;\n  const lastAlertTime = cryptoData.last_alert_time;\n  \n  // Check cooldown period\n  let shouldCheckAlert = true;\n  if (lastAlertTime) {\n    const lastAlert = new Date(lastAlertTime);\n    const timeDiff = (currentTime - lastAlert) / (1000 * 60); // minutes\n    if (timeDiff < cooldownMinutes) {\n      shouldCheckAlert = false;\n    }\n  }\n  \n  let alertTriggered = false;\n  let alertMessage = '';\n  let alertType = '';\n  \n  if (shouldCheckAlert) {\n    // Check upper limit (BREAKOUT)\n    if ((direction === 'both' || direction === 'above') && currentPrice > upperLimit) {\n      alertTriggered = true;\n      alertType = 'upper';\n      const pumpPercentage = ((currentPrice - upperLimit) / upperLimit * 100).toFixed(2);\n      alertMessage = `🚀 CRYPTO BREAKOUT ALERT! 🚀\\n\\n` +\n                    `💎 ${symbol.toUpperCase()}\\n` +\n                    `📈 Current Price: $${currentPrice.toLocaleString()}\\n` +\n                    `🎯 Upper Target: $${upperLimit.toLocaleString()}\\n` +\n                    `⚡ Pump: +${pumpPercentage}% above target!\\n` +\n                    `📊 24h Change: ${change24h >= 0 ? '+' : ''}${change24h.toFixed(2)}%\\n` +\n                    `💰 Market Cap: $${(marketCap / 1000000000).toFixed(2)}B\\n` +\n                    `⏰ ${currentTime.toLocaleString()}\\n\\n` +\n                    `🔥 BULLISH MOMENTUM DETECTED! 🔥`;\n    }\n    // Check lower limit (BREAKDOWN) \n    else if ((direction === 'both' || direction === 'below') && currentPrice < lowerLimit) {\n      alertTriggered = true;\n      alertType = 'lower';\n      const dumpPercentage = ((lowerLimit - currentPrice) / lowerLimit * 100).toFixed(2);\n      alertMessage = `📉 CRYPTO BREAKDOWN ALERT! 📉\\n\\n` +\n                    `💎 ${symbol.toUpperCase()}\\n` +\n                    `📉 Current Price: $${currentPrice.toLocaleString()}\\n` +\n                    `🎯 Lower Support: $${lowerLimit.toLocaleString()}\\n` +\n                    `⚠️ Dump: -${dumpPercentage}% below support!\\n` +\n                    `📊 24h Change: ${change24h >= 0 ? '+' : ''}${change24h.toFixed(2)}%\\n` +\n                    `💰 Market Cap: $${(marketCap / 1000000000).toFixed(2)}B\\n` +\n                    `⏰ ${currentTime.toLocaleString()}\\n\\n` +\n                    `🚨 BEARISH MOMENTUM DETECTED! 🚨`;\n    }\n  }\n  \n  if (alertTriggered) {\n    items.push({\n      json: {\n        symbol: symbol,\n        coin_id: coinId,\n        current_price: currentPrice,\n        upper_limit: upperLimit,\n        lower_limit: lowerLimit,\n        change_24h: change24h,\n        market_cap: marketCap,\n        alert_type: alertType,\n        alert_message: alertMessage,\n        timestamp: currentTime.toISOString(),\n        // Data for updating Google Sheet\n        row_data: {\n          symbol: symbol,\n          upper_limit: upperLimit,\n          lower_limit: lowerLimit,\n          direction: direction,\n          cooldown_minutes: cooldownMinutes,\n          last_alert_price: currentPrice,\n          last_alert_time: currentTime.toISOString()\n        }\n      }\n    });\n  }\n}\n\nreturn items;"
      },
      "typeVersion": 2
    },
    {
      "id": "1b5f189f-7df3-4056-92f1-67a7619123b7",
      "name": "检查加密货币告警条件",
      "type": "n8n-nodes-base.if",
      "position": [
        688,
        832
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8e7f6d5c-4b3a-2910-8765-fedcba098765",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.alert_message }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "6a7b0b7d-ec72-401a-82aa-896ae4338a76",
      "name": "发送加密货币电子邮件告警",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        912,
        544
      ],
      "webhookId": "f37902ad-b0fb-4e01-a2bb-462fd5011e2f",
      "parameters": {
        "options": {},
        "subject": "=🚨 CRYPTO ALERT: {{ $json.symbol }} {{ $json.alert_type === 'upper' ? '🚀 BREAKOUT' : '📉 BREAKDOWN' }} - ${{ $json.current_price }}",
        "toEmail": "crypto-alerts@gmail.com",
        "fromEmail": "your-email@gmail.com"
      },
      "credentials": {
        "smtp": {
          "id": "G1kyF8cSWTZ4vouN",
          "name": "SMTP -test"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "500e80b7-9e42-4e8b-ba6b-df9d3960a0f4",
      "name": "发送 Telegram 加密货币告警",
      "type": "n8n-nodes-base.telegram",
      "position": [
        912,
        928
      ],
      "webhookId": "6c624a07-a1f7-46ea-97ac-f7583a167777",
      "parameters": {
        "text": "={{ $json.alert_message }}",
        "chatId": "YOUR_TELEGRAM_CHAT_ID",
        "additionalFields": {
          "parse_mode": "HTML"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "3ubbGgZx2YzylQZu",
          "name": "Telegram account - test"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6139992f-563f-4f7e-a0fd-04e42684cf77",
      "name": "发送 Discord 加密货币告警",
      "type": "n8n-nodes-base.discord",
      "position": [
        912,
        1120
      ],
      "webhookId": "8b0ccaaa-caea-48a6-9c88-4217f569850c",
      "parameters": {
        "name": "new",
        "guildId": {
          "__rl": true,
          "mode": "id",
          "value": "=987654321t5r4w2"
        },
        "options": {}
      },
      "credentials": {
        "discordBotApi": {
          "id": "r1gTUG66KRYBDfTA",
          "name": "Discord Bot account - test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "0bcadcb1-e39e-443d-8483-20c548480d1f",
      "name": "更新加密货币告警历史",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        912,
        736
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": "Sheet1",
        "documentId": "YOUR_GOOGLE_SHEET_ID_HERE",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "ScSS2KxGQULuPtdy",
          "name": "Google Sheets- test"
        }
      },
      "typeVersion": 4
    },
    {
      "id": "7806b975-49a0-4a9c-9aed-77f4768fd65d",
      "name": "加密货币告警状态检查",
      "type": "n8n-nodes-base.if",
      "position": [
        1136,
        736
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "success-condition",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.symbol }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "b7e51130-380d-4eb4-b96e-132038a98a0d",
      "name": "成功通知",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1360,
        640
      ],
      "webhookId": "5f7a530c-30ea-4fd2-b79c-67655318b768",
      "parameters": {
        "options": {},
        "subject": "✅ Crypto Monitor: Alert Sent Successfully",
        "toEmail": "admin@yourcompany.com",
        "fromEmail": "your-email@gmail.com"
      },
      "credentials": {
        "smtp": {
          "id": "G1kyF8cSWTZ4vouN",
          "name": "SMTP -test"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "3d14deb0-259e-4a6b-a579-978d2fb16e26",
      "name": "错误通知",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1360,
        832
      ],
      "webhookId": "46b6f6f3-d707-4d17-a796-98d02f589f4a",
      "parameters": {
        "options": {},
        "subject": "❌ Crypto Monitor: Alert Failed",
        "toEmail": "admin@yourcompany.com",
        "fromEmail": "your-email@gmail.com"
      },
      "credentials": {
        "smtp": {
          "id": "G1kyF8cSWTZ4vouN",
          "name": "SMTP -test"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "6ab21bb1-63c3-40fb-bff1-2e4ea5a30a89",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -320
      ],
      "parameters": {
        "width": 850,
        "height": 212,
        "content": "## 🚀 实时加密货币价格监控器和智能告警"
      },
      "typeVersion": 1
    },
    {
      "id": "fbe3232f-4377-49cc-9ca4-45d804b9f0c0",
      "name": "加密货币工作流指南",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        32
      ],
      "parameters": {
        "color": 5,
        "width": 680,
        "height": 520,
        "content": "## 🔧 工作原理"
      },
      "typeVersion": 1
    },
    {
      "id": "f8b1bfed-7c0c-4e4e-b963-fea13a10cd3c",
      "name": "加密货币设置示例",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        -32
      ],
      "parameters": {
        "color": 3,
        "width": 760,
        "height": 380,
        "content": "## 💎 加密货币观察列表示例"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8f8ad344-643c-41db-9b92-5a3b18ccdee3",
  "connections": {
    "Parse Crypto Data": {
      "main": [
        [
          {
            "node": "Fetch Live Crypto Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "24/7 Crypto Trigger": {
      "main": [
        [
          {
            "node": "Read Crypto Watchlist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Crypto Watchlist": {
      "main": [
        [
          {
            "node": "Parse Crypto Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Live Crypto Price": {
      "main": [
        [
          {
            "node": "Smart Crypto Alert Logic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Smart Crypto Alert Logic": {
      "main": [
        [
          {
            "node": "Check Crypto Alert Conditions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Crypto Alert Status Check": {
      "main": [
        [
          {
            "node": "Success Notification",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Crypto Alert History": {
      "main": [
        [
          {
            "node": "Crypto Alert Status Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Crypto Alert Conditions": {
      "main": [
        [
          {
            "node": "Send Crypto Email Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Telegram Crypto Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Discord Crypto Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Update Crypto Alert History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
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 查看

分享此工作流