{
  "id": "H5bqsUPIPid2vFyk",
  "name": "Bitget AI Agent v1.02",
  "tags": [],
  "nodes": [
    {
      "id": "ce9b21f8-1f5d-49a0-8bfc-886439710297",
      "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": "f51b1ea0-88f6-47be-86d4-1460d05e2478",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1008,
        240
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3f52c9c4-97ca-44b2-a21d-b542bf219a99",
      "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": "769ecd3e-e739-4e24-8b3b-9cd8a13b2e5e",
      "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": "5854038c-1ac6-4a1c-9853-7361d5942a19",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        896,
        240
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4a5700e1-ef5d-4ae0-85fb-dfe0d3a9436c",
      "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": "ecc233de-5095-48f5-b5ea-0c383af58313",
      "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": "4ced49d4-c400-487f-93f0-6ac1d7de8704",
      "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": "d057cc29-426b-4769-8765-7263c1bd8f8e",
      "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": "83e47566-d233-404a-8c3c-b43212cfb2cd",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -512
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 964,
        "content": "# Main AI Agent: Data Fetcher (Bitget)\n\n**Node: Bitget Data Agent**\nThis is the **core orchestrator**. It uses OpenAI only to **format and present raw Bitget spot market data**, not to analyze or generate strategies.\n\nIt has direct **HTTP request access** to the Bitget REST API and retrieves:\n\n* **Live ticker (latest price & 24h stats)**\n  `GET /api/v2/spot/market/tickers`\n\n* **Order book depth**\n  `GET /api/v2/spot/market/orderbook` (with `symbol`, `type=step0`, `limit`)\n\n* **Recent trades**\n  `GET /api/v2/spot/market/fills` (for trade history, latest public trades)\n\n* **Klines / Candlesticks**\n  `GET /api/v2/spot/market/candles` (with `symbol`, `granularity`, `limit`)\n\n* **Historical candles (optional)**\n  `GET /api/v2/spot/market/history-candles` (with `endTime`, `limit`)\n\nThe agent calls these endpoints in parallel for the requested trading pair (e.g., `BTCUSDT`), validates results, and then **presents the data in clean Telegram text format**.\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "47065561-7279-41c3-9231-c8d9bc81d27f",
      "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": "05a063ef-9294-4692-907e-2e8d43e67dec",
      "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": "6e9a03c3-c867-4c88-871c-c09de2293b60",
      "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": "d835c62a-6fc4-4422-8b77-c0e4e401282a",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        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### **Order Book Depth**\n\n**Endpoint:** `GET /api/v2/spot/market/orderbook`\n**What it does:** Returns order book bids/asks up to `limit`.\n\n**Params:**\n* `symbol` (STRING, required) \u2192 e.g., BTCUSDT\n* `type` (STRING, optional) \u2192 depth aggregation level (e.g., step0)\n* `limit` (INT, optional) \u2192 number of levels (default 100)\n\n**Returns:** bids/asks arrays with price and size.\n\n**n8n query mapping:**\n\n```txt\nsymbol = $fromAI('symbol', 'BTCUSDT', 'string')\ntype   = $fromAI('depthType', 'step0', 'string')\nlimit  = $fromAI('limit', 100, 'number')\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "fd0947eb-9d67-439b-8bd8-a672472531bd",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        128,
        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\n### **Recent Trades**\n\n**Endpoint:** `GET /api/v2/spot/market/fills`\n**What it does:** Returns the most recent public trades for a symbol.\n\n**Params:**\n* `symbol` (STRING, required) \u2192 e.g., BTCUSDT\n* `limit`  (INT, optional) \u2192 number of trades (default 100 here)\n\n**Returns:** array of trades with price, size, side, and time.\n\n**n8n query mapping:**\n\n```txt\nsymbol = $fromAI('symbol', 'BTCUSDT', 'string')\nlimit  = $fromAI('limit', 100, 'number')\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "907737f8-167d-4276-9710-1920cc01b101",
      "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": "852be091-4826-4907-a99b-9cd56d52508e",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -784,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 740,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Ticker (Latest & 24h Stats)**\n\n**Endpoint:** `GET /api/v2/spot/market/tickers`\n**What it does:** Returns latest price plus 24h stats for a symbol (last, open/high/low, change %, volumes, best bid/ask).\n\n**Params:**\n* `symbol` (STRING, optional but recommended) \u2192 e.g., BTCUSDT\n\n**n8n query mapping:**\n\n```txt\nsymbol = $fromAI('symbol', 'BTCUSDT', 'string')\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "22e1d65a-0d59-44fa-b0dc-b103d7191c8c",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 916,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Klines (Candles)**\n\n**Endpoint:** `GET /api/v2/spot/market/candles`  \n**What it does:** OHLCV candlesticks for a symbol/interval.  \n\n**Params:**  \n* `symbol` (STRING, required) \u2192 e.g., BTCUSDT  \n* `granularity` (ENUM, required) \u2192 one of **1min, 15min, 1h, 4h, 1day**  \n* `limit` (INT, optional) \u2192 number of candles (default 20 here)  \n* `startTime`, `endTime` (optional) \u2192 ms timestamps  \n\n**Returns:** arrays per candle: `[timestamp, open, high, low, close, volume]`  \n\n**n8n query mapping:**  \n```txt\nsymbol      = $fromAI('symbol', 'BTCUSDT', 'string')\ngranularity = $fromAI('granularity', '15min', 'string')\nlimit       = $fromAI('limit', 20, 'number')\n"
      },
      "typeVersion": 1
    },
    {
      "id": "62c3ed90-d9f3-43b6-adb5-c4b1c1cfecbb",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 948,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Historical Candles**\n\n**Endpoint:** `GET /api/v2/spot/market/history-candles`  \n**What it does:** Returns **older OHLCV candlesticks** ending before `endTime`.  \n\n**Params:**  \n* `symbol` (STRING, required) \u2192 e.g., BTCUSDT  \n* `granularity` (ENUM, required) \u2192 one of **1min, 15min, 1h, 4h, 1day**  \n* `endTime` (LONG, required) \u2192 Unix ms timestamp (last candle end)  \n* `limit` (INT, optional, default 100)  \n\n**Returns:** arrays per candle: `[timestamp, open, high, low, close, volume]`  \n\n**n8n query mapping:**  \n```txt\nsymbol      = $fromAI('symbol', 'BTCUSDT', 'string')\ngranularity = $fromAI('granularity', '15min', 'string')\nendTime     = $fromAI('endTime', '', 'number')\nlimit       = $fromAI('limit', 100, 'number')\n"
      },
      "typeVersion": 1
    },
    {
      "id": "55a0673c-0626-465e-9e95-375f4470e9af",
      "name": "Bitget  AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -96,
        240
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "options": {
          "systemMessage": "You are the **Bitget Spot Market Data Agent**.\nYou have **HTTP GET** access to the official Bitget REST **v2 Spot API** to retrieve market data for any requested Spot trading 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.bitget.com/api/v2`\n**Pair format:** `BASEQUOTE` (uppercase, no separator), e.g. `BTCUSDT`.\n\n**General rules**\n\n* All requests are **GET** and return **JSON**.\n* Query params go in the URL, e.g. `?symbol=BTCUSDT&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/market/tickers?symbol=BTCUSDT`\n   Returns last price, open/high/low, 24h % change, base/quote volume, best bid/ask.\n\n2. **Order Book Depth**\n   `GET /spot/market/orderbook?symbol=BTCUSDT&type=step0&limit=100`\n   Returns bids/asks up to the limit (top-of-book first).\n   Use `limit=1` to emulate **Best Bid/Ask**.\n\n3. **Recent Trades**\n   `GET /spot/market/fills?symbol=BTCUSDT&limit=100`\n   Most recent public trades (price, size, side, time).\n\n4. **Candlesticks (Klines)**\n   `GET /spot/market/candles?symbol=BTCUSDT&granularity=15min&limit=20`\n   OHLCV candles. Supported intervals: **1min, 15min, 1h, 4h, 1day**.\n\n5. **Historical Candles** (Optional)\n   `GET /spot/market/history-candles?symbol=BTCUSDT&granularity=15min&endTime=...&limit=100`\n   Older OHLCV candles ending before `endTime`.\n   Supported intervals: **1min, 15min, 1h, 4h, 1day**.\n\n---\n\n## \ud83e\udde9 Utility Tools\n\n* **Calculator** \u2014 optional math (spread, midpoint, % change).\n* **Think** \u2014 reshape JSON and format the final Telegram text message.\n\n---\n\n## \ud83d\udce4 Output Format (Telegram text)\n\nStart with:\n\n```\nBTCUSDT \u2014 Bitget 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: 15min (O/H/L/C per candle)\n\nHistorical Candles\n\u2022 End before: {{endTime}} \u2022 Interval: {{granularity}}\n```\n\n---\n\n## \u26a0\ufe0f Rules\n\n* Always call the correct **Bitget Spot v2 endpoint**.\n* Do not fabricate numbers or run technical analysis/sentiment.\n* Do not dump raw JSON; always present clean, readable values.\n* On error or missing fields, show `N/A` and continue.\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "9d0b1a13-5fb3-4479-aa03-d4d8b71ed9e5",
      "name": "Ticker (24h Stats)",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -704,
        608
      ],
      "parameters": {
        "url": "https://api.bitget.com/api/v2/spot/market/tickers",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "symbol",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('symbol', `BTCUSDT`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### \ud83c\udff7 Tool: **Ticker (Latest & 24h Stats)**\n\n**Endpoint:** `GET /api/v2/spot/market/tickers`\n**What it does:** Returns latest price plus 24h stats for a symbol (last, open/high/low, change %, volumes, best bid/ask).\n\n**Params:**\n* `symbol` (STRING, optional but recommended) \u2192 e.g., BTCUSDT\n\n**n8n query mapping:**\n\n```txt\nsymbol = $fromAI('symbol', 'BTCUSDT', 'string')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "83e887de-8dc0-4951-a092-15c98bc96d0c",
      "name": "Order Book Depth",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -416,
        608
      ],
      "parameters": {
        "url": "https://api.bitget.com/api/v2/spot/market/orderbook",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "symbol",
              "value": "={{ $fromAI('symbol', `BTCUSDT`, 'string') }}"
            },
            {
              "name": "type",
              "value": "={{ $fromAI('depthType', `step0`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ $fromAI('limit', `100`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### \ud83c\udff7 Tool: **Order Book Depth**\n\n**Endpoint:** `GET /api/v2/spot/market/orderbook`\n**What it does:** Returns order book bids/asks up to `limit`.\n\n**Params:**\n* `symbol` (STRING, required) \u2192 e.g., BTCUSDT\n* `type` (STRING, optional) \u2192 depth aggregation level (e.g., step0)\n* `limit` (INT, optional) \u2192 number of levels (default 100)\n\n**Returns:** bids/asks arrays with price and size.\n\n**n8n query mapping:**\n\n```txt\nsymbol = $fromAI('symbol', 'BTCUSDT', 'string')\ntype   = $fromAI('depthType', 'step0', 'string')\nlimit  = $fromAI('limit', 100, 'number')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "a3145234-d478-4f6e-8eb9-560b0558bf79",
      "name": "Recent Trades",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        208,
        608
      ],
      "parameters": {
        "url": "https://api.bitget.com/api/v2/spot/market/fills",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "symbol",
              "value": "={{ $fromAI('symbol', `BTCUSDT`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ $fromAI('limit', `100`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### \ud83c\udff7 Tool: **Recent Trades**\n\n**Endpoint:** `GET /api/v2/spot/market/fills`\n**What it does:** Returns the most recent public trades for a symbol.\n\n**Params:**\n* `symbol` (STRING, required) \u2192 e.g., BTCUSDT\n* `limit`  (INT, optional) \u2192 number of trades (default 100 here)\n\n**Returns:** array of trades with price, size, side, and time.\n\n**n8n query mapping:**\n\n```txt\nsymbol = $fromAI('symbol', 'BTCUSDT', 'string')\nlimit  = $fromAI('limit', 100, 'number')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "d337f052-af2c-4ca1-9feb-e1a58ff6349f",
      "name": "Historical Candles",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        544,
        608
      ],
      "parameters": {
        "url": "https://api.bitget.com/api/v2/spot/market/history-candles",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "symbol",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `BTCUSDT`, 'string') }}"
            },
            {
              "name": "granularity",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `15m`, 'string') }}"
            },
            {
              "name": "endTime",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Value', ``, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters3_Value', `100`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### \ud83c\udff7 Tool: **Historical Candles**\n\n**Endpoint:** `GET /api/v2/spot/market/history-candles`  \n**What it does:** Returns **older OHLCV candlesticks** ending before `endTime`.  \n\n**Params:**  \n* `symbol` (STRING, required) \u2192 e.g., BTCUSDT  \n* `granularity` (ENUM, required) \u2192 one of **1min, 15min, 1h, 4h, 1day**  \n* `endTime` (LONG, required) \u2192 Unix ms timestamp (last candle end)  \n* `limit` (INT, optional, default 100)  \n\n**Returns:** arrays per candle: `[timestamp, open, high, low, close, volume]`  \n\n**n8n query mapping:**  \n```txt\nsymbol      = $fromAI('symbol', 'BTCUSDT', 'string')\ngranularity = $fromAI('granularity', '15min', 'string')\nendTime     = $fromAI('endTime', '', 'number')\nlimit       = $fromAI('limit', 100, 'number')\n"
      },
      "typeVersion": 4.2
    },
    {
      "id": "bc735a72-1b1f-4b30-a57a-b85828b61295",
      "name": "Klines (Candles)",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -112,
        592
      ],
      "parameters": {
        "url": "https://api.bitget.com/api/v2/spot/market/candles",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "symbol",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `BTCUSDT`, 'string') }}"
            },
            {
              "name": "granularity",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `1min, 5min, 15min, 1h, 4h, 1day`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters2_Value', `20`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### \ud83c\udff7 Tool: **Klines (Candles)**\n\n**Endpoint:** `GET /api/v2/spot/market/candles`  \n**What it does:** OHLCV candlesticks for a symbol/interval.  \n\n**Params:**  \n* `symbol` (STRING, required) \u2192 e.g., BTCUSDT  \n* `granularity` (ENUM, required) \u2192 one of **1min, 15min, 1h, 4h, 1day**  \n* `limit` (INT, optional) \u2192 number of candles (default 20 here)  \n* `startTime`, `endTime` (optional) \u2192 ms timestamps  \n\n**Returns:** arrays per candle: `[timestamp, open, high, low, close, volume]`  \n\n**n8n query mapping:**  \n```txt\nsymbol      = $fromAI('symbol', 'BTCUSDT', 'string')\ngranularity = $fromAI('granularity', '15min', 'string')\nlimit       = $fromAI('limit', 20, 'number')\n"
      },
      "typeVersion": 4.2
    },
    {
      "id": "bfa7a5b2-6e12-4c5d-9bb6-84adf000bb5f",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -1008,
        720
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "bde84900-04ac-4efb-8096-f68dc35307d9",
      "name": "Calculator",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        896,
        592
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0139552e-d250-4d32-8b62-2604ed61ff23",
      "name": "Think",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        1184,
        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": "65de308b-818a-4214-ac13-ee08b355f636",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        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": "dd67ba06-a20f-45c1-8c7c-469fadd562f5",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1104,
        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": "521f1e1b-93cc-4640-81ac-768f0dd0ab51",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1504,
        -896
      ],
      "parameters": {
        "width": 1200,
        "height": 2736,
        "content": "# \ud83e\udde0 Bitget Spot Market AI Agent \u2013 Full System Documentation\n\nA specialized **data-fetching AI automation system** for Bitget Spot markets.  \nIt retrieves **live tickers, order books, trades, and candlesticks** via the official Bitget REST v2 API and presents them in a **Telegram-friendly format**.  \nNo predictions or trading advice are generated \u2014 only **raw, structured data presentation**.\n\n---\n\n## \ud83e\udde9 Included Workflows\n\nInstall and activate **all the following workflows/tools**:\n\n| \u2705 Workflow / Tool Name | \ud83d\udccc Function Description |\n| ----------------------- | ----------------------- |\n| **Bitget AI Agent** | Core orchestrator. Fetches data from Bitget REST API, formats into Telegram output. |\n| **OpenAI Chat Model** | Provides GPT-powered text formatting (gpt-4.1-mini). |\n| **Telegram Trigger** | Listens for new Telegram commands/messages. |\n| **User Authentication (ID Check)** | Ensures only approved Telegram ID can use the agent. |\n| **Adds SessionId** | Creates a session context per Telegram chat. |\n| **Simple Memory** | Short-term state storage for symbol/session continuity. |\n| **Splits Message >4000** | Splits long reports into chunks (Telegram safe). |\n| **Telegram (Send Message)** | Sends the final formatted data/report to user. |\n| **Ticker (24h Stats)** | Gets last price, O/H/L, 24h % change, volumes, bid/ask. |\n| **Order Book Depth** | Pulls top bids/asks from Bitget order book. |\n| **Recent Trades** | Retrieves recent public trades. |\n| **Klines (Candles)** | Pulls OHLCV candlesticks for supported intervals. |\n| **Historical Candles** | Gets older candles ending before `endTime`. |\n| **Calculator** | Performs math operations (spreads, % change). |\n| **Think** | Lightweight reasoning/reshaping tool for JSON \u2192 clean text. |\n\n---\n\n## \u2699\ufe0f Installation Instructions\n\n### Step 1: Import Workflows\n* Open **n8n Editor UI**  \n* Import `Bitget AI Agent v1.02.json`  \n* Activate the workflow\n\n### Step 2: Set Credentials\n* **OpenAI API** \u2192 add your GPT-4.1-mini key  \n* **Telegram Bot API** \u2192 connect your Telegram bot  \n* **Bitget Data** \u2192 no authentication required (public endpoints)\n\n### Step 3: Configure Telegram\n* Add your bot to Telegram  \n* Replace the **Telegram ID check** inside `User Authentication` with your own ID  \n* Only messages from this ID will trigger the agent\n\n### Step 4: Run the Agent\n* Send `/BTCUSDT` or similar symbol request via Telegram  \n* Agent fetches ticker, order book, trades, and candlesticks  \n* Returns a formatted, structured report\n\n---\n\n## \ud83d\udda5\ufe0f Workflow Overview\n\n```\n\n\\[Telegram Trigger]\n\u2192 \\[User Authentication (ID Check)]\n\u2192 \\[Adds SessionId]\n\u2192 \\[Bitget AI Agent]\n\u21b3 (Ticker, Order Book, Trades, Klines, Historical Candles, Calculator, Think)\n\u2192 \\[Split if >4000 chars]\n\u2192 \\[Send to Telegram]\n\n````\n\n---\n\n## \ud83d\udccc Supported Bitget API Endpoints\n\n1. **Ticker (24h Stats)**  \n   `GET /api/v2/spot/market/tickers?symbol=BTCUSDT`  \n\n2. **Order Book Depth**  \n   `GET /api/v2/spot/market/orderbook?symbol=BTCUSDT&type=step0&limit=100`  \n\n3. **Recent Trades**  \n   `GET /api/v2/spot/market/fills?symbol=BTCUSDT&limit=100`  \n\n4. **Klines (Candles)**  \n   `GET /api/v2/spot/market/candles?symbol=BTCUSDT&granularity=15min&limit=20`  \n\n5. **Historical Candles**  \n   `GET /api/v2/spot/market/history-candles?symbol=BTCUSDT&granularity=15min&endTime=...&limit=100`\n\n---\n\n## \ud83d\udcec Telegram Output Style\n\n```html\n<b>BTCUSDT \u2014 Bitget 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 x 0.5], [26,244 x 1.2] \u2026\n\u2022 Asks: [26,255 x 0.8], [26,256 x 1.5] \u2026\n\n<b>Candles (15m, last 20)</b>\n\u2022 O/H/L/C values per candle\n\n<b>Historical Candles</b>\n\u2022 Interval: 15m \u2022 Ending before: 1699999999999\n````\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": "b42bdc61-4f67-4c28-a541-05126540fc04",
  "connections": {
    "Think": {
      "ai_tool": [
        [
          {
            "node": "Bitget  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "Bitget  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Recent Trades": {
      "ai_tool": [
        [
          {
            "node": "Bitget  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Bitget  AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Adds \"SessionId\"": {
      "main": [
        [
          {
            "node": "Bitget  AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bitget  AI Agent": {
      "main": [
        [
          {
            "node": "Splits message is more than 4000 characters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Klines (Candles)": {
      "ai_tool": [
        [
          {
            "node": "Bitget  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Order Book Depth": {
      "ai_tool": [
        [
          {
            "node": "Bitget  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": "Bitget  AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Historical Candles": {
      "ai_tool": [
        [
          {
            "node": "Bitget  AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Ticker (24h Stats)": {
      "ai_tool": [
        [
          {
            "node": "Bitget  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
          }
        ]
      ]
    }
  }
}