8
n8n 中文网amn8n.com

使用 CoinGecko 通过邮件/SMS 监控比特币和以太坊价格告警

中级

这是一个Crypto Trading, Miscellaneous, Multimodal AI领域的自动化工作流,包含 8 个节点。主要使用 If, Code, Gmail, Twilio, HttpRequest 等节点。 使用 CoinGecko 通过邮件/SMS 监控比特币和以太坊价格告警

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "5695a0ca-3750-4d6f-bbb3-d41143375841",
      "name": "每15分钟",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "0535cf1e-d5de-47da-9962-0aa1a7524db8",
      "name": "获取加密货币价格",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        208,
        0
      ],
      "parameters": {
        "url": "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum&vs_currencies=usd&include_24hr_change=true",
        "options": {}
      },
      "typeVersion": 4.1
    },
    {
      "id": "33914e7a-c4bc-40aa-b2e9-ac8e41d3e4ab",
      "name": "计算阈值标志",
      "type": "n8n-nodes-base.code",
      "position": [
        432,
        0
      ],
      "parameters": {
        "jsCode": "const BTC_UP=110000, BTC_DOWN=105000, ETH_UP=4500, ETH_DOWN=4200, MOVE_ABS=2.0;\nconst j=$json; const now=new Date().toISOString();\nconst btcPrice=Number(j.bitcoin?.usd), btcChg=Number(j.bitcoin?.usd_24h_change);\nconst ethPrice=Number(j.ethereum?.usd), ethChg=Number(j.ethereum?.usd_24h_change);\nconst flags={\n  btc:{price:btcPrice, chg24:btcChg, cross_up:isFinite(btcPrice)&&btcPrice>=BTC_UP, cross_down:isFinite(btcPrice)&&btcPrice<=BTC_DOWN, big_move:isFinite(btcChg)&&Math.abs(btcChg)>=MOVE_ABS},\n  eth:{price:ethPrice, chg24:ethChg, cross_up:isFinite(ethPrice)&&ethPrice>=ETH_UP, cross_down:isFinite(ethPrice)&&ethPrice<=ETH_DOWN, big_move:isFinite(ethChg)&&Math.abs(ethChg)>=MOVE_ABS},\n  ts: now\n};\nreturn [{json: flags}];"
      },
      "typeVersion": 2
    },
    {
      "id": "c3a3e299-ebe7-499e-a0fc-9329690caadf",
      "name": "是否有警报?",
      "type": "n8n-nodes-base.if",
      "position": [
        624,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.btc.cross_up }}"
            },
            {
              "value1": "={{ $json.btc.cross_down }}"
            },
            {
              "value1": "={{ $json.btc.big_move }}"
            },
            {
              "value1": "={{ $json.eth.cross_up }}"
            },
            {
              "value1": "={{ $json.eth.cross_down }}"
            },
            {
              "value1": "={{ $json.eth.big_move }}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "63226aa9-0d9d-499d-988b-6b10b877fe7d",
      "name": "格式化警报邮件",
      "type": "n8n-nodes-base.code",
      "position": [
        832,
        0
      ],
      "parameters": {
        "jsCode": "const s=(n,d=2)=>isFinite(n)?Number(n).toFixed(d):'—';\nconst sign=n=>isFinite(n)&&n>0?'+':'';\nconst j=$json; const lines=[\n  `BTC: $${s(j.btc.price,0)} (24h: ${sign(j.btc.chg24)}${s(j.btc.chg24)}%)`,\n  `ETH: $${s(j.eth.price,0)} (24h: ${sign(j.eth.chg24)}${s(j.eth.chg24)}%)`\n];\nreturn [{json:{\n  subject:`⚠️ Crypto Alert — ${new Date().toLocaleString('en-US',{timeZone:'Africa/Lagos'})}`,\n  html:`<p>${lines.join('<br>')}</p>`,\n  text: lines.join('\\n')\n}}];"
      },
      "typeVersion": 2
    },
    {
      "id": "98e5269e-9607-46ad-8dd1-b8c7c8c37a8f",
      "name": "发送消息",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1040,
        96
      ],
      "webhookId": "14c6592e-d95f-4e54-9a2d-460c609935f2",
      "parameters": {
        "sendTo": "recipient@gmail.com",
        "message": "={{ $json.html }}",
        "options": {
          "appendAttribution": true
        },
        "subject": "={{ $json.subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "LVRUgE95PAvkE1Mc",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "76dfd7da-7369-4a97-9d6b-72ed12df0b4c",
      "name": "发送 SMS/MMS/WhatsApp 消息",
      "type": "n8n-nodes-base.twilio",
      "position": [
        1040,
        -112
      ],
      "parameters": {
        "message": "={{ $('Format Alert Email').item.json.text }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "3e6cc369-0736-4414-919b-8907016e470e",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -480
      ],
      "parameters": {
        "width": 912,
        "height": 720,
        "content": "## ⚠️ 加密货币价格阈值警报(邮件/SMS/Telegram)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Any Alert?": {
      "main": [
        [
          {
            "node": "Format Alert Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        []
      ]
    },
    "Every 15 Minutes": {
      "main": [
        [
          {
            "node": "Get Crypto Prices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Crypto Prices": {
      "main": [
        [
          {
            "node": "Compute Threshold Flags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Alert Email": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send an SMS/MMS/WhatsApp message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compute Threshold Flags": {
      "main": [
        [
          {
            "node": "Any Alert?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

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

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

作者
David Olusola

David Olusola

@dae221

I help ambitious businesses eliminate operational bottlenecks and scale faster with AI automation. My clients typically see 40-60% efficiency gains within 90 days. Currently accepting 3 new projects this quarter - david@daexai.com

外部链接
在 n8n.io 查看

分享此工作流