8
n8n 中文网amn8n.com

Gate AI代理 v1.02

高级

这是一个Crypto Trading, AI Chatbot, Multimodal AI领域的自动化工作流,包含 35 个节点。主要使用 Set, Code, Telegram, Agent, HttpRequestTool 等节点。 从Gate.io获取实时加密货币市场数据,使用GPT-4o和Telegram

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "wJXl7mSb4EhDi6mT",
  "meta": {
    "instanceId": "a5283507e1917a33cc3ae615b2e7d5ad2c1e50955e6f831272ddd5ab816f3fb6",
    "templateCredsSetupCompleted": true
  },
  "name": "Gate AI Agent v1.02",
  "tags": [],
  "nodes": [
    {
      "id": "cf0da4b9-ff10-47c7-8b7e-217b3889d871",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1264,
        736
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "yUizd8t0sD5wMYVG",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "efc44a96-36af-457d-a28e-022dbfcc8149",
      "name": "Telegram触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1008,
        240
      ],
      "webhookId": "53ab61de-3265-4a87-a78e-271a40f932b1",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "NRLKuLR7z8vCesub",
          "name": "BinanceSpotTradingAIAgent_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e6eed75c-75dd-4f7a-93d1-5c65ef2a1aa9",
      "name": "用户认证(替换 Telegram ID)",
      "type": "n8n-nodes-base.code",
      "position": [
        -688,
        240
      ],
      "parameters": {
        "jsCode": "if ($input.first().json.message.from.id !== <<Replace>>) { // Replace with your actual ID\n  return {unauthorized: true};\n} else {\n  // Return the original data when authorized\n  return $input.all();\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "7a1c6d28-5fde-4a84-b8aa-9166a99e34eb",
      "name": "添加 \"SessionId\"",
      "type": "n8n-nodes-base.set",
      "position": [
        -416,
        240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "47598bf1-e55f-4cc0-ae75-272085e7ce02",
              "name": "=sessionId",
              "type": "string",
              "value": "={{ $json.message.chat.id }}"
            },
            {
              "id": "daa49d74-e55e-47bc-ac52-8686d591ab83",
              "name": "message",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f8406859-3320-4918-a240-d2dee2c9cccb",
      "name": "拆分超过 4000 字符的消息",
      "type": "n8n-nodes-base.code",
      "position": [
        464,
        240
      ],
      "parameters": {
        "jsCode": "// Input: assumes incoming message in `item.json.message`\nconst input = $json.output;\nconst chunkSize = 4000;\n\n// Function to split text\nfunction splitMessage(text, size) {\n  const result = [];\n  for (let i = 0; i < text.length; i += size) {\n    result.push(text.substring(i, i + size));\n  }\n  return result;\n}\n\n// Logic\nif (input.length <= chunkSize) {\n  return [{ json: { message: input } }];\n} else {\n  const chunks = splitMessage(input, chunkSize);\n  return chunks.map(chunk => ({ json: { message: chunk } }));\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "f0f3f157-f35b-4c68-afd1-82e9a4abfc57",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        -32
      ],
      "parameters": {
        "color": 4,
        "height": 460,
        "content": "## 触发传入 Telegram 命令"
      },
      "typeVersion": 1
    },
    {
      "id": "ea50b5ad-9086-46a3-99f7-2a62979a28ef",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        -32
      ],
      "parameters": {
        "color": 2,
        "height": 460,
        "content": "## 验证用户访问权限"
      },
      "typeVersion": 1
    },
    {
      "id": "e5070b89-c14e-44bb-9bc6-51b3e2b1a459",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -32
      ],
      "parameters": {
        "color": 5,
        "height": 460,
        "content": "## 生成会话元数据"
      },
      "typeVersion": 1
    },
    {
      "id": "17693c7a-9c4b-4067-bf38-32b177a73c7c",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -336
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 772,
        "content": "## 主 AI Agent:数据获取器"
      },
      "typeVersion": 1
    },
    {
      "id": "58ddff39-608d-41db-b89e-a3d4c7571de0",
      "name": "便签说明4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -32
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 460,
        "content": "## 处理 Telegram 消息限制"
      },
      "typeVersion": 1
    },
    {
      "id": "1b0a5854-f183-4a9d-a967-23802393de90",
      "name": "便签说明5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        -32
      ],
      "parameters": {
        "color": 4,
        "height": 460,
        "content": "## 发送最终报告到 Telegram"
      },
      "typeVersion": 1
    },
    {
      "id": "df1fb332-093a-4669-91a1-b4004ff09a4d",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        640
      ],
      "parameters": {
        "height": 540,
        "content": "## 用于推理的 GPT 模型"
      },
      "typeVersion": 1
    },
    {
      "id": "92146023-977e-47ff-9e90-bedf05f06262",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 884,
        "content": "### **订单簿深度**"
      },
      "typeVersion": 1
    },
    {
      "id": "020081b2-6d5f-4b7b-8d5a-bd4151722cd0",
      "name": "## 为什么选择 4o 模型?👆",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 868,
        "content": "### **最佳买/卖价(订单簿报价器)**"
      },
      "typeVersion": 1
    },
    {
      "id": "9af111a2-e1b5-46bb-b00f-75a6ab07abd5",
      "name": "便签 9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        640
      ],
      "parameters": {
        "color": 3,
        "height": 540,
        "content": "## 短期记忆模块"
      },
      "typeVersion": 1
    },
    {
      "id": "0ff5fedb-9d7b-42a8-9460-5daf76ca91f9",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -992,
        736
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "a8f8c1cb-9e8b-450c-a7b7-be72ab2538d7",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -784,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 932,
        "content": "### **24 小时统计数据**"
      },
      "typeVersion": 1
    },
    {
      "id": "043ebb93-f65a-419d-b2b8-2931044195a0",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 820,
        "content": "### **价格(最新)**"
      },
      "typeVersion": 1
    },
    {
      "id": "7640a82a-5936-4d4e-8258-257763c524b4",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 1012,
        "content": "### **K 线(蜡烛图)**"
      },
      "typeVersion": 1
    },
    {
      "id": "840c6704-acf8-43c0-9808-dbef0cc97cfd",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 788,
        "content": "### **24 小时统计数据(报价器)**"
      },
      "typeVersion": 1
    },
    {
      "id": "0817d422-51a8-4d74-9b91-461d68681799",
      "name": "便签 14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 900,
        "content": "### 🏷 工具:**最近交易**"
      },
      "typeVersion": 1
    },
    {
      "id": "5ed3cd36-3f49-4484-91b0-e9dc8d81a018",
      "name": "计算器",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        1520,
        592
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "00a91265-2c7f-4150-b47c-eb537a7c6b6c",
      "name": "思考",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        1808,
        592
      ],
      "parameters": {
        "description": "### 🏷 工具:**思考**"
      },
      "typeVersion": 1.1
    },
    {
      "id": "dc07a5c2-1922-4f90-9ba2-07e155af5ed5",
      "name": "便签 15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 836,
        "content": "### **计算器**"
      },
      "typeVersion": 1
    },
    {
      "id": "1ea6c681-34a5-4e70-a8ef-c12f9f56a02f",
      "name": "便签16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1728,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 932,
        "content": "### **思考**"
      },
      "typeVersion": 1
    },
    {
      "id": "8eb8b24a-5ab3-4f23-817f-cdb57b9055f0",
      "name": "Gate AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -96,
        240
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "options": {
          "systemMessage": "You are the **Gate Spot Market Data Agent**.\n\nYou have **HTTP GET** access to the official Gate.io REST **v4** API to retrieve market data for any requested **Spot** currency pair.\nYour job is to **fetch and present data only** — no analysis, predictions, or advice.\n\n---\n\n## 🔗 API Access\n\n**Base URL:** `https://api.gateio.ws/api/v4`\n**Pair format:** `BASE_QUOTE` (underscore, uppercase), e.g. `BTC_USDT`.\n\n**General rules**\n\n* All requests are **GET** and return **JSON**.\n* Query params go in the URL, e.g. `?currency_pair=BTC_USDT&limit=100`.\n* If a field or call fails, output `N/A` and continue.\n\n---\n\n## 📌 Market Data Endpoints (Spot)\n\n1. **Latest Price & 24h Stats**\n   `GET /spot/tickers?currency_pair=BTC_USDT`\n   Returns last price, open/high/low, 24h change %, base/quote volume, best bid/ask and more.\n\n2. **Order Book Depth**\n   `GET /spot/order_book?currency_pair=BTC_USDT&limit=100&with_id=true`\n   Returns bids/asks up to the limit (top-of-book first). Use `limit=1` to emulate **Best Bid/Ask**.\n\n3. **Recent Trades**\n   `GET /spot/trades?currency_pair=BTC_USDT&limit=100`\n   Most recent public trades (price, size, time, side).\n\n4. **Candlesticks (Klines)**\n   `GET /spot/candlesticks?currency_pair=BTC_USDT&interval=15m&limit=20`\n   OHLCV candles. Supported intervals: `10s, 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w`. Use common ones like `1m, 5m, 15m, 1h, 4h, 1d`.\n\n---\n\n### Notes\n\n* Gate.io does not expose a separate “average price” endpoint. If needed, compute midpoint `(best_bid + best_ask) / 2` in the **Calculator** node.\n* No separate “bookTicker” endpoint; use **Order Book** with `limit=1` for best bid/ask.\n\n---\n\n## 🧩 Utility Tools\n\n* **Calculator** — optional simple math (spread, midpoint, % change).\n* **Think** — reshape JSON and format the final Telegram message.\n\n---\n\n## 📤 Output Format (Telegram text)\n\nStart with:\n\n```\nBTC_USDT — Gate Spot Data\n```\n\nThen group logically:\n\n```\nPrice\n• Last: 26250\n• Best Bid / Ask: 26245 / 26255\n• Change (24h): -1.2%\n\n24h Stats\n• Open: 26500 • High: 27000 • Low: 26000 • Close: 26250\n• Volume: 1,234 BTC • Quote Vol: 32,000,000 USDT\n\nOrder Book (Top 5)\n• Bids: [26245 x 0.5], [26244 x 1.2] …\n• Asks: [26255 x 0.8], [26256 x 1.5] …\n\nCandles (latest 20)\n• Interval: 15m (O/H/L/C per candle)\n```\n\n---\n\n## ⚠️ Rules\n\n* Always call the correct **Gate.io v4 Spot endpoint** for the requested data.\n* Do not fabricate values, run technical analysis, or sentiment.\n* Do not dump raw JSON — always return clean, readable values.\n* On error or missing fields, show `N/A` and continue.\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "6508d18e-8885-42b0-9e3c-4cf180dabc84",
      "name": "24 小时统计数据",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -704,
        592
      ],
      "parameters": {
        "url": "https://api.gateio.ws/api/v4/spot/tickers",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "currency_pair",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('currency_pair', `BTC_USDT`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **24h Stats**\n\n**Endpoint:** `GET /spot/tickers`\n**What it does:** 24-hour stats for a currency pair: **last price, open/high/low, change %, volume, best bid/ask**.\n**Params:**\n\n* `currency_pair` (STRING, required) → format: `BASE_QUOTE` (e.g., BTC_USDT)\n\n**Returns:** `{ \"currency_pair\": \"BTC_USDT\", \"last\": \"...\", \"lowest_ask\": \"...\", \"highest_bid\": \"...\", \"change_percentage\": \"...\", \"base_volume\": \"...\", \"quote_volume\": \"...\", \"high_24h\": \"...\", \"low_24h\": \"...\" }`\n\n**n8n query mapping:**\n\n```txt\ncurrency_pair = $fromAI('currency_pair', 'BTC_USDT', 'string')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "c73467fc-d8cb-4d0c-858f-858ddcd1ff65",
      "name": "订单簿深度",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -400,
        592
      ],
      "parameters": {
        "url": "https://api.gateio.ws/api/v4/spot/order_book",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "currency_pair",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('currency_pair', `BTC_USDT`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('limit', `100`, 'number') }}"
            },
            {
              "name": "with_id",
              "value": "true"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Order Book Depth**\n\n**Endpoint:** `GET /spot/order_book`\n**What it does:** Returns order book bids/asks up to `limit`.\n**Params:**\n\n* `currency_pair` (STRING, required) → format: `BASE_QUOTE` (e.g., BTC_USDT)\n* `limit` (INT, default 100; max 5000; **we default 100**)\n* `with_id` (BOOL, optional; if true, includes order book update ID)\n\n**Returns:** `{ \"id\":12345, \"bids\":[[price, amount],...], \"asks\":[[price, amount],...] }`\n\n**n8n query mapping:**\n\n```txt\ncurrency_pair = $fromAI('currency_pair', 'BTC_USDT', 'string')\nlimit         = $fromAI('limit', 100, 'number')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "5774e695-360f-4493-ba6f-01703abac1f5",
      "name": "价格(最新)",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -112,
        592
      ],
      "parameters": {
        "url": "https://api.gateio.ws/api/v4/spot/tickers",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "currency_pair",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('currency_pair', `BTC_USDT`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Price (Latest)**\n\n**Endpoint:** `GET /spot/tickers`\n**What it does:** Returns the **latest trade price** for a currency pair (field: `last`).\n**Params:**\n\n* `currency_pair` (STRING, required) → format: `BASE_QUOTE` (e.g., BTC_USDT)\n\n**Returns:** `{ \"currency_pair\":\"BTC_USDT\", \"last\":\"...\", \"lowest_ask\":\"...\", \"highest_bid\":\"...\", \"base_volume\":\"...\", \"quote_volume\":\"...\" }`\n\n**n8n query mapping:**\n\n```txt\ncurrency_pair = $fromAI('currency_pair', 'BTC_USDT', 'string')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "8684607d-5c84-459b-a4cb-78b93c77b0ec",
      "name": "最佳买/卖价",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        208,
        592
      ],
      "parameters": {
        "url": "https://api.gateio.ws/api/v4/spot/order_book",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "currency_pair",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('currency_pair', `BTC_USDT`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "1"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Best Bid/Ask (Book Ticker)**\n\n**Endpoint:** `GET /spot/order_book`\n**What it does:** Returns the best **bid/ask** with sizes for a currency pair.\n**Params:**\n\n* `currency_pair` (STRING, required) → format: `BASE_QUOTE` (e.g., BTC_USDT)\n* `limit` (INT, fixed = 1)\n\n**Returns:** `{ \"bids\": [[price, amount]], \"asks\": [[price, amount]], \"id\": ... }`\n\n**n8n query mapping:**\n\n```txt\ncurrency_pair = $fromAI('currency_pair', 'BTC_USDT', 'string')\nlimit         = 1\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "bcdd5693-66f0-4474-a503-701e346b6cde",
      "name": "K线 (蜡烛图)",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        544,
        592
      ],
      "parameters": {
        "url": "https://api.gateio.ws/api/v4/spot/candlesticks",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "currency_pair",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('currency_pair', `BTC_USDT`, 'string') }}"
            },
            {
              "name": "interval",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('interval', `15m`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('limit', `20`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Klines (Candles)**\n\n**Endpoint:** `GET /spot/candlesticks`\n**What it does:** OHLCV candlesticks for a currency pair/interval.\n**Params:**\n\n* `currency_pair` (STRING, required) → format: `BASE_QUOTE` (e.g., BTC_USDT)\n* `interval` (STRING, required) → e.g., `1m,5m,15m,30m,1h,4h,1d,1w` (others may be supported)\n* `limit` (INT, optional) → number of candles to return (**we default 20**)\n* `from`, `to` (INT, optional) → unix seconds range\n\n**Returns (array per candle):** `[ t, v, c, h, l, o ]` (time, volume, close, high, low, open)\n\n**n8n query mapping:**\n\n```txt\ncurrency_pair = $fromAI('currency_pair', 'BTC_USDT', 'string')\ninterval      = $fromAI('interval', '15m', 'string')\nlimit         = $fromAI('limit', 20, 'number')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "b6173161-f16d-4356-8dda-1e517a25a803",
      "name": "24 小时统计数据(报价器)1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        880,
        592
      ],
      "parameters": {
        "url": "https://api.gateio.ws/api/v4/spot/tickers",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "currency_pair",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('currency_pair', `BTC_USDT`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **24h Stats (Ticker)**\n\n**Endpoint:** `GET /spot/tickers`\n**What it does:** Returns latest ticker stats for a currency pair.\n**Params:**\n\n* `currency_pair` (STRING, required) → format: `BASE_QUOTE` (e.g., BTC_USDT)\n\n**Returns:** `last, lowest_ask, highest_bid, change_percentage, base_volume, quote_volume`\n\n**n8n query mapping:**\n\n```txt\ncurrency_pair = $fromAI('currency_pair', 'BTC_USDT', 'string')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "63ed8ff8-6eb7-4410-80fe-ec5c19af49ff",
      "name": "最近交易",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        1216,
        592
      ],
      "parameters": {
        "url": "https://api.gateio.ws/api/v4/spot/trades",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "currency_pair",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('currency_pair', `BTC_USDT`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('limit', `100`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Recent Trades**\n\n**Endpoint:** `GET /spot/trades`\n**What it does:** Returns the **most recent public trades** for a currency pair.\n**Params:**\n\n* `currency_pair` (STRING, required) → format: `BASE_QUOTE` (e.g., BTC_USDT)\n* `limit` (INT, optional) → number of trades to return (**we default 100**)\n\n**Returns (array):** `[ { \"id\":123, \"create_time_ms\":\"...\", \"side\":\"buy|sell\", \"price\":\"...\", \"amount\":\"...\" }, ... ]`\n\n**n8n query mapping:**\n\n```txt\ncurrency_pair = $fromAI('currency_pair', 'BTC_USDT', 'string')\nlimit         = $fromAI('limit', 100, 'number')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "c24030d4-7e6d-45fc-9c21-18277795fb04",
      "name": "发送短信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        896,
        240
      ],
      "webhookId": "e43b0e16-947a-4a5e-9bd6-00e2e87b02f6",
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": true
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "NRLKuLR7z8vCesub",
          "name": "BinanceSpotTradingAIAgent_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4d084614-f0d0-4d59-8cc6-baa2676b084e",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2272,
        -800
      ],
      "parameters": {
        "width": 1424,
        "height": 2608,
        "content": "# 🧠 Gate 现货市场数据 AI Agent – 完整系统文档"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "677c5ded-85e9-440c-bd65-65099b96650d",
  "connections": {
    "Think": {
      "ai_tool": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "24h Stats": {
      "ai_tool": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Best Bid/Ask": {
      "ai_tool": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gate AI Agent": {
      "main": [
        [
          {
            "node": "Splits message is more than 4000 characters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recent Trades": {
      "ai_tool": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Price (Latest)": {
      "ai_tool": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Adds \"SessionId\"": {
      "main": [
        [
          {
            "node": "Gate AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Klines (Candles)": {
      "ai_tool": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Order Book Depth": {
      "ai_tool": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "User Authentication (Replace Telegram ID)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "24h Stats (Ticker)1": {
      "ai_tool": [
        [
          {
            "node": "Gate AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "User Authentication (Replace Telegram ID)": {
      "main": [
        [
          {
            "node": "Adds \"SessionId\"",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Splits message is more than 4000 characters": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 加密货币交易, AI 聊天机器人, 多模态 AI

需要付费吗?

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

工作流信息
难度等级
高级
节点数量35
分类3
节点类型11
难度说明

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

作者
Don Jayamaha Jr

Don Jayamaha Jr

@don-the-gem-dealer

With 12 years of experience as a Blockchain Strategist and Web3 Architect, I specialize in bridging the gap between traditional industries and decentralized technologies. My expertise spans tokenized assets, crypto payment integrations, and blockchain-driven market solutions.

外部链接
在 n8n.io 查看

分享此工作流