Telegram Bot

Telegram Bot

Pair your Telegram account to your CubeTerminal instance so you can read your positions, place trades, and receive alerts from your phone. The bot runs entirely from your own terminal — there is no cloud component.

The bot is a bridge. Your terminal opens a long-poll connection to Telegram using your personal bot token and handles every message locally. Nothing routes through a CubeTerminal-operated server.

Setup

1. Create a bot with @BotFather

  1. Open Telegram and start a chat with @BotFather (opens in a new tab)
  2. Send /newbot and follow the prompts (name, then a unique @username ending in bot)
  3. BotFather replies with an HTTP API token in the form 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
  4. Copy the token — you will paste it into the terminal in the next step

2. Find your chat ID

  1. Start a chat with your new bot and send any message (e.g. hi)
  2. In a browser visit https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
  3. Look for "chat":{"id": 123456789, ...} in the JSON — that number is your chat ID

For a group chat, add the bot to the group first, send a message, then read the same endpoint — group IDs are negative (e.g. -1001234567890).

3. Configure CubeTerminal

  1. Open Settings → Notifications → Integrations → Telegram
  2. Paste the Bot Token and Chat ID
  3. Flip the Telegram master toggle on
  4. Enable Bot Commands (Inbound) to let the bot respond to /buy, /positions, etc.
  5. Enable Alerts (Outbound) if you want the terminal to push notifications to you
  6. Click Test Alert to confirm the connection works end-to-end
⚠️

The bot will only accept commands from the Chat ID you configured. Any other sender is silently ignored. Keep your bot token private — anyone with it can send messages as your bot.

Command reference

Every command below is registered with Telegram via setMyCommands, so typing / in the chat shows an autocomplete menu.

CommandSyntaxDescriptionExample
/buy/buy <symbol> <size>Long a symbol on the active exchange/buy BTC 1k
/sell/sell <symbol> <size>Short a symbol on the active exchange/sell ETH 500
/close/close <symbol|all>Close a single position or every open position/close BTC
/cancel/cancel <symbol|all>Cancel open orders for a symbol or all orders/cancel all
/positions/positionsList open positions with size, entry, and uPnL/positions
/pnl/pnlCurrent unrealized PnL per-position and total/pnl
/balance/balanceAccount equity, available, margin used, uPnL/balance
/portfolio/portfolioOn-chain + Polymarket + perp equity breakdown/portfolio
/price/price <symbol>Current mark price and 24h change/price BTC
/funding/funding <symbol>Funding rate and next funding time/funding ETH
/news/news [symbol]Recent newsfeed items, optionally filtered/news BTC
/keyword/keyword <list|add|remove> [text]Manage newsfeed highlight keywords/keyword add airdrop
/tgkeyword/tgkeyword <list|add|remove|clear> [text]Manage Telegram-only alert keywords (distinct from newsfeed)/tgkeyword add listing
/help/helpShow the full command list/help

Trading commands

/buy and /sell take a USD size with the usual shorthand: 100, 1k, 2.5k, 10000. Orders route through the active exchange shown in the terminal header — switch it in the UI before sending. Both commands use market orders by default.

/close accepts a symbol or the literal all. If the connected exchange supports a native close endpoint (Hyperliquid, Bitget) the bot calls that directly; otherwise it submits a reduceOnly market order of the opposite side.

/cancel all sweeps every open order across every symbol with an open order. /cancel BTC targets a single symbol.

Market commands

/price and /funding are exchange-agnostic — the bot resolves the symbol across every connected exchange and picks the best match, respecting your preferred exchange setting. If a symbol is only available on one venue, that one is used automatically.

Newsfeed vs. Telegram keywords

/keyword and /tgkeyword manage two separate keyword lists on purpose:

  • /keyword — drives newsfeed highlighting, in-app notifications, and sounds. Usually broader.
  • /tgkeyword — gates what the bot pipes to your phone. Usually the loud, must-see subset.

Both accept list, add <text>, and remove <text>. /tgkeyword also supports clear.

Alert routing

Alerts are outbound messages the terminal pushes to you. Configure them in Settings → Notifications → Telegram:

  • News Keyword Alerts — newsfeed items that match any /tgkeyword entry
  • Position Change Alerts — open, close, or liquidation events on connected exchanges
  • PnL Thresholds — comma-separated dollar amounts; you get a ping each time unrealized PnL crosses one (e.g. 100, 500, 1000)

Use Test Alert at the bottom of the integration panel to confirm the channel is live without waiting for a real event.

Security notes

  • Your bot token lives only in local settings — it is never uploaded anywhere.
  • The bot handler ignores any message whose sender chat ID does not match your configured Chat ID. Even if someone discovers the bot, they cannot issue commands.
  • Disable the bot at any time by flipping the Telegram master toggle off, or clearing the token field.
  • Compromised token? Open @BotFather → /revoke to rotate immediately, then paste the new token.

Troubleshooting

Bot doesn't reply to commands

  • Confirm Bot Commands (Inbound) is toggled on
  • Confirm the Chat ID matches the chat you are messaging from (DM and group IDs are different)
  • Send /help — if that works, the issue is command-specific; check the active exchange is connected for trading commands

Alerts never arrive

  • Confirm Alerts (Outbound) is toggled on
  • Click Test Alert — a failure here usually means a bad token or Chat ID
  • For news keyword alerts, verify you have entries in /tgkeyword list

"Command must start with /"

  • The bot requires a leading slash. Freeform text is not parsed.

Unknown command

  • Only commands in the table above are registered. Typos and aliases not in the list fall through to an error. Send /help to see what is accepted.