8
n8n 中文网amn8n.com

Upbit AI代理v1.02

高级

这是一个Crypto Trading, AI Chatbot, Multimodal AI领域的自动化工作流,包含 35 个节点。主要使用 Set, Code, Telegram, Agent, HttpRequestTool 等节点。 在Telegram中使用GPT-4o-mini访问Upbit加密货币市场数据

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "1P0wZUbdzeVsfStr",
  "meta": {
    "instanceId": "a5283507e1917a33cc3ae615b2e7d5ad2c1e50955e6f831272ddd5ab816f3fb6"
  },
  "name": "Upbit AI Agent v1.02",
  "tags": [],
  "nodes": [
    {
      "id": "65f5a5f3-53ae-4ec5-ba47-f97678991d8a",
      "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": "041e4483-e29f-4ba6-b733-7eac06085aaf",
      "name": "Telegram 触发器",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1008,
        240
      ],
      "webhookId": "4f251873-4004-4549-b390-9f3287930f17",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "NRLKuLR7z8vCesub",
          "name": "BinanceSpotTradingAIAgent_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4f3f7bdb-8e94-46be-8e57-2c2931d1b99b",
      "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": "469fd8a2-b369-493c-87e6-30ad1ecac215",
      "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": "1c8b1d16-6133-4346-8b57-7de7c7728d2c",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        896,
        240
      ],
      "webhookId": "0d8f53dc-fe8a-4093-926c-06b9179eb958",
      "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": "e802f5c0-2645-479b-bed4-501dedbb416f",
      "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": "801570b2-0b43-4e18-ac6e-6de6fd469417",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        -32
      ],
      "parameters": {
        "color": 4,
        "height": 460,
        "content": "## 触发传入的 Telegram 命令"
      },
      "typeVersion": 1
    },
    {
      "id": "9966b776-c71d-4fe3-ba2b-b67197b0d460",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        -32
      ],
      "parameters": {
        "color": 2,
        "height": 460,
        "content": "## 验证用户访问权限"
      },
      "typeVersion": 1
    },
    {
      "id": "31accad8-885b-4670-bd23-2039e154ad30",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -32
      ],
      "parameters": {
        "color": 5,
        "height": 460,
        "content": "## 生成会话元数据"
      },
      "typeVersion": 1
    },
    {
      "id": "f526d222-bb30-4201-a090-72d71961f679",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -208
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 644,
        "content": "### 📝 主代理说明(便签式,可复制粘贴)"
      },
      "typeVersion": 1
    },
    {
      "id": "8cf34baa-e329-42b5-99a1-dc7526edabaa",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -32
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 460,
        "content": "## 处理 Telegram 消息限制"
      },
      "typeVersion": 1
    },
    {
      "id": "ce8ee7ff-5b58-4413-80da-28b191c786f7",
      "name": "便利贴5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        -32
      ],
      "parameters": {
        "color": 4,
        "height": 460,
        "content": "## 发送最终报告到 Telegram"
      },
      "typeVersion": 1
    },
    {
      "id": "6686c779-cdb7-4413-936f-5527190342e6",
      "name": "便签 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        640
      ],
      "parameters": {
        "height": 540,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "6390def9-a6a1-4aae-a9b6-204075756b3f",
      "name": "便签 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 980,
        "content": "## 用于推理的 GPT 模型"
      },
      "typeVersion": 1
    },
    {
      "id": "41691a52-2ca2-4cd9-aba0-97139f8f6e67",
      "name": "便签8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 932,
        "content": "### **订单簿深度**"
      },
      "typeVersion": 1
    },
    {
      "id": "28671723-092c-49c7-8038-cb10677b41b7",
      "name": "便签 9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        640
      ],
      "parameters": {
        "color": 3,
        "height": 540,
        "content": "### **最佳买价/卖价(订单簿快照)**"
      },
      "typeVersion": 1
    },
    {
      "id": "907b0af3-b626-46da-90dd-6d58f219bfa9",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -992,
        736
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "6c479a7a-ff73-4b8d-9f8a-079a60f80af7",
      "name": "便签10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -784,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 1124,
        "content": "## 短期记忆模块"
      },
      "typeVersion": 1
    },
    {
      "id": "90ec97ef-7eb9-4071-a9c2-ef8f8440f313",
      "name": "便签11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 980,
        "content": "### **24 小时统计**"
      },
      "typeVersion": 1
    },
    {
      "id": "9bd5a13c-3346-40c0-a8b1-9a34632c43cf",
      "name": "便签12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 1332,
        "content": "### **价格(最新)**"
      },
      "typeVersion": 1
    },
    {
      "id": "7b656884-eeb9-433c-90e0-dd8bd19fc19d",
      "name": "便签13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 948,
        "content": "### **动态 K 线图(一个节点支持所有时间框架)**"
      },
      "typeVersion": 1
    },
    {
      "id": "f4717caf-540e-4ced-90d9-825d200a0154",
      "name": "便签14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 868,
        "content": "### **平均价格(VWAP)**"
      },
      "typeVersion": 1
    },
    {
      "id": "9adcbbd2-1f62-4779-b1bd-0c3792042110",
      "name": "计算器",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        1520,
        592
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c5fc3093-d51e-430e-bd5b-59a79d07c835",
      "name": "思考",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        1808,
        592
      ],
      "parameters": {
        "description": "### **最近交易**"
      },
      "typeVersion": 1.1
    },
    {
      "id": "883e49b1-ec6b-4865-9595-7d6890022d6d",
      "name": "便签15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 836,
        "content": "### 🏷 工具:**思考**"
      },
      "typeVersion": 1
    },
    {
      "id": "aad0c76e-5a27-41c7-847e-8fa03d078db4",
      "name": "便签16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1728,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 932,
        "content": "### **计算器**"
      },
      "typeVersion": 1
    },
    {
      "id": "3c3cad01-5bfd-475a-9ab1-ae790be6bd4d",
      "name": "### **思考**",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -96,
        240
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "options": {
          "systemMessage": "You are the **Upbit Spot Market Data Agent**.\n\nYou have **HTTP GET access** to the official Upbit REST API and must **fetch and present market data only** for requested Upbit Spot markets. You do **not** analyze, predict, or recommend.\n\n#### API base\n\n* `https://api.upbit.com`\n\n#### Request/format rules\n\n* All requests are **HTTP GET** returning **JSON**.\n* Query strings for params (e.g., `?markets=KRW-BTC`).\n* Market codes are uppercase with a hyphen (e.g., `KRW-BTC`, `USDT-ETH`).\n* If anything fails or is missing, show `N/A`.\n\n#### Available endpoints\n\n1. **Market list** – `GET /v1/market/all`\n2. **Tickers (price + 24h stats)** – `GET /v1/ticker?markets=KRW-BTC[,…]`\n3. **Tickers by quote** – `GET /v1/tickers?quote_currencies=KRW|BTC|USDT`\n4. **Order book** – `GET /v1/orderbook?markets=KRW-BTC`\n5. **Supported levels** – `GET /v1/orderbook/supported_levels?markets=KRW-BTC`\n6. **Recent trades** – `GET /v1/trades/ticks?market=KRW-BTC&count=100`\n7. **Candles (dynamic)** – `GET /v1/candles/{seconds | minutes/{unit} | days | weeks | months | years}`\n\n#### Dynamic candles (single tool, auto-select path)\n\n* Input `tf` decides the path:\n\n  * `1s, 30s` → `seconds`\n  * `1m,3m,5m,10m,15m,30m,60m,240m` → `minutes/{unit}`\n  * `1h,2h,4h` → map to `minutes/60`, `minutes/120`, `minutes/240`\n  * `1d` → `days`, `1w` → `weeks`, `1M` → `months`, `1y` → `years`\n* Common params: `market` (e.g., `KRW-BTC`), `count`/`limit` (default 100, max 200), optional `to` ISO8601.\n\n#### Utility tools\n\n* **Calculator**: spreads, % changes, lightweight math.\n* **Think**: reshape/clean JSON, select fields, prepare text.\n\n#### Output style\n\nReturn **clean, structured text** (no HTML). Example:\n\n```\nKRW-BTC — Upbit Spot Data\n\nPrice\n• Last: 95,800,000 KRW\n• Change (24h): +2.3%\n\n24h Stats\n• Open: 93,500,000 • High: 96,200,000 • Low: 92,800,000 • Volume: 12,345 BTC\n\nOrder Book (Top 5)\n• Bids: [95,790,000 x 0.50], [95,780,000 x 1.20], …\n• Asks: [95,810,000 x 0.80], [95,820,000 x 1.50], …\n\nKlines (15m, latest 5)\n• O/H/L/C: 95,700,000 / 95,820,000 / 95,600,000 / 95,800,000\n```\n\n#### Rules\n\n* Always call the correct Upbit endpoint for the user’s request.\n* Never fabricate values (formatting/math only).\n* No strategies, advice, or sentiment.\n* Prefer concise, human-readable values over raw JSON.\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "052801e0-4631-4466-bd04-84ea68320d28",
      "name": "Upbit AI Agent",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -704,
        592
      ],
      "parameters": {
        "url": "https://api.upbit.com/v1/ticker",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "markets",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `KRW-BTC`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **24h Stats**\n\n**Endpoint:** `GET /v1/ticker`\n**What it does:** Real-time price and 24-hour rolling stats for one or more markets: **open/high/low/last**, **24h change**, **base/quote volume**, etc.\n\n**Params:**\n\n* `markets` (STRING, required) — one or more market codes, comma-separated. Examples: `KRW-BTC`, `USDT-BTC`, `KRW-BTC,KRW-ETH`.\n\n**Returns (key fields):** `trade_price` (last), `opening_price`, `high_price`, `low_price`, `signed_change_rate`, `signed_change_price`, `acc_trade_volume_24h`, `acc_trade_price_24h`, `prev_closing_price`, `timestamp`, etc.\n\n**n8n query mapping:**\n\n```txt\nmarkets = $fromAI('parameters0_Value', 'KRW-BTC', 'string')\n```\n\n**Notes:**\n* Market codes are uppercase with a hyphen (e.g., `KRW-BTC`).\n* Multiple markets are supported via comma separation."
      },
      "typeVersion": 4.2
    },
    {
      "id": "54bdf0b7-4d92-4a86-a5fe-99f7fd283a09",
      "name": "24 小时统计",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -400,
        592
      ],
      "parameters": {
        "url": "https://api.upbit.com/v1/orderbook",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "markets",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `KRW-BTC`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Order Book Depth**\n\n**Endpoint:** `GET /v1/orderbook`\n**What it does:** Returns **order book** with bids/asks and total sizes.\n\n**Params:**\n\n* `markets` (STRING, required) — market code, e.g., `KRW-BTC`.\n\n**Returns:** `orderbook_units` array with `ask_price`, `bid_price`, `ask_size`, `bid_size` (top ~15 levels by default).\n\n**n8n query mapping:**\n\n```txt\nmarkets = $fromAI('parameters0_Value', 'KRW-BTC', 'string')\n```\n\n**Notes:**\n* Upbit does not support arbitrary `limit` — it returns a fixed number of levels (usually 15).\n* Market codes use hyphen format (e.g., `KRW-BTC`)."
      },
      "typeVersion": 4.2
    },
    {
      "id": "cbcbba24-d5a8-4229-a043-d0bced05ae06",
      "name": "订单簿深度",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -112,
        592
      ],
      "parameters": {
        "url": "https://api.upbit.com/v1/ticker",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "markets",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `KRW-BTC`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Price (Latest)**\n\n**Endpoint:** `GET /v1/ticker`\n**What it does:** Returns the **latest trade price** (and more stats) for a market.\n\n**Params:**\n* `markets` (STRING, required) — market code (e.g., `KRW-BTC`, `USDT-ETH`).\n\n**Returns:** Array with objects including `trade_price` (last price), `opening_price`, `high_price`, `low_price`, `prev_closing_price`, `acc_trade_volume`, `acc_trade_price`, `change`, `signed_change_rate`, etc.\n\n**n8n query mapping:**\n\n```txt\nmarkets = $fromAI('parameters0_Value', 'KRW-BTC', 'string')\n```\n\n**Notes:**\n* Always use **hyphenated format** (e.g., `KRW-BTC`).\n* Returns **more than just price** — can also be used instead of 24h stats."
      },
      "typeVersion": 4.2
    },
    {
      "id": "79da9179-4725-470a-a729-d064d41d074f",
      "name": "价格(最新)",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        208,
        592
      ],
      "parameters": {
        "url": "https://api.upbit.com/v1/orderbook",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "markets",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `KRW-BTC`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Best Bid/Ask (Orderbook Snapshot)**\n\n**Endpoint:** `GET /v1/orderbook`\n**What it does:** Returns the **best bid/ask** and order book depth for the given market.\n\n**Params:**\n* `markets` (STRING, required) — market code (e.g., `KRW-BTC`, `USDT-ETH`).\n\n**Returns:** Array with objects:\n* `orderbook_units`: [{ \"ask_price\", \"bid_price\", \"ask_size\", \"bid_size\" }, ...]\n* Top unit = **best bid/ask**.\n\n**n8n query mapping:**\n\n```txt\nmarkets = $fromAI('parameters0_Value', 'KRW-BTC', 'string')\n```\n\n**Notes:**\n* Use the first element of `orderbook_units` for **best bid/ask**.\n* You can expand to show more levels if needed."
      },
      "typeVersion": 4.2
    },
    {
      "id": "9d926768-3fee-450f-8b92-bc51d1c0c309",
      "name": "最佳买价/卖价",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        880,
        592
      ],
      "parameters": {
        "url": "https://api.upbit.com/v1/trades/ticks",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "market",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `KRW-BTC`, 'string') }}"
            },
            {
              "name": "count",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `30`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Average Price (VWAP)**\n\n**Endpoint:** `GET /v1/trades/ticks`\n**What it does:** Retrieves recent trades and can be used to calculate a rolling **average price (VWAP)** for a market.\n\n**Params:**\n* `market` (STRING, required) — e.g., `KRW-BTC`\n* `count` (INT, optional) — number of trades to fetch (default 30, max 200)\n\n**Returns:** Array of trades (`trade_price`, `trade_volume`, `timestamp`, etc.).\n\n**n8n mapping:**\n```txt\nmarket = $fromAI('parameters0_Value', 'KRW-BTC', 'string')\ncount  = $fromAI('parameters1_Value', 30, 'number')\n```\n\n**Notes:** Upbit doesn’t provide a direct avgPrice endpoint. Instead, VWAP or mean trade price is derived from the latest trades."
      },
      "typeVersion": 4.2
    },
    {
      "id": "7edfe1df-567c-4a7a-8d09-d87f1cd9031f",
      "name": "平均价格(VWAP)",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        1216,
        592
      ],
      "parameters": {
        "url": "https://api.upbit.com/v1/trades/ticks",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "market",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `KRW-BTC`, 'string') }}"
            },
            {
              "name": "count",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `30`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Recent Trades**\n\n**Endpoint:** `GET /v1/trades/ticks`\n**What it does:** Fetches the **most recent trades** for a market.\n\n**Params:**\n\n* `market` (STRING, required) — Upbit market ID (e.g., `KRW-BTC`, `USDT-ETH`).\n* `count` (INT, optional, default 30, max 200) — number of trades to fetch.\n\n**Returns:** array of trade objects `{trade_price, trade_volume, ask_bid, timestamp, sequential_id, ...}`\n\n**n8n query mapping:**\n\n```txt\nmarket = $fromAI('parameters0_Value', 'KRW-BTC', 'string')\ncount  = $fromAI('parameters1_Value', 30, 'number')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "2f16acde-faa2-4869-8b75-a5e5d5f003c4",
      "name": "最近交易",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        544,
        592
      ],
      "parameters": {
        "url": "={{ (function(){\n  const base = 'https://api.upbit.com/v1/candles/';\n  const tf = $fromAI('tf', '15m', 'string');\n  const m = (tf || '').trim();\n\n  // seconds (e.g., 1s, 30s)\n  if (/^\\d+s$/i.test(m)) {\n    return base + 'seconds';\n  }\n\n  // minutes direct (e.g., 1m, 3m, 5m, 10m, 15m, 30m, 60m, 240m)\n  const minMatch = m.match(/^(\\d+)m$/i);\n  if (minMatch) {\n    const unit = minMatch[1];\n    return base + 'minutes/' + unit;\n  }\n\n  // hours mapped to minutes\n  const hourMap = { '1':'60', '2':'120', '4':'240' };\n  const hrMatch = m.match(/^(\\d+)h$/i);\n  if (hrMatch && hourMap[hrMatch[1]]) {\n    return base + 'minutes/' + hourMap[hrMatch[1]];\n  }\n\n  // days, weeks, months, years\n  if (/^\\d+d$/i.test(m)) return base + 'days';\n  if (/^\\d+w$/i.test(m)) return base + 'weeks';\n  if (/^\\d+M$/i.test(m)) return base + 'months';\n  if (/^\\d+y$/i.test(m)) return base + 'years';\n\n  // fallback: 15m\n  return base + 'minutes/15';\n})() }}",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "market",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('market', `KRW-BTC`, 'string') }}"
            },
            {
              "name": "count",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('limit', `100`, 'number') }}"
            },
            {
              "name": "to",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('to', ``, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Dynamic Klines (All Timeframes in One Node)**\n\n**Endpoint (dynamic):** `GET /v1/candles/{seconds|minutes/{unit}|days|weeks|months|years}`\n**What it does:** Returns OHLCV candles for the requested Upbit market using **one node**. The path segment is chosen automatically from your `tf` (timeframe) input.\n\n**Accepted `tf` examples:**\n- `1s`, `30s` → **seconds**\n- `1m`, `3m`, `5m`, `10m`, `15m`, `30m`, `60m`, `240m` → **minutes/{unit}**\n- `1h`, `2h`, `4h` → mapped to **minutes/60**, **minutes/120**, **minutes/240**\n- `1d` → **days**\n- `1w` → **weeks**\n- `1M` → **months**\n- `1y` → **years**\n\n**Params:**\n* `market` (STRING, required) — e.g., `KRW-BTC`, `USDT-ETH`\n* `tf` (STRING, required) — timeframe token as above (default `15m`)\n* `limit` (INT, optional, default 100, max 200) — number of candles\n* `to` (STRING, optional) — ISO8601 end time (exclusive), e.g. `2025-09-15T09:00:00Z`\n\n**Notes:**\n* Upbit hours are done via minutes (e.g., `1h` → `minutes/60`).\n* Seconds endpoint exists but is limited in historical depth.\n* Response is an array of candles with fields like `opening_price`, `high_price`, `low_price`, `trade_price` (close), `candle_acc_trade_volume`, `timestamp`.\n"
      },
      "typeVersion": 4.2
    },
    {
      "id": "28fa8e05-0d29-4776-adea-459515f1ea00",
      "name": "便签17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2112,
        -1248
      ],
      "parameters": {
        "width": 1440,
        "height": 4256,
        "content": "Upbit K 线图(动态)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "99f3c302-0f14-4e73-a185-0aebffb3dcb3",
  "connections": {
    "Think": {
      "ai_tool": [
        [
          {
            "node": "Upbit  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "24h Stats": {
      "ai_tool": [
        [
          {
            "node": "Upbit  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "Upbit  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Best Bid/Ask": {
      "ai_tool": [
        [
          {
            "node": "Upbit  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Recent Trades": {
      "ai_tool": [
        [
          {
            "node": "Upbit  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Upbit  AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Price (Latest)": {
      "ai_tool": [
        [
          {
            "node": "Upbit  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Upbit  AI Agent": {
      "main": [
        [
          {
            "node": "Splits message is more than 4000 characters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Adds \"SessionId\"": {
      "main": [
        [
          {
            "node": "Upbit  AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Order Book Depth": {
      "ai_tool": [
        [
          {
            "node": "Upbit  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": "Upbit  AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Average Price (VWAP)": {
      "ai_tool": [
        [
          {
            "node": "Upbit  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Upbit Klines (Dynamic)": {
      "ai_tool": [
        [
          {
            "node": "Upbit  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 查看

分享此工作流