Trade Crypto via Telegram Bot
Automate crypto spot trading on Bitget through a Telegram bot. Execute trades, check balances, and get real-time notifications via Telegram, email, and Notion.
What This Workflow Does
This workflow template enables automated cryptocurrency spot trading on Bitget using an AI-powered assistant accessible through Telegram. It processes user commands securely, interacts with the Bitget API for account management and trade execution, and sends notifications through Telegram, email, and Notion.
It handles five core tasks:
- Listens for incoming Telegram webhook messages from the user.
- Parses message content and authenticates the sender by Telegram user ID.
- Configures Bitget API credentials and trading parameters.
- Invokes an AI trading agent that interprets commands and interacts with Bitget's spot trading functions.
- Sends trade updates and account info via Telegram, email, and Notion.
What You Need
- A Telegram bot with a webhook URL configured
- Bitget API key, secret key, and API passphrase with appropriate permissions
- A Needle platform account to run the workflow
- Your Telegram user ID whitelisted for authentication
- Optional: Email and Notion connectors configured for receiving notifications
How the Flow Works
| Step | Node | Description |
|---|---|---|
| 1 | Webhook Trigger | Receives incoming Telegram updates as webhook events. |
| 2 | Telegram Message Parser & Auth | Parses the Telegram message, extracts sender details, and authenticates the user by Telegram ID. |
| 3 | Bitget API Configuration | Prepares Bitget API keys, passphrase, and base URL along with user and message context. |
| 4 | Trading Context Builder | Adds trading parameters like supported pairs, order types, and size limits to the trading context. |
| 5 | AI Trader Agent | Uses an AI model to interpret user commands, execute trading operations, query account info, and compose responses. |
| 6 | Response Parser | Extracts structured trade data from the AI response and splits long messages into Telegram-friendly chunks. |
| 7a | Telegram Reply | Sends the response back to the user's Telegram chat. |
| 7b | Gmail Notification | Sends an HTML email summarizing the trade or query. |
| 7c | Notion Trading Log | Creates a new page in a Notion database as a trading journal entry. |
Supported Trading Features
- Account & Wallet Management — Check balances, assets, deposit addresses, and transfer records.
- Spot Order Trading — Place market or limit buy/sell orders, check order status, and cancel orders.
- Trigger/Plan Orders — Set stop-loss and take-profit orders with configurable trigger types.
- Market Data — Get ticker prices, orderbook depth, candlestick data, and recent trades.
- Web Research — Search the internet for crypto market news and analysis.
Supported Trading Pairs
BTCUSDT, ETHUSDT, SOLUSDT, XRPUSDT, DOGEUSDT, ADAUSDT, AVAXUSDT, DOTUSDT, LINKUSDT, MATICUSDT
You can customize this list in the Trading Context Builder node.
Required Variables
| Variable | Description |
|---|---|
BITGET_API_KEY | Your Bitget API key |
BITGET_SECRET_KEY | Your Bitget secret key (store as a secret variable) |
BG_PASSPHRASE | Your Bitget API passphrase (store as a secret variable) |
BITGET_BASE_URL | Bitget API base URL (default: https://api.bitget.com) |
AUTHORIZED_TELEGRAM_ID | Your Telegram user ID for authentication |
TELEGRAM_CHAT_ID | The Telegram chat ID where replies are sent |
NOTIFICATION_EMAIL | Email address for trade notification emails |
NOTION_TRADING_DB_ID | Notion database ID for the trading log |
Built-in Risk Management
The AI agent follows these safety rules when executing trades:
- Always checks the current ticker price before placing any order.
- Always checks available balance before placing orders.
- Warns and requires confirmation if an order exceeds $500 USD equivalent.
- Limits a single order to 50% of available balance.
- Caps "all in" requests at 90% of balance with a warning.
- Verifies limit order prices are within 5% of market price unless explicitly overridden.
Output
At the end of the workflow, you receive real-time responses and trade execution results directly in your Telegram chat. Email and Notion notifications provide a persistent record of trading activity, orders, and account balances without any manual effort.
Notes
- Store your Bitget API credentials as secret variables for security.
- The bot only responds to the authorized Telegram user ID — all other users are rejected.
- Test the workflow with the provided dummy inputs before connecting real API keys.
- Adjust supported pairs and order parameters in the Trading Context Builder to match your trading preferences.
- Familiarity with Bitget's official API documentation and Telegram bot setup will help you customize and troubleshoot this workflow.
Want to showcase your own workflows?
Become a Needle workflow partner and turn your expertise into recurring revenue.
