8
n8n 中文网amn8n.com

OKX AI代理 v1.02

高级

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

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "NPE3aLxgBrs6UNcA",
  "meta": {
    "instanceId": "a5283507e1917a33cc3ae615b2e7d5ad2c1e50955e6f831272ddd5ab816f3fb6"
  },
  "name": "OKX AI Agent v1.02",
  "tags": [],
  "nodes": [
    {
      "id": "0fdddcb8-ad21-468d-8dc1-99e9a2e9997e",
      "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": "7b6f2205-5a51-4034-b558-19b0585da42e",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1008,
        240
      ],
      "webhookId": "f5388051-b3af-4d27-b50c-24a194308e4d",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "NRLKuLR7z8vCesub",
          "name": "BinanceSpotTradingAIAgent_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0433fe88-52d0-4fa6-80b7-e1f0afa6ce75",
      "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": "5d20cb16-35dd-4cfc-b22a-c4859eefbc56",
      "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": "65f42216-de3f-4961-b67e-34cf0ec4d358",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        896,
        240
      ],
      "webhookId": "777f010f-9fde-4ab5-b6f0-a5bb60b44613",
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "NRLKuLR7z8vCesub",
          "name": "BinanceSpotTradingAIAgent_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8a4b0dae-f2df-4358-98aa-51b832a337b1",
      "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": "4dfa9d4a-3668-423f-9685-a8517fd398f2",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        -32
      ],
      "parameters": {
        "color": 4,
        "height": 460,
        "content": "## 触发传入的Telegram命令"
      },
      "typeVersion": 1
    },
    {
      "id": "ad8587d4-f03b-495d-b0c3-d608e29fe3a6",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        -32
      ],
      "parameters": {
        "color": 2,
        "height": 460,
        "content": "## 验证用户访问权限"
      },
      "typeVersion": 1
    },
    {
      "id": "cb8bb1c5-4dd8-4d60-a224-863358e17d35",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -32
      ],
      "parameters": {
        "color": 5,
        "height": 460,
        "content": "## 生成会话元数据"
      },
      "typeVersion": 1
    },
    {
      "id": "0b465e66-b299-4a21-a84a-7e4eb08098a7",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -352
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 788,
        "content": "## 主 AI Agent:数据获取器"
      },
      "typeVersion": 1
    },
    {
      "id": "6a5c34be-a570-49b8-b875-a08a3725ef16",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -32
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 460,
        "content": "## 处理Telegram消息限制"
      },
      "typeVersion": 1
    },
    {
      "id": "424be542-56b9-4078-859d-a31c18512838",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        -32
      ],
      "parameters": {
        "color": 4,
        "height": 460,
        "content": "## 发送最终报告到Telegram"
      },
      "typeVersion": 1
    },
    {
      "id": "fb2debe7-5160-406c-9e3c-7245148a1389",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        640
      ],
      "parameters": {
        "height": 540,
        "content": "## 用于推理的GPT模型"
      },
      "typeVersion": 1
    },
    {
      "id": "2515e909-480e-4ddb-ae09-fb022bbc47dc",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 868,
        "content": "### **订单簿深度**"
      },
      "typeVersion": 1
    },
    {
      "id": "66b35377-9b16-4b61-9beb-2ca38a370018",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 916,
        "content": "### **最佳买/卖价(订单簿行情)**"
      },
      "typeVersion": 1
    },
    {
      "id": "924995df-b973-4055-95fd-4490ffdb21e9",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        640
      ],
      "parameters": {
        "color": 3,
        "height": 540,
        "content": "## 短期记忆模块"
      },
      "typeVersion": 1
    },
    {
      "id": "c8d351a3-bb20-4ec4-a890-162b2295c7c4",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -992,
        736
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "9376ce27-8a71-45d7-a7df-863c25a2ff1e",
      "name": "便签 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -784,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 836,
        "content": "### **24 小时统计数据(行情)**"
      },
      "typeVersion": 1
    },
    {
      "id": "33c6deb2-f7ca-4d0f-ae6a-93bcd0a30b76",
      "name": "便签 11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 884,
        "content": "### **价格(最新)**"
      },
      "typeVersion": 1
    },
    {
      "id": "8207ae9a-ddf7-43e9-accb-155117ebcc54",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 1108,
        "content": "### **K 线(蜡烛图)**"
      },
      "typeVersion": 1
    },
    {
      "id": "0a1965e4-08cb-415d-912d-c154ec3fe103",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 1012,
        "content": "### **平均/标记价格**"
      },
      "typeVersion": 1
    },
    {
      "id": "944da462-023b-46ec-bd85-95f3e9c7d3ad",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 868,
        "content": "### **最近交易**"
      },
      "typeVersion": 1
    },
    {
      "id": "696106a9-6f82-4149-be59-266c409562bb",
      "name": "计算器",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        1520,
        592
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f62d4038-2114-4d76-a77d-2330ec9767b2",
      "name": "思考",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        1808,
        592
      ],
      "parameters": {
        "description": "### 🏷 工具:**思考**"
      },
      "typeVersion": 1.1
    },
    {
      "id": "5fef8e2d-9290-451e-a54e-759bd6cf02cb",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 836,
        "content": "### **计算器**"
      },
      "typeVersion": 1
    },
    {
      "id": "62f9ee31-ae28-40ae-8462-b41ba31d24dd",
      "name": "便签 16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1728,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 932,
        "content": "### **思考**"
      },
      "typeVersion": 1
    },
    {
      "id": "8f9284c5-dd6e-44c9-96d2-3c439aa99940",
      "name": "OKX AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -96,
        240
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "options": {
          "systemMessage": "You are the **OKX Spot Market Data Agent**.\n\nYou have **HTTP request access** to the official OKX REST API to retrieve market data for any requested OKX Spot trading pair.\nYour job is to **fetch and present data only**. You do **not** analyze, predict, or recommend.\n\n---\n\n## 🔗 API Access\n\n**Base endpoint (default):**\n\n* [https://www.okx.com](https://www.okx.com)\n\n**Format rules:**\n\n* All requests are **HTTP GET**\n* Responses are **JSON**\n* Parameters use query strings (e.g., `?instId=BTC-USDT`)\n* `instId` is always uppercase with `-` (e.g., `BTC-USDT`)\n\n---\n\n## 📌 Available Market Data Endpoints\n\n1. **Tickers (All or Single)**\n   `GET /api/v5/market/tickers?instType=SPOT`\n   `GET /api/v5/market/ticker?instId=BTC-USDT`\n   • Real-time ticker for one or all Spot instruments.\n\n2. **Order Book Depth**\n   `GET /api/v5/market/books?instId=BTC-USDT&sz=50`\n   • Returns bids/asks with depth (size configurable).\n\n3. **Recent Trades**\n   `GET /api/v5/market/trades?instId=BTC-USDT&limit=100`\n   • Most recent trades for a symbol.\n\n4. **Candlestick / Kline Data**\n   `GET /api/v5/market/candles?instId=BTC-USDT&bar=15m&limit=100`\n   • Supported intervals: `1m, 3m, 5m, 15m, 30m, 1H, 2H, 4H, 6H, 12H, 1D, 1W, 1M`\n   • Default limit = 100 (max 100).\n\n5. **24h Stats (Ticker Details)**\n   `GET /api/v5/market/ticker?instId=BTC-USDT`\n   • Includes open, high, low, last, volume, % change, etc.\n\n6. **Average Price (Mark Price)**\n   `GET /api/v5/market/mark-price?instType=SPOT&instId=BTC-USDT`\n   • Use `markPx` as the fair/average reference price.\n\n---\n\n## 🧩 Utility Tools\n\n* **Calculator** → Perform math inside the workflow (spreads, % changes, etc).\n* **Think** → Lightweight reasoning helper to reshape JSON, select fields, and prepare outputs.\n\n---\n\n## 📤 Output Format\n\nRespond with **clean, structured text** (no HTML required). Example grouping:\n\n```\nBTC-USDT — OKX Spot Data\n\nPrice\n• Last: 58000.12\n• Avg (Mark): 57980.55\n• Change (24h): +2.4%\n\n24h Stats\n• Open: 56500 • High: 58500 • Low: 56200 • Volume: 12,430 BTC • Quote Vol: 720M USDT\n\nOrder Book (Top 5)\n• Bids: [57990 x 0.5], [57980 x 1.2], …\n• Asks: [58010 x 0.8], [58020 x 1.5], …\n\nKlines (15m, latest 5)\n• O/H/L/C: 57800 / 58020 / 57750 / 57990\n```\n\n---\n\n## ⚠️ Rules\n\n* Always **call the correct OKX API endpoint** for the requested data.\n* Do **not** fabricate or calculate values yourself (except simple formatting).\n* Do **not** provide trading advice, sentiment, or predictions.\n* Do **not** output raw JSON; always present clean, human-readable values.\n* If data is missing or request fails, show `N/A`.\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "40071070-f676-4f72-a913-eadc349c5d9e",
      "name": "24 小时统计数据",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -720,
        592
      ],
      "parameters": {
        "url": "https://www.okx.com/api/v5/market/ticker",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "instId",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **24h Stats (Ticker)**\n\n**Endpoint:** `GET /api/v5/market/ticker`\n**What it does:** Returns 24h stats for a Spot instrument: **last**, **open24h**, **high24h**, **low24h**, **vol24h (base)**, **volCcy24h (quote)**, **price change %**, etc.\n\n**Params:**\n* `instId` (STRING, required) — instrument id, e.g. `BTC-USDT`\n\n**n8n query mapping:**\n\n```txt\ninstId = $fromAI('parameters0_Value', '', 'string')\n```\n\n**Notes:** `instId` must be UPPERCASE with a hyphen, e.g. `ETH-USDT`."
      },
      "typeVersion": 4.2
    },
    {
      "id": "2eca8bad-e582-43bc-b2f9-6dc36d3de490",
      "name": "订单簿深度",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -400,
        592
      ],
      "parameters": {
        "url": "https://www.okx.com/api/v5/market/books",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "instId",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "sz",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `25`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Order Book Depth**\n\n**Endpoint:** `GET /api/v5/market/books`\n**What it does:** Returns order book **bids/asks** up to `sz` (default 25).\n\n**Params:**\n\n* `instId` (STRING, required) — instrument id, e.g. `BTC-USDT`\n* `sz` (INT, optional; default 25; max 400)\n\n**Returns:** `asks`, `bids`, `ts`\n\n**n8n query mapping:**\n\n```txt\ninstId = $fromAI('parameters0_Value', '', 'string')\nsz     = $fromAI('parameters1_Value', 25, 'number')\n```\n\n**Notes:** Unlike Binance `limit`, OKX uses `sz` with max 400."
      },
      "typeVersion": 4.2
    },
    {
      "id": "7e353ddc-98d5-45b0-b868-f42c74154008",
      "name": "价格(最新)",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -112,
        592
      ],
      "parameters": {
        "url": "https://www.okx.com/api/v5/market/ticker",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "instId",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Price (Latest)**\n\n**Endpoint:** `GET /api/v5/market/ticker`\n**What it does:** Returns the **latest trade price** for an instrument.\n\n**Params:**\n* `instId` (STRING, required) — instrument id, e.g. `BTC-USDT`\n\n**Returns:** `{ \"instId\":\"BTC-USDT\", \"last\":\"...\", \"askPx\":\"...\", \"bidPx\":\"...\", \"high24h\":\"...\", \"low24h\":\"...\" }`\n\n**n8n query mapping:**\n\n```txt\ninstId = $fromAI('parameters0_Value', '', 'string')\n```\n\n**Notes:** OKX always requires `instId` with dash format (e.g., `BTC-USDT`)."
      },
      "typeVersion": 4.2
    },
    {
      "id": "2474c7bf-34c2-4f71-9ba2-88c9f364c81c",
      "name": "最佳买/卖价",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        208,
        592
      ],
      "parameters": {
        "url": "https://www.okx.com/api/v5/market/ticker",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "instId",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Best Bid/Ask (Book Ticker)**\n\n**Endpoint:** `GET /api/v5/market/ticker`\n**What it does:** Provides the **best bid/ask** prices and sizes for an instrument.\n\n**Params:**\n* `instId` (STRING, required) — instrument id, e.g. `BTC-USDT`\n\n**Returns:** `{ \"instId\":\"BTC-USDT\", \"bidPx\":\"...\", \"bidSz\":\"...\", \"askPx\":\"...\", \"askSz\":\"...\" }`\n\n**n8n query mapping:**\n\n```txt\ninstId = $fromAI('parameters0_Value', '', 'string')\n```\n\n**Notes:** Unlike Binance, OKX’s `ticker` response includes last price, open24h, high24h, low24h, and **best bid/ask** in the same payload."
      },
      "typeVersion": 4.2
    },
    {
      "id": "d16b1649-1233-448c-af6f-9294a59c2f73",
      "name": "K线(蜡烛图)",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        560,
        592
      ],
      "parameters": {
        "url": "https://www.okx.com/api/v5/market/candles",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "instId",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "bar",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `15m`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Value', `20`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Klines (Candles)**\n\n**Endpoint:** `GET /api/v5/market/candles`\n**What it does:** Returns candlestick (OHLCV) bars for an instrument.\n\n**Params:**\n\n* `instId` (STRING, required) — instrument ID (e.g., `BTC-USDT`)\n* `bar` (ENUM, required) — interval, e.g. `1m,3m,5m,15m,30m,1H,2H,4H,6H,12H,1D,1W,1M`\n* `limit` (INT, optional, default 100; max 100)\n* `after` / `before` (optional, pagination)\n\n**Returns (array per candle):** `[ ts, o, h, l, c, vol, volCcy, volCcyQuote, confirm ]`\n\n**n8n query mapping:**\n\n```txt\ninstId = $fromAI('parameters0_Value', '', 'string')\nbar    = $fromAI('parameters1_Value', '15m', 'string')\nlimit  = $fromAI('parameters2_Value', 20, 'number')\n```\n\n**Notes:**\n* Binance uses `symbol`/`interval`; OKX uses `instId`/`bar`.\n* `limit` max is **100** (not 1000 like Binance)."
      },
      "typeVersion": 4.2
    },
    {
      "id": "45d7b0d9-8c95-479f-8cc0-6f48983e217e",
      "name": "平均/标记价格",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        880,
        592
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', ``, 'string') }}",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "instType",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "instId",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Average / Mark Price**\n\n**Endpoint:** `GET /api/v5/market/mark-price`\n**What it does:** Returns the **mark price** (reference fair price) for an instrument, which can serve as an 'average-like' indicator.\n\n**Params:**\n\n* `instType` (STRING, required) — e.g., `SPOT`\n* `instId` (STRING, required) — instrument ID (e.g., `BTC-USDT`)\n\n**Returns:** `[{ instType, instId, markPx, ts }]`\n\n**n8n query mapping:**\n\n```txt\ninstType = 'SPOT'\ninstId   = $fromAI('parameters0_Value', '', 'string')\n```\n\n**Notes:**\n* Binance’s `/avgPrice` gives a rolling average — OKX does not have this directly.\n* Use `markPx` as the closest equivalent (widely used as the fair price across markets)."
      },
      "typeVersion": 4.2
    },
    {
      "id": "c8925c12-b11d-45be-8bee-41d64d8122e3",
      "name": "最近交易",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        1216,
        608
      ],
      "parameters": {
        "url": "https://www.okx.com/api/v5/market/trades",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "instId",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `100`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Recent Trades**\n\n**Endpoint:** `GET /api/v5/market/trades`\n**What it does:** Returns the **most recent public trades** for an OKX Spot instrument.\n\n**Params:**\n* `instId` (STRING, required) — instrument id, e.g. `BTC-USDT`\n* `limit`  (INT, optional; default 100, max 100)\n\n**Returns:** array of trades like `{ tradeId, px, sz, side, ts, instId }`.\n\n**n8n query mapping:**\n```txt\ninstId = $fromAI('parameters0_Value', '', 'string')\nlimit  = $fromAI('parameters1_Value', 100, 'number')\n```\n\n**Notes:** `instId` must be UPPERCASE with a hyphen (e.g., `ETH-USDT`)."
      },
      "typeVersion": 4.2
    },
    {
      "id": "ffa14c26-a607-4793-820f-0bd8ee93de32",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2112,
        -688
      ],
      "parameters": {
        "width": 1424,
        "height": 2256,
        "content": "# 🧠 OKX 现货市场数据 AI Agent – 完整系统文档"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d8300b40-9963-44cd-908a-609073e7b2c6",
  "connections": {
    "Think": {
      "ai_tool": [
        [
          {
            "node": "OKX  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "24h Stats": {
      "ai_tool": [
        [
          {
            "node": "OKX  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "OKX  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Best Bid/Ask": {
      "ai_tool": [
        [
          {
            "node": "OKX  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OKX  AI Agent": {
      "main": [
        [
          {
            "node": "Splits message is more than 4000 characters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recent Trades": {
      "ai_tool": [
        [
          {
            "node": "OKX  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "OKX  AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Price (Latest)": {
      "ai_tool": [
        [
          {
            "node": "OKX  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Adds \"SessionId\"": {
      "main": [
        [
          {
            "node": "OKX  AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Klines (Candles)": {
      "ai_tool": [
        [
          {
            "node": "OKX  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Order Book Depth": {
      "ai_tool": [
        [
          {
            "node": "OKX  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": "OKX  AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Average / Mark Price": {
      "ai_tool": [
        [
          {
            "node": "OKX  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": "Telegram",
            "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 查看

分享此工作流