Agente de IA de Bybit v1.02

Avanzado

Este es unCrypto Trading, AI Chatbot, Multimodal AIflujo de automatización del dominio deautomatización que contiene 35 nodos.Utiliza principalmente nodos como Set, Code, Telegram, Agent, HttpRequestTool. Obtener datos en tiempo real del mercado de criptomonedas de Bybit mediante GPT-4.1-mini y Telegram

Requisitos previos
  • Bot Token de Telegram
  • Pueden requerirse credenciales de autenticación para la API de destino
  • Clave de API de OpenAI
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "id": "INW3Qtj4GuhFO6L2",
  "meta": {
    "instanceId": "a5283507e1917a33cc3ae615b2e7d5ad2c1e50955e6f831272ddd5ab816f3fb6"
  },
  "name": "Bybit AI Agent v1.02",
  "tags": [],
  "nodes": [
    {
      "id": "e32639ff-0e71-4c35-8c73-79248687fc4f",
      "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": {
          "id": "yUizd8t0sD5wMYVG",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5796edc7-641b-4a99-8620-3c547270d812",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1008,
        240
      ],
      "webhookId": "3671a169-5ef7-430c-88ff-668190d86ee0",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "NRLKuLR7z8vCesub",
          "name": "BinanceSpotTradingAIAgent_Bot"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f9886889-fb69-4af0-80b5-df3af4f1642d",
      "name": "Autenticación de Usuario (Reemplazar ID Telegram)",
      "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": "0233f87d-57bf-4c05-9cd0-a1ffec8ba86d",
      "name": "Agrega \"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": "27aed875-b9f5-4957-be94-9d46fca3a256",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        896,
        240
      ],
      "webhookId": "b8f79882-fe86-45a8-b356-66a8f783a8c2",
      "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": "7a47dd07-a50c-4dec-a42d-6e4c89b6cb8d",
      "name": "Divide mensajes de más de 4000 caracteres",
      "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": "0889b0f3-3b16-4646-844b-878523afe513",
      "name": "Nota Adhesiva",
      "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": "84f4f69f-6008-476e-b05f-4425d255c90d",
      "name": "Nota Adhesiva1",
      "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": "6b8248f1-97fe-4543-a7c4-61dd61adf9c8",
      "name": "Nota Adhesiva2",
      "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": "d47c30da-9fa6-4b32-be89-403dccfc0c18",
      "name": "Nota Adhesiva3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -320
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 756,
        "content": "## Main AI Agent: Data Fetcher\n\n**Node: Bybit Data Agent**\nThis is the **core orchestrator**. It uses OpenAI only to **format and present raw Bybit Spot market data**, not to analyze or generate strategies.\n\nIt has direct **HTTP request access** to the Bybit REST **v5 Spot API** and retrieves:\n\n* **Latest price & 24h stats** (`/v5/market/tickers`)\n* **Order book depth** (`/v5/market/orderbook`)\n* **Best bid/ask** (`/v5/market/orderbook?limit=1`)\n* **Klines/candlesticks** (`/v5/market/kline`)\n* **Recent public trades** (`/v5/market/recent-trade`)\n\nThe agent calls these endpoints in parallel for the requested symbol, validates results, and then **presents the data in clean Telegram HTML format**.\n\nIt does **not**:\n\n* Perform technical analysis\n* Generate strategies or predictions\n* Fetch sentiment or news\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "88706b84-fa2b-4744-9789-ca4f684fe6c4",
      "name": "Nota Adhesiva4",
      "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": "88257edc-46d3-4308-97c1-d3994c77ef21",
      "name": "Nota Adhesiva5",
      "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": "4822fbae-1d0d-4c5c-8e7d-de9c6d6a7fe4",
      "name": "Nota Adhesiva6",
      "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": "9f342b49-a4c5-4e69-843b-b5441cb63c4c",
      "name": "Nota Adhesiva7",
      "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 /v5/market/orderbook`\n**What it does:** Returns order book bids/asks up to `limit` for a symbol.\n\n**Params:**\n\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n* `limit` (INT, optional; default 25; max 5000)\n\n**Returns:** bid/ask arrays with price and size.\n\n**n8n query mapping:**\n\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\nlimit    = $fromAI('limit', 100, 'number')\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "c8140a94-2d1b-4a85-8a7f-f8213394e0f9",
      "name": "Nota Adhesiva8",
      "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 /v5/market/orderbook`\n**What it does:** Returns the current order book. Using `limit=1` gives the **best bid/ask** (top of book).\n\n**Params:**\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n* `limit` (INT, optional, default 1)\n\n**Returns:** top of book with bid/ask price and size arrays.\n\n**n8n query mapping:**\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\nlimit    = 1\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "79749296-1b46-4e5e-abb7-6aadc72f4897",
      "name": "Nota Adhesiva9",
      "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": "a3a95f1c-1fbb-4319-b4c8-2558258179b9",
      "name": "Memoria Simple",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -992,
        736
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "844d30b6-13c0-4578-ba56-d7b7509e3de9",
      "name": "Nota Adhesiva10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -784,
        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### **24h Stats (Ticker)**\n\n**Endpoint:** `GET /v5/market/tickers`\n**What it does:** Returns latest price and 24h stats for a Spot symbol: last price, best bid/ask, 24h high/low, 24h change %, turnover and volume.\n\n**Params:**\n\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, optional but recommended) → e.g., BTCUSDT\n\n**Returns:** Bybit ticker fields such as `lastPrice`, `bid1Price`, `ask1Price`, `highPrice24h`, `lowPrice24h`, `price24hPcnt`, `turnover24h`, `volume24h`.\n\n**n8n query mapping:**\n\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "7622838f-8e7a-4e82-82df-da0ea7474de6",
      "name": "Nota Adhesiva11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 772,
        "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 /v5/market/tickers`\n**What it does:** Returns the latest price and 24h stats for a symbol.\n\n**Params:**\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n\n**Returns:** includes lastPrice, bid1Price, ask1Price, highPrice24h, lowPrice24h, volume24h, etc.\n\n**n8n query mapping:**\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "0fc5427f-394a-4faf-b76f-f0bf4cbfc493",
      "name": "Nota Adhesiva12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 1060,
        "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 /v5/market/kline`\n**What it does:** Returns candlestick (OHLCV) bars for a spot symbol and interval.\n\n**Params:**\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n* `interval` (STRING, required) → supported: `1,3,5,15,30,60,120,240,360,720,D,W,M`\n* `limit` (INT, optional, default 20)\n* `start` (LONG, optional, ms timestamp)\n* `end` (LONG, optional, ms timestamp)\n\n**Returns (array per candle):** `[ startTime, open, high, low, close, volume, turnover ]`\n\n**n8n query mapping:**\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\ninterval = $fromAI('interval', '15', 'string')\nlimit    = $fromAI('limit', 20, 'number')\nstart    = $fromAI('start', '', 'number')\nend      = $fromAI('end', '', 'number')\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "403afddb-0349-4949-8597-919a7569ed11",
      "name": "Nota Adhesiva13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        512
      ],
      "parameters": {
        "color": 6,
        "height": 964,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### **Ticker (Latest & Stats)**\n\n**Endpoint:** `GET /v5/market/tickers`\n**What it does:** Returns the latest price, best bid/ask, 24h high/low, % change, and volume for a symbol.\n\n**Params:**\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n\n**Returns:** `{symbol, lastPrice, bid1Price, bid1Size, ask1Price, ask1Size, highPrice24h, lowPrice24h, volume24h, turnover24h}`\n\n**n8n query mapping:**\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\n```\n\n**Notes:** Bybit has no `/avgPrice`; derive midpoint `(bid1Price + ask1Price) / 2` in the Calculator node if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "e891654a-fd49-439e-acf5-ded1cca0cb96",
      "name": "Nota Adhesiva14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        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### **Recent Trades**\n\n**Endpoint:** `GET /v5/market/recent-trade`\n**What it does:** Returns the most recent public trades for a given symbol.\n\n**Params:**\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n* `limit` (INT, optional, default 100, max 1000)\n\n**Returns:** array of trades `{execId, price, size, side, time}`.\n\n**n8n query mapping:**\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('parameters0_Value', '', 'string')\nlimit    = $fromAI('parameters1_Value', 100, 'number')\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "2c225033-748b-442c-b674-3116a1457081",
      "name": "Calculadora",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        1520,
        592
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ee219272-a31f-4556-9ad1-5537b48d2cd6",
      "name": "Think",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        1808,
        592
      ],
      "parameters": {
        "description": "### 🏷 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 → Think → Report Agent."
      },
      "typeVersion": 1.1
    },
    {
      "id": "acda52e9-0932-4ba0-839e-393ea9e5e445",
      "name": "Nota Adhesiva15",
      "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 – 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 → Final Report\n"
      },
      "typeVersion": 1
    },
    {
      "id": "6de0d578-222b-4e31-8601-94c127bf7fbe",
      "name": "Nota Adhesiva16",
      "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 → Think → Report Agent."
      },
      "typeVersion": 1
    },
    {
      "id": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
      "name": "Agente de IA de Bybit",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -96,
        240
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "options": {
          "systemMessage": "You are the **Bybit Spot Market Data Agent**.\nYou have **HTTP GET** access to the official Bybit REST **v5** API to retrieve market data for any requested **Spot** trading pair.\nYour job is to **fetch and present data only** — no analysis, predictions, or advice.\n\n## API Access\n\n* Base URL: `https://api.bybit.com/v5`\n* Pair format: `BASEQUOTE` (uppercase, no separator), e.g. `BTCUSDT`.\n* Always include `category=spot` on market endpoints.\n* If a field or call fails, output `N/A` and continue.\n\n## Market Data Endpoints (Spot)\n\n1. **Latest price & 24h stats**\n   `GET /market/tickers?category=spot&symbol=BTCUSDT`\n   Returns last price, best bid/ask, 24h high/low, % change, turnover/volume.&#x20;\n\n2. **Order book depth**\n   `GET /market/orderbook?category=spot&symbol=BTCUSDT&limit=100`\n   Snapshot of bids/asks (Spot supports 1–200; default 1). Use `limit=1` to emulate Best Bid/Ask.&#x20;\n\n3. **Recent public trades**\n   `GET /market/recent-trade?category=spot&symbol=BTCUSDT&limit=60`\n   Most recent trades (Spot limit 1–60; default 60).&#x20;\n\n4. **Candlesticks (klines)**\n   `GET /market/kline?category=spot&symbol=BTCUSDT&interval=15&limit=200`\n   OHLCV candles. Use only these intervals to match other agents: **1, 15, 60, 240, D** (1min, 15min, 1h, 4h, 1day).&#x20;\n\n## Optional Utility Endpoints\n\n* **Server time**: `GET /market/time` → Bybit server timestamps (sec/nano).&#x20;\n* **Order price limit**: `GET /market/price-limit?category=spot&symbol=BTCUSDT` → current buy/sell limit prices (spot/derivatives).&#x20;\n\n## Output Format (Telegram text)\n\nStart with:\n\n```\nBTCUSDT — Bybit Spot Data\n```\n\nThen:\n\n```\nPrice\n• Last: {{lastPrice}}\n• Best Bid / Ask: {{bid1Price}} / {{ask1Price}}\n• Change (24h): {{price24hPcnt}}%\n\n24h Stats\n• High: {{highPrice24h}} • Low: {{lowPrice24h}}\n• Volume(24h): {{volume24h}} • Turnover(24h): {{turnover24h}}\n\nOrder Book (Top 5)\n• Bids: [price x size] …\n• Asks: [price x size] …\n\nCandles (latest N)\n• Interval: {{interval}} (O/H/L/C per candle)\n```\n\n## Rules\n\n* Call the correct **Bybit v5 Spot** endpoint for each request.\n* Do not fabricate values or provide analysis/sentiment.\n* Do not dump raw JSON; present clean, readable values.\n* On error or missing fields, show `N/A` and continue.\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "41e95ef0-7957-44c5-ae8f-faebc894b28b",
      "name": "Estadísticas 24h1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -704,
        608
      ],
      "parameters": {
        "url": "https://api.bybit.com/v5/market/tickers",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "category",
              "value": "spot"
            },
            {
              "name": "symbol",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('symbol', `BTCUSDT`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **24h Stats (Ticker)**\n\n**Endpoint:** `GET /v5/market/tickers`\n**What it does:** Returns latest price and 24h stats for a Spot symbol: last price, best bid/ask, 24h high/low, 24h change %, turnover and volume.\n\n**Params:**\n\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, optional but recommended) → e.g., BTCUSDT\n\n**Returns:** Bybit ticker fields such as `lastPrice`, `bid1Price`, `ask1Price`, `highPrice24h`, `lowPrice24h`, `price24hPcnt`, `turnover24h`, `volume24h`.\n\n**n8n query mapping:**\n\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "dbb8ad4d-0e57-4abf-809e-c759457a06a9",
      "name": "Profundidad del Libro de Órdenes1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -416,
        608
      ],
      "parameters": {
        "url": "https://api.bybit.com/v5/market/orderbook",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "category",
              "value": "spot"
            },
            {
              "name": "symbol",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('symbol', `BTCUSDT`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('limit', `100`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Order Book Depth**\n\n**Endpoint:** `GET /v5/market/orderbook`\n**What it does:** Returns order book bids/asks up to `limit` for a symbol.\n\n**Params:**\n\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n* `limit` (INT, optional; default 25; max 5000)\n\n**Returns:** bid/ask arrays with price and size.\n\n**n8n query mapping:**\n\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\nlimit    = $fromAI('limit', 100, 'number')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "e6fcff06-babc-4167-ad9a-13a07b66723b",
      "name": "Precio (Más Reciente)1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -128,
        608
      ],
      "parameters": {
        "url": "https://api.bybit.com/v5/market/tickers",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "category",
              "value": "spot"
            },
            {
              "name": "symbol",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('symbol', `BTCUSDT`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Price (Latest)**\n\n**Endpoint:** `GET /v5/market/tickers`\n**What it does:** Returns the latest price and 24h stats for a symbol.\n\n**Params:**\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n\n**Returns:** includes lastPrice, bid1Price, ask1Price, highPrice24h, lowPrice24h, volume24h, etc.\n\n**n8n query mapping:**\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "850c7e5a-b61b-4618-a158-7c505086252c",
      "name": "Mejor Oferta/Demanda1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        208,
        592
      ],
      "parameters": {
        "url": "https://api.bybit.com/v5/market/orderbook",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "category",
              "value": "spot"
            },
            {
              "name": "symbol",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('symbol', `BTCUSDT`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "1"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Best Bid/Ask (Book Ticker)**\n\n**Endpoint:** `GET /v5/market/orderbook`\n**What it does:** Returns the current order book. Using `limit=1` gives the **best bid/ask** (top of book).\n\n**Params:**\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n* `limit` (INT, optional, default 1)\n\n**Returns:** top of book with bid/ask price and size arrays.\n\n**n8n query mapping:**\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\nlimit    = 1\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "a60a8ec4-3aca-4958-b87b-f68fc522e3e7",
      "name": "Klines (Velas)1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        544,
        592
      ],
      "parameters": {
        "url": "https://api.bybit.com/v5/market/kline",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "category",
              "value": "spot"
            },
            {
              "name": "symbol",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('symbol', `BTCUSDT`, 'string') }}"
            },
            {
              "name": "interval",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('interval', `15`, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('limit', `20`, 'number') }}"
            },
            {
              "name": "start",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('start', ``, 'number') }}"
            },
            {
              "name": "end",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('end', ``, 'number') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Klines (Candles)**\n\n**Endpoint:** `GET /v5/market/kline`\n**What it does:** Returns candlestick (OHLCV) bars for a spot symbol and interval.\n\n**Params:**\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n* `interval` (STRING, required) → supported: `1,3,5,15,30,60,120,240,360,720,D,W,M`\n* `limit` (INT, optional, default 20)\n* `start` (LONG, optional, ms timestamp)\n* `end` (LONG, optional, ms timestamp)\n\n**Returns (array per candle):** `[ startTime, open, high, low, close, volume, turnover ]`\n\n**n8n query mapping:**\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\ninterval = $fromAI('interval', '15', 'string')\nlimit    = $fromAI('limit', 20, 'number')\nstart    = $fromAI('start', '', 'number')\nend      = $fromAI('end', '', 'number')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "d128abbd-cac6-4c17-bc95-3fc4e3ba2651",
      "name": "Ticker (Último y Estadísticas)",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        880,
        592
      ],
      "parameters": {
        "url": "https://api.bybit.com/v5/market/tickers",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "category",
              "value": "spot"
            },
            {
              "name": "symbol",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('symbol', `BTCUSDT`, 'string') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Ticker (Latest & Stats)**\n\n**Endpoint:** `GET /v5/market/tickers`\n**What it does:** Returns the latest price, best bid/ask, 24h high/low, % change, and volume for a symbol.\n\n**Params:**\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n\n**Returns:** `{symbol, lastPrice, bid1Price, bid1Size, ask1Price, ask1Size, highPrice24h, lowPrice24h, volume24h, turnover24h}`\n\n**n8n query mapping:**\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('symbol', 'BTCUSDT', 'string')\n```\n\n**Notes:** Bybit has no `/avgPrice`; derive midpoint `(bid1Price + ask1Price) / 2` in the Calculator node if needed."
      },
      "typeVersion": 4.2
    },
    {
      "id": "b97f8b36-a8c5-449d-9df7-279daa00ae50",
      "name": "Operaciones Recientes1",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        1200,
        608
      ],
      "parameters": {
        "url": "https://api.bybit.com/v5/market/recent-trade",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "category",
              "value": "spot"
            },
            {
              "name": "symbol",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', ``, 'string') }}"
            },
            {
              "name": "limit",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', `100`, 'number') }}"
            }
          ]
        },
        "toolDescription": "### 🏷 Tool: **Recent Trades**\n\n**Endpoint:** `GET /v5/market/recent-trade`\n**What it does:** Returns the most recent public trades for a given symbol.\n\n**Params:**\n* `category` (STRING, required) → `spot`\n* `symbol` (STRING, required) → e.g., BTCUSDT\n* `limit` (INT, optional, default 100, max 1000)\n\n**Returns:** array of trades `{execId, price, size, side, time}`.\n\n**n8n query mapping:**\n```txt\ncategory = 'spot'\nsymbol   = $fromAI('parameters0_Value', '', 'string')\nlimit    = $fromAI('parameters1_Value', 100, 'number')\n```"
      },
      "typeVersion": 4.2
    },
    {
      "id": "b91c3be7-60e1-4309-a195-14cc2cb35a8a",
      "name": "Nota Adhesiva17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2160,
        -1408
      ],
      "parameters": {
        "width": 1168,
        "height": 3920,
        "content": "# 📘 Bybit AI Agent v1.02 Documentation\n\n## Overview\n\nThis workflow connects **Telegram → Bybit Spot REST API (v5)** → **OpenAI Formatter**, returning **clean market data** to a user.\nIt does **not** provide predictions, advice, or strategy — only structured data fetch + formatting.\n\n---\n\n## 🔹 Telegram Layer\n\n* **Telegram Trigger**\n  Listens for incoming user messages. Starts the workflow.\n\n* **User Authentication (Code node)**\n  Ensures only the approved Telegram user ID can access the bot.\n  If ID ≠ allowed, workflow halts.\n\n* **Adds SessionId (Set node)**\n  Stores:\n\n  * `sessionId = chat.id`\n  * `message = user input text`\n    Used for memory + message routing.\n\n---\n\n## 🔹 Memory Layer\n\n* **Simple Memory (Buffer Window)**\n  Keeps session context (symbol, interval, etc.) across multiple turns.\n  Useful for multi-turn conversations.\n\n---\n\n## 🔹 AI Layer\n\n* **OpenAI Chat Model (gpt-4.1-mini)**\n  Interprets user queries and coordinates tool calls.\n\n* **Bybit AI Agent (Agent node)**\n\n  * Attached tools:\n\n    * 24h Stats\n    * Price (Latest)\n    * Order Book Depth\n    * Best Bid/Ask\n    * Klines (Candles)\n    * Ticker (Latest & Stats)\n    * Recent Trades\n    * Calculator\n    * Think\n  * Uses system prompt to enforce **fetch-only rules**.\n  * Formats output into Telegram-ready HTML text.\n\n* **Think Tool**\n  Reshapes JSON, extracts fields, preps data for reporting.\n  Does not fetch data.\n\n* **Calculator Tool**\n  Runs inline math: spreads, % changes, midpoints, etc.\n\n---\n\n## 🔹 Bybit Spot API Tools\n\n### 1. 📊 24h Stats (Ticker)\n\n`GET /v5/market/tickers`\n\n* Params: `category=spot`, `symbol=BTCUSDT`\n* Returns: `lastPrice`, `bid1Price`, `ask1Price`, `highPrice24h`, `lowPrice24h`, `price24hPcnt`, `turnover24h`, `volume24h`\n\n---\n\n### 2. 💰 Price (Latest)\n\n`GET /v5/market/tickers`\n\n* Params: `category=spot`, `symbol=BTCUSDT`\n* Returns: same as above, focused on latest price.\n\n---\n\n### 3. 📚 Order Book Depth\n\n`GET /v5/market/orderbook`\n\n* Params: `category=spot`, `symbol=BTCUSDT`, `limit=100`\n* Returns: full bid/ask arrays with price + size.\n\n---\n\n### 4. 🎯 Best Bid/Ask (Book Ticker)\n\n`GET /v5/market/orderbook?limit=1`\n\n* Returns: top of book bid/ask.\n\n---\n\n### 5. 🕯 Klines (Candles)\n\n`GET /v5/market/kline`\n\n* Params:\n\n  * `category=spot`\n  * `symbol=BTCUSDT`\n  * `interval=1,15,60,240,D`\n  * `limit=20`\n* Returns: OHLCV bars `[time, open, high, low, close, volume, turnover]`.\n\n---\n\n### 6. 📌 Ticker (Latest & Stats)\n\n`GET /v5/market/tickers`\n\n* Params: `category=spot`, `symbol=BTCUSDT`\n* Returns: `{lastPrice, bid1Price, ask1Price, highPrice24h, lowPrice24h, volume24h}`\n* ⚠️ No `/avgPrice` → derive midpoint with Calculator.\n\n---\n\n### 7. 🔄 Recent Trades\n\n`GET /v5/market/recent-trade`\n\n* Params: `category=spot`, `symbol=BTCUSDT`, `limit=100`\n* Returns: `{execId, price, size, side, time}` array.\n\n---\n\n## 🔹 Message Handling\n\n* **Split Message (Code node)**\n  Telegram limit = 4096 chars. Splits output into chunks if longer than 4000.\n\n* **Telegram SendMessage**\n  Sends final formatted HTML report (or split chunks) to authenticated user.\n\n---\n\n## 🔹 Output Format (Telegram)\n\n```\nBTCUSDT — Bybit Spot Data\n\nPrice\n• Last: 63,212.50\n• Best Bid / Ask: 63,210.80 / 63,214.20\n• Change (24h): +1.2%\n\n24h Stats\n• High: 64,000.00 • Low: 61,500.00\n• Volume(24h): 12,345 • Turnover(24h): 789M\n\nOrder Book (Top 5)\n• Bids: [63210.8 x 0.5], …\n• Asks: [63214.2 x 0.3], …\n\nCandles (15m, latest 5)\n• O: 63200 H: 63220 L: 63150 C: 63212\n```\n\n\n---\n\n## 🚀 Support & Licensing\n\n🔗 **Don Jayamaha – LinkedIn**\n[linkedin.com/in/donjayamahajr](http://linkedin.com/in/donjayamahajr)\n\n© 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."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f2c0d0c4-cb82-42ed-abab-e92908715c43",
  "connections": {
    "ee219272-a31f-4556-9ad1-5537b48d2cd6": {
      "ai_tool": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "41e95ef0-7957-44c5-ae8f-faebc894b28b": {
      "ai_tool": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "2c225033-748b-442c-b674-3116a1457081": {
      "ai_tool": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "850c7e5a-b61b-4618-a158-7c505086252c": {
      "ai_tool": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "a3a95f1c-1fbb-4319-b4c8-2558258179b9": {
      "ai_memory": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "b97f8b36-a8c5-449d-9df7-279daa00ae50": {
      "ai_tool": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4": {
      "main": [
        [
          {
            "node": "7a47dd07-a50c-4dec-a42d-6e4c89b6cb8d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e6fcff06-babc-4167-ad9a-13a07b66723b": {
      "ai_tool": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "0233f87d-57bf-4c05-9cd0-a1ffec8ba86d": {
      "main": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5796edc7-641b-4a99-8620-3c547270d812": {
      "main": [
        [
          {
            "node": "f9886889-fb69-4af0-80b5-df3af4f1642d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a60a8ec4-3aca-4958-b87b-f68fc522e3e7": {
      "ai_tool": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "e32639ff-0e71-4c35-8c73-79248687fc4f": {
      "ai_languageModel": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "dbb8ad4d-0e57-4abf-809e-c759457a06a9": {
      "ai_tool": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "d128abbd-cac6-4c17-bc95-3fc4e3ba2651": {
      "ai_tool": [
        [
          {
            "node": "4b1a57e5-d6e8-4399-b67b-a0ff74d8aff4",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "f9886889-fb69-4af0-80b5-df3af4f1642d": {
      "main": [
        [
          {
            "node": "0233f87d-57bf-4c05-9cd0-a1ffec8ba86d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7a47dd07-a50c-4dec-a42d-6e4c89b6cb8d": {
      "main": [
        [
          {
            "node": "27aed875-b9f5-4957-be94-9d46fca3a256",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Avanzado - Comercio de criptomonedas, Chatbot de IA, IA Multimodal

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos35
Categoría3
Tipos de nodos11
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Autor
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.

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34