AutomationFlowsAI & RAG › Real-time Crypto Market Data From Gate.io with Gpt-4o and Telegram

Real-time Crypto Market Data From Gate.io with Gpt-4o and Telegram

ByDon Jayamaha Jr @don-the-gem-dealer on n8n.io

Instantly fetch live Gate.io Spot Market data directly in Telegram!

Event trigger★★★★★ complexityAI-powered35 nodesOpenAI ChatTelegram TriggerMemory Buffer WindowTool CalculatorTool ThinkAgentHTTP Request ToolTelegram
AI & RAG Trigger: Event Nodes: 35 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #8608 — we link there as the canonical source.

This workflow follows the Agent → HTTP Request Tool recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "wJXl7mSb4EhDi6mT",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Gate AI Agent v1.02",
  "tags": [],
  "nodes": [
    {
      "id": "cf0da4b9-ff10-47c7-8b7e-217b3889d871",
      "name": "OpenAI Chat Model",
      "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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "efc44a96-36af-457d-a28e-022dbfcc8149",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1008,
        240
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e6eed75c-75dd-4f7a-93d1-5c65ef2a1aa9",
      "name": "User Authentication (Replace 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": "Adds \"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": "Splits message is more than 4000 characters",
      "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": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        -32
      ],
      "parameters": {
        "color": 4,
        "height": 460,
        "content": "## Trigger Incoming Telegram Command\nNode: Telegram Trigger\n**Listens for new Telegram messages** from users.\nTriggers the full agent process and passes raw user input downstream."
      },
      "typeVersion": 1
    },
    {
      "id": "ea50b5ad-9086-46a3-99f7-2a62979a28ef",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        -32
      ],
      "parameters": {
        "color": 2,
        "height": 460,
        "content": "## Validate User Access\nNode: User **Authentication\nChecks incoming Telegram ID** against the approved user list."
      },
      "typeVersion": 1
    },
    {
      "id": "e5070b89-c14e-44bb-9bc6-51b3e2b1a459",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -32
      ],
      "parameters": {
        "color": 5,
        "height": 460,
        "content": "## Generate Session Metadata\nNode: Add S**essionId\nCreates a sessionId using the Telegram chat_id**.\nThis is passed into all downstream tools for memory and workflow routing."
      },
      "typeVersion": 1
    },
    {
      "id": "17693c7a-9c4b-4067-bf38-32b177a73c7c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -336
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 772,
        "content": "## Main AI Agent: Data Fetcher\n\n**Node: Gate Data Agent**\nThis is the **core orchestrator**. It uses OpenAI only to **format and present raw Gate.io Spot market data**, not to analyze or generate strategies.\n\nIt has direct **HTTP GET access** to the Gate.io REST **v4 API** and retrieves:\n\n* **Latest price & 24h stats** (`/spot/tickers`)\n* **Order book depth** (`/spot/order_book`)\n* **Best bid/ask** (via `/spot/order_book?limit=1`)\n* **Klines / candlesticks** (`/spot/candlesticks`)\n* **Recent trades** (`/spot/trades`)\n\nThe agent calls these endpoints in parallel for the requested currency pair, validates results, and then **presents the data in clean Telegram text format**.\n\nIt does **not**:\n\n* Perform technical analysis\n* Generate strategies or predictions\n* Fetch sentiment or news"
      },
      "typeVersion": 1
    },
    {
      "id": "58ddff39-608d-41db-b89e-a3d4c7571de0",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -32
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 460,
        "content": "## Handle Telegram Message Limits\nNode: Code (split logic)\nChecks if the **GPT output exceeds 4000 characters**.\nIf so, it splits the message into safe chunks and passes them on sequentially."
      },
      "typeVersion": 1
    },
    {
      "id": "1b0a5854-f183-4a9d-a967-23802393de90",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        -32
      ],
      "parameters": {
        "color": 4,
        "height": 460,
        "content": "## Send Final Report to Telegram\nNode: Telegram sendMessage\nSends **formatted HTML report (or split chunks)** directly to the authenticated user via Telegram bot."
      },
      "typeVersion": 1
    },
    {
      "id": "df1fb332-093a-4669-91a1-b4004ff09a4d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        640
      ],
      "parameters": {
        "height": 540,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## GPT Model for Reasoning\nNode: OpenAI Chat Model\nModel: **gpt-4o-mini**\nUsed to:\n\nInterpret signal values\n\nGenerate structured HTML\n\n**Recommend spot and leverage trades**\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "92146023-977e-47ff-9e90-bedf05f06262",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 884,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **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) \u2192 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": 1
    },
    {
      "id": "020081b2-6d5f-4b7b-8d5a-bd4151722cd0",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 868,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **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) \u2192 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": 1
    },
    {
      "id": "9af111a2-e1b5-46bb-b00f-75a6ab07abd5",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        640
      ],
      "parameters": {
        "color": 3,
        "height": 540,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Short-Term Memory Module\nNode: **Simple Memory\nStores the sessionId**, symbol, and other state data.\nUseful for:\n\nMulti-turn Telegram interactions\n\nTracking indicator agreement across timeframes\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0ff5fedb-9d7b-42a8-9460-5daf76ca91f9",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -992,
        736
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "a8f8c1cb-9e8b-450c-a7b7-be72ab2538d7",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -784,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 932,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **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) \u2192 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": 1
    },
    {
      "id": "043ebb93-f65a-419d-b2b8-2931044195a0",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 820,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **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) \u2192 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": 1
    },
    {
      "id": "7640a82a-5936-4d4e-8258-257763c524b4",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 1012,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **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) \u2192 format: `BASE_QUOTE` (e.g., BTC_USDT)\n* `interval` (STRING, required) \u2192 e.g., `1m,5m,15m,30m,1h,4h,1d,1w` (others may be supported)\n* `limit` (INT, optional) \u2192 number of candles to return (**we default 20**)\n* `from`, `to` (INT, optional) \u2192 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": 1
    },
    {
      "id": "840c6704-acf8-43c0-9808-dbef0cc97cfd",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 788,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **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) \u2192 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": 1
    },
    {
      "id": "0817d422-51a8-4d74-9b91-461d68681799",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 900,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### \ud83c\udff7 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) \u2192 format: `BASE_QUOTE` (e.g., BTC_USDT)\n* `limit` (INT, optional) \u2192 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": 1
    },
    {
      "id": "5ed3cd36-3f49-4484-91b0-e9dc8d81a018",
      "name": "Calculator",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        1520,
        592
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "00a91265-2c7f-4150-b47c-eb537a7c6b6c",
      "name": "Think",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        1808,
        592
      ],
      "parameters": {
        "description": "### \ud83c\udff7 Tool: **Think**\n\n**Purpose:**\n\n* Lightweight **reasoning helper**.\n* Lets the AI Agent process intermediate logic, format outputs, or decide how to combine multiple API results before sending the final report.\n* Does not fetch data itself.\n\n**Use cases:**\n\n* Clean/reshape JSON from Binance endpoints\n* Extract only the needed fields (e.g., `lastPrice`, `volume`)\n* Help prepare data for Telegram message formatting\n\n**n8n setup notes:**\n\n* No API call, just an **AI Tool** node.\n* Connect upstream API results \u2192 Think \u2192 Report Agent."
      },
      "typeVersion": 1.1
    },
    {
      "id": "dc07a5c2-1922-4f90-9ba2-07e155af5ed5",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 836,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Calculator**\n\n**Purpose:**\n\n* Perform **math operations** inside the workflow.\n* Supports add/subtract/multiply/divide, percentages, rounding, etc.\n\n**Use cases:**\n\n* Calculate spreads (ask \u2013 bid)\n* Compute % changes from open vs. last price\n* Normalize volumes or confidence scores\n\n**n8n setup notes:**\n\n* Node: `Calculator` (n8n built-in)\n* Input fields can come from Binance API JSON\n* Output can be chained into Think \u2192 Final Report\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1ea6c681-34a5-4e70-a8ef-c12f9f56a02f",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1728,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 932,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Think**\n\n**Purpose:**\n\n* Lightweight **reasoning helper**.\n* Lets the AI Agent process intermediate logic, format outputs, or decide how to combine multiple API results before sending the final report.\n* Does not fetch data itself.\n\n**Use cases:**\n\n* Clean/reshape JSON from Binance endpoints\n* Extract only the needed fields (e.g., `lastPrice`, `volume`)\n* Help prepare data for Telegram message formatting\n\n**n8n setup notes:**\n\n* No API call, just an **AI Tool** node.\n* Connect upstream API results \u2192 Think \u2192 Report Agent."
      },
      "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** \u2014 no analysis, predictions, or advice.\n\n---\n\n## \ud83d\udd17 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## \ud83d\udccc 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 \u201caverage price\u201d endpoint. If needed, compute midpoint `(best_bid + best_ask) / 2` in the **Calculator** node.\n* No separate \u201cbookTicker\u201d endpoint; use **Order Book** with `limit=1` for best bid/ask.\n\n---\n\n## \ud83e\udde9 Utility Tools\n\n* **Calculator** \u2014 optional simple math (spread, midpoint, % change).\n* **Think** \u2014 reshape JSON and format the final Telegram message.\n\n---\n\n## \ud83d\udce4 Output Format (Telegram text)\n\nStart with:\n\n```\nBTC_USDT \u2014 Gate Spot Data\n```\n\nThen group logically:\n\n```\nPrice\n\u2022 Last: 26250\n\u2022 Best Bid / Ask: 26245 / 26255\n\u2022 Change (24h): -1.2%\n\n24h Stats\n\u2022 Open: 26500 \u2022 High: 27000 \u2022 Low: 26000 \u2022 Close: 26250\n\u2022 Volume: 1,234 BTC \u2022 Quote Vol: 32,000,000 USDT\n\nOrder Book (Top 5)\n\u2022 Bids: [26245 x 0.5], [26244 x 1.2] \u2026\n\u2022 Asks: [26255 x 0.8], [26256 x 1.5] \u2026\n\nCandles (latest 20)\n\u2022 Interval: 15m (O/H/L/C per candle)\n```\n\n---\n\n## \u26a0\ufe0f 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 \u2014 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": "24h Stats",
      "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": "### \ud83c\udff7 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) \u2192 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": "Order Book Depth",
      "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": "### \ud83c\udff7 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) \u2192 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": "Price (Latest)",
      "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": "### \ud83c\udff7 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) \u2192 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": "Best Bid/Ask",
      "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": "### \ud83c\udff7 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) \u2192 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": "Klines (Candles)",
      "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": "### \ud83c\udff7 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) \u2192 format: `BASE_QUOTE` (e.g., BTC_USDT)\n* `interval` (STRING, required) \u2192 e.g., `1m,5m,15m,30m,1h,4h,1d,1w` (others may be supported)\n* `limit` (INT, optional) \u2192 number of candles to return (**we default 20**)\n* `from`, `to` (INT, optional) \u2192 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": "24h Stats (Ticker)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": "### \ud83c\udff7 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) \u2192 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": "Recent Trades",
      "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": "### \ud83c\udff7 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) \u2192 format: `BASE_QUOTE` (e.g., BTC_USDT)\n* `limit` (INT, optional) \u2192 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": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        896,
        240
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": true
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4d084614-f0d0-4d59-8cc6-baa2676b084e",
      "name": "Sticky Note17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2272,
        -800
      ],
      "parameters": {
        "width": 1424,
        "height": 2608,
        "content": "# \ud83e\udde0 Gate Spot Market Data AI Agent \u2013 Full System Documentation\n\nA production-ready AI automation system for **Gate.io Spot Market data retrieval**.  \nThis agent fetches **raw market data directly from the Gate.io REST v4 API** and presents it in clean **Telegram-ready reports**.  \n\u26a0\ufe0f **No technical analysis, predictions, or strategies are performed.** It is a pure data delivery agent.\n\n---\n\n## \ud83e\udde9 Included Workflows & Tools\n\nThe system is built entirely in **n8n** and consists of these active components:\n\n| \u2705 Node / Tool            | \ud83d\udccc Function Description                                                                 |\n| ------------------------- | --------------------------------------------------------------------------------------- |\n| **Telegram Trigger**      | Listens for new Telegram messages from users.                                           |\n| **User Authentication**   | Validates incoming Telegram ID to ensure only approved user(s) can access the agent.    |\n| **Adds SessionId**        | Creates sessionId from Telegram chat ID, used across downstream nodes.                  |\n| **Simple Memory**         | Stores session context (chat, symbol, etc.) for short-term memory.                      |\n| **Gate AI Agent**         | The orchestrator. Calls all Gate.io Spot API tools and formats them via OpenAI.         |\n| **OpenAI Chat Model**     | GPT-4.1-mini model. Handles message structuring and clean HTML formatting.              |\n| **24h Stats Tool**        | Calls `/spot/tickers` for 24h stats (last price, high/low, % change, volumes).          |\n| **Order Book Depth Tool** | Calls `/spot/order_book` for bids/asks up to limit (default 100).                       |\n| **Best Bid/Ask Tool**     | Calls `/spot/order_book?limit=1` for top of book snapshot.                              |\n| **Price (Latest)**        | Calls `/spot/tickers` (field: `last`) for latest trade price.                           |\n| **Klines (Candles)**      | Calls `/spot/candlesticks` for OHLCV data (default 20 candles, 15m interval).           |\n| **Recent Trades**         | Calls `/spot/trades` for the most recent 100 trades.                                    |\n| **24h Stats (Ticker)**    | Additional ticker stats endpoint variant from `/spot/tickers`.                          |\n| **Calculator**            | Optional. Computes spreads, % changes, averages.                                        |\n| **Think Tool**            | Optional reasoning/reshaping helper. Formats JSON before final report.                  |\n| **Splitter Node**         | Splits GPT output if >4000 chars (Telegram message limit).                              |\n| **Send to Telegram**      | Sends final HTML-formatted report (or split chunks) back to user.                       |\n\n---\n\n## \u2699\ufe0f Installation Instructions\n\n### Step 1: Import Workflow\n* Open **n8n Editor UI**\n* Import `Gate AI Agent v1.02.json`\n* Save & activate workflow\n\n### Step 2: Set Credentials\n* **OpenAI API Key** \u2014 configure GPT model access\n* **Telegram Bot API** \u2014 connect your bot token and replace Telegram ID in the auth node\n\n### Step 3: Configure Agent\n* Edit **User Authentication node** \u2192 replace Telegram ID (`2028836793`) with your own\n* Default session handling is automatic (`chat.id` \u2192 sessionId)\n\n### Step 4: Verify Gate.io Endpoints\n* No authentication required (all endpoints are **public**)\n* API base: `https://api.gateio.ws/api/v4`\n* Pair format: `BASE_QUOTE` (e.g., `BTC_USDT`)\n\n---\n\n## \ud83d\udda5\ufe0f System Workflow Overview\n\n```\n\n\\[Telegram Trigger]\n\u2192 \\[User Authentication]\n\u2192 \\[Adds SessionId]\n\u2192 \\[Gate AI Agent]\n\u21b3 24h Stats\n\u21b3 Price (Latest)\n\u21b3 Order Book Depth\n\u21b3 Best Bid/Ask\n\u21b3 Klines (Candles)\n\u21b3 Recent Trades\n\u21b3 24h Stats (Ticker)\n\u21b3 Calculator\n\u21b3 Think\n\u2192 \\[Split if >4000 chars]\n\u2192 \\[Send Telegram Report]\n\n````\n\n---\n\n## \ud83d\udce4 Example Telegram Output\n\n```html\n<b>BTC_USDT \u2014 Gate Spot Data</b>\n\n<b>Price</b>\n\u2022 Last: 26,250\n\u2022 Best Bid / Ask: 26,245 / 26,255\n\u2022 Change (24h): -1.2%\n\n<b>24h Stats</b>\n\u2022 Open: 26,500 \u2022 High: 27,000 \u2022 Low: 26,000 \u2022 Close: 26,250\n\u2022 Volume: 1,234 BTC \u2022 Quote Vol: 32,000,000 USDT\n\n<b>Order Book (Top 5)</b>\n\u2022 Bids: [26,245 \u00d7 0.5], [26,244 \u00d7 1.2] \u2026\n\u2022 Asks: [26,255 \u00d7 0.8], [26,256 \u00d7 1.5] \u2026\n\n<b>Candles</b>\n\u2022 Interval: 15m (latest 20 OHLCV rows)\n````\n\n---\n\n## \u26a0\ufe0f Rules of Operation\n\n* **Do not** generate analysis, advice, or strategies\n* **Do not** output raw JSON\n* On missing fields or errors, output `N/A`\n* Always return formatted clean text suitable for Telegram\n\n---\n\n## \ud83d\ude80 Support & Licensing\n\n\ud83d\udd17 **Don Jayamaha \u2013 LinkedIn**\n[linkedin.com/in/donjayamahajr](http://linkedin.com/in/donjayamahajr)\n\n\u00a9 2025 Treasurium Capital Limited Company.\nAll rights reserved. This system architecture, prompts, and workflow structure are proprietary and protected by **U.S. copyright law**.\nReuse or resale prohibited without license.\n\n\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "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
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Instantly fetch live Gate.io Spot Market data directly in Telegram!

Source: https://n8n.io/workflows/8608/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Jarvis is a powerful multi-agent productivity assistant built in n8n. It works directly from Telegram and can understand both text messages and voice notes.

Telegram Trigger, Telegram, OpenAI +10
AI & RAG

This multi-agent n8n workflow delivers an automated, intelligent trading analysis system for the WEEX Spot Market. It uses GPT-4o to interpret user prompts, route them to the correct sub-agent tools,

OpenAI Chat, Telegram Trigger, Agent +7
AI & RAG

AI-powered Telegram bot for effortless expense tracking. Send receipts, voice messages, or text - the bot automatically extracts and categorizes your expenses. 📸 Receipt & Invoice OCR - Send photos of

Telegram Trigger, Mcp Client Tool, Tool Calculator +7
AI & RAG

This template is designed for anyone who wants to use Telegram as a personal AI assistant hub. If you often juggle tasks, emails, calendars, and expenses across multiple tools, this workflow consolida

OpenAI Chat, Memory Buffer Window, Mcp Client Tool +11
AI & RAG

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Output Parser Structured, Telegram, N8N Nodes Tesseractjs +14