8
n8n 中文网amn8n.com

比特币价格下跌警报系统_via_Bright_Data

中级

这是一个AI领域的自动化工作流,包含 15 个节点。主要使用 If, Code, Html, Gmail, HttpRequest 等节点,结合人工智能技术实现智能自动化。 Bright Data和n8n的实时比特币价格警报

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "HPuntqVPRH2UITi4",
  "meta": {
    "instanceId": "60046904b104f0f72b2629a9d88fe9f676be4035769f1f08dad1dd38a76b9480"
  },
  "name": "Bitcoin_Price_Drop_Alert_System_via_Bright_Data",
  "tags": [],
  "nodes": [
    {
      "id": "8746bf3b-5e6b-4f14-815d-4b774c3302c3",
      "name": "手动触发器",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        2040,
        780
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1a5d6ae5-9491-4199-a6fe-ae01593ebedd",
      "name": "获取最后记录的价格",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2880,
        780
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/15DSwLkRw9NK2RIhXLMjzysmF9QYa5afreDXFrDQNXPM/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "15DSwLkRw9NK2RIhXLMjzysmF9QYa5afreDXFrDQNXPM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/15DSwLkRw9NK2RIhXLMjzysmF9QYa5afreDXFrDQNXPM/edit?usp=drivesdk",
          "cachedResultName": "Bitcoin latest price"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "r2mDaisH6e9VkwHl",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "b48cce2e-63f3-4b4a-b9e7-f7506695dd8a",
      "name": "发送警报邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3780,
        600
      ],
      "webhookId": "bb09c84f-b390-4ce6-937e-eaeaefc979c5",
      "parameters": {
        "sendTo": "shahkar.genai@gmail.com",
        "message": "=Hello,\n\nThe price of Bitcoin has dropped by {{ $json.dropPercent }}% since the last check.\n\nPrevious Price: {{ $json.previousPrice }}\nCurrent Price: {{ $json.currentPrice }}\n\nPlease review accordingly.\n\nBest regards,\nYour Crypto Monitor Bot\n`;\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "=Bitcoin Price has dropped {{ $json.dropPercent }}%",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "AQDSl75AdzK3vmqJ",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "d1f96797-9558-403d-a37c-604e07e76563",
      "name": "无需提醒",
      "type": "n8n-nodes-base.noOp",
      "position": [
        3780,
        900
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "208006b9-4cae-4199-9342-d7646fe38672",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 1300,
        "height": 320,
        "content": "======================================="
      },
      "typeVersion": 1
    },
    {
      "id": "403e8b40-1a0f-464e-8d81-a162c0308252",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        340
      ],
      "parameters": {
        "color": 4,
        "width": 1289,
        "height": 2558,
        "content": "# 📉💰 **比特币价格下跌警报工作流**"
      },
      "typeVersion": 1
    },
    {
      "id": "201e7c73-d960-47c5-934e-f8fe0630ca2c",
      "name": "Fetch Bitcoin Price",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2240,
        780
      ],
      "parameters": {
        "url": "https://api.brightdata.com/request",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "zone",
              "value": "n8n_unblocker"
            },
            {
              "name": "url",
              "value": "https://coinmarketcap.com/currencies/bitcoin/"
            },
            {
              "name": "country",
              "value": "us"
            },
            {
              "name": "format",
              "value": "raw"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer API_KEY"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "ff6d0c30-0e72-4a28-9628-b94606461a20",
      "name": "Extract Price",
      "type": "n8n-nodes-base.html",
      "position": [
        2440,
        780
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "price",
              "cssSelector": "<span class=\"sc-65e7f566-0 esyGGG base-text\" data-test=\"text-cdp-price-display\">$105,095.42</span>"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "759e26b7-a260-469e-ba17-fc5bee7be762",
      "name": "Convert type",
      "type": "n8n-nodes-base.code",
      "position": [
        2660,
        780
      ],
      "parameters": {
        "jsCode": "return items.map(item => {\n  const priceStr = item.json.price;\n  const priceNumber = parseFloat(priceStr.replace(/[$,]/g, ''));\n  return {\n    json: {\n      price: priceNumber\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "c33e81f4-f06e-4e47-942f-4764027f270c",
      "name": "Find drop percentage",
      "type": "n8n-nodes-base.code",
      "position": [
        3100,
        780
      ],
      "parameters": {
        "jsCode": "// Extract current and previous price from separate input items\nconst currentPrice = $('Convert type').first().json.price;\nconst previousPrice = $input.first().json.Price;\n\nconst dropPercent = previousPrice !== 0 \n  ? ((previousPrice - currentPrice) / previousPrice) * 100 \n  : 0;\n\nreturn [{\n  json: {\n    currentPrice,\n    previousPrice,\n    dropPercent: parseFloat(dropPercent.toFixed(2))\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "cb64ae28-6086-4301-85b7-a8bdac6c2370",
      "name": "If droppercentage >= 5",
      "type": "n8n-nodes-base.if",
      "position": [
        3420,
        780
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9b9dfa4e-92d1-408e-90f0-355141f73d54",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.dropPercent }}",
              "rightValue": 5
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "08bcbb20-2f85-45c9-b56e-61edb70ccd74",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2020,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 540,
        "height": 980,
        "content": "## 🔎 **Section 1: Fetch the Current Bitcoin Price**\n\n🧩 **Nodes:**\n\n1. **⚡ Manual Trigger**\n2. **🌐 Fetch Bitcoin Price**\n3. **🧱 Extract Price**\n\n### 🧠 What Happens:\n\n* **⚡ Manual Trigger**\n  This starts the process manually. Think of it like pressing a \"Start\" button.\n\n* **🌐 Fetch Bitcoin Price**\n  Uses the [Bright Data API](https://brightdata.com/) to scrape the live Bitcoin price from a specific website using a POST request.\n\n* **🧱 Extract Price**\n  Extracts the **exact price value** from the scraped HTML using selectors (like CSS paths).\n\n### 💡 Why It’s Useful:\n\nYou can track the **real-time price** of Bitcoin straight from any public site, even those not offering official APIs. It's like building your own live feed.\n\n---\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9c153740-4fb9-4ab7-b129-c6bc8c61c274",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2640,
        -40
      ],
      "parameters": {
        "color": 5,
        "width": 600,
        "height": 1020,
        "content": "## 📊 **Section 2: Calculate and Compare with Historical Price**\n\n🧩 **Nodes:**\n4\\. **🔄 Convert Type**\n5\\. **📗 Get Last Recorded Price (Google Sheet)**\n6\\. **📉 Find Drop Percentage**\n\n### 🧠 What Happens:\n\n* **🔄 Convert Type**\n  Converts the price from a text format to a number so we can calculate with it.\n\n* **📗 Get Last Recorded Price**\n  Pulls the **previous Bitcoin price** from a Google Sheet (a record from last check). Acts like your “memory”.\n\n* **📉 Find Drop Percentage**\n  Calculates how much the price has dropped:\n\n  $$\n  \\text{Drop (\\%)} = \\frac{\\text{Previous Price - Current Price}}{\\text{Previous Price}} \\times 100\n  $$\n\n### 💡 Why It’s Useful:\n\nYou’re comparing real-time data with past values automatically—no spreadsheets or calculators needed! This makes it ideal for **traders or enthusiasts** watching for price alerts.\n\n---\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "58dbf6d5-371f-4123-8838-5c6f40185711",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3380,
        100
      ],
      "parameters": {
        "color": 6,
        "width": 540,
        "height": 940,
        "content": "## 🚨 **Section 3: Send Alert if Drop ≥ 5%**\n\n🧩 **Nodes:**\n7\\. **🔀 If droppercentage >= 5**\n8\\. **📧 Send Alert Email**\n9\\. **➡️ No Alert Needed**\n\n### 🧠 What Happens:\n\n* **🔀 If Statement**\n  Checks: Has the price dropped by **5% or more**?\n\n* **📧 Send Alert Email** (if true)\n  Automatically sends an email to notify you about the drop. This could go to your inbox, or a team.\n\n* **➡️ No Alert Needed** (if false)\n  The workflow ends quietly without doing anything else.\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a9608daf-aff9-460a-8ca5-14c1fc41916e",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4000,
        100
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 240,
        "content": "## I’ll receive a tiny commission if you join Bright Data through this link—thanks for fueling more free content!\n\n### https://get.brightdata.com/1tndi4600b25"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "125a795b-a427-4a83-abee-62fe60538000",
  "connections": {
    "Convert type": {
      "main": [
        [
          {
            "node": "Get Last Recorded Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Price": {
      "main": [
        [
          {
            "node": "Convert type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Fetch Bitcoin Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Bitcoin Price": {
      "main": [
        [
          {
            "node": "Extract Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find drop percentage": {
      "main": [
        [
          {
            "node": "If droppercentage >= 5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If droppercentage >= 5": {
      "main": [
        [
          {
            "node": "Send Alert Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Alert Needed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Last Recorded Price": {
      "main": [
        [
          {
            "node": "Find drop percentage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 人工智能

需要付费吗?

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

工作流信息
难度等级
中级
节点数量15
分类1
节点类型9
难度说明

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

作者
Yaron Been

Yaron Been

@yaron-nofluff

Building AI Agents and Automations | Growth Marketer | Entrepreneur | Book Author & Podcast Host If you need any help with Automations, feel free to reach out via linkedin: https://www.linkedin.com/in/yaronbeen/ And check out my Youtube channel: https://www.youtube.com/@YaronBeen/videos

外部链接
在 n8n.io 查看

分享此工作流