Data Processing & Analysisintermediate
October 9, 2025
5 min read
45 minutes
Automated Cryptocurrency Market Analysis Using HTX API, GPT-4o, and Telegram Integration
Create an AI-powered Telegram bot using n8n, HTX API, and GPT-4o to deliver real-time cryptocurrency market insights instantly.
By Kazi Sakib

Cryptocurrency traders spend hours jumping between platforms, checking prices, analyzing order books, and monitoring market movements. What if you could get all that information delivered straight to your Telegram with a simple message? Better yet, what if an AI could understand your request and fetch exactly the data you need?
This n8n workflow creates an intelligent cryptocurrency market data bot that connects Telegram, HTX exchange API, and GPT-4o to deliver real-time market insights on demand. Instead of manually checking multiple websites, you can simply ask your bot for Bitcoin prices, order book depth, or candlestick patterns, and get professionally formatted responses in seconds.
Prerequisites: What You Need to Get Started
Before diving into the workflow construction, gather these essential components:
- Telegram Bot Token: Create a new bot through BotFather on Telegram
- OpenAI API Key: Access to GPT-4o-mini for intelligent request processing
- HTX API Access: Free public endpoints from HTX exchange (no authentication required)
- n8n Instance: Either cloud or self-hosted n8n automation platform
Key Components: The Building Blocks
This workflow leverages several powerful n8n nodes that work together seamlessly:
- Telegram Trigger: Captures incoming messages from users
- AI Agent: GPT-4o-mini processes requests and coordinates API calls
- HTTP Request Tools: Seven specialized endpoints for HTX market data
- Memory Buffer: Maintains conversation context for follow-up questions
- Calculator Tool: Performs mathematical operations on market data
- Code Node: Handles message splitting and user authentication
Step 1: Set Up Telegram Integration and User Security
Start by configuring your Telegram connection. The workflow begins with a Telegram Trigger node that listens for incoming messages. However, security comes first.
The User Authentication node contains a crucial piece of JavaScript code that validates incoming messages. It checks if the sender's Telegram ID matches your authorized user ID. This prevents unauthorized access to your market data bot.

img_1.png
Pro tip: Replace the hardcoded user ID with your own Telegram ID. You can find this by messaging your bot and checking the logs, or using a simple ID bot on Telegram.
Once authenticated, the "Adds SessionId" node extracts the chat ID and message content, preparing them for the AI agent to process.
Step 2: Configure the AI Agent as Your Market Data Expert
The heart of this workflow is the HTX AI Agent, powered by GPT-4o-mini. This isn't just any chatbot. The system prompt specifically trains it to be an "HTX Spot Market Data Agent" that understands cryptocurrency terminology and knows exactly which API endpoints to call.

img_2.png
The agent has been instructed to:
- Fetch and present raw market data only (no trading advice)
- Use proper HTX symbol formatting (lowercase, no dashes)
- Select appropriate timeframes automatically
- Format responses for Telegram HTML display
The Simple Memory node ensures the AI remembers your conversation context, allowing for natural follow-up questions like "What about Ethereum?" after asking about Bitcoin prices.
Step 3: Connect Multiple HTX API Endpoints
Here's where the magic happens. The workflow includes seven different HTTP Request Tool nodes, each configured for specific market data types:
- 24h Stats: OHLC data, volume, and trade count
- Order Book Depth: Bid/ask levels with customizable depth
- Price Latest: Current market price and spread
- Best Bid/Ask: Top of book quotes
- Klines (Candles): Candlestick data for technical analysis
- Recent Trades: Latest transaction history
- Average Price: Midpoint calculations
Each tool includes detailed descriptions that help the AI agent choose the right endpoint. For example, when you ask for "Bitcoin order book," the AI knows to use the Order Book Depth tool with the btcusdt symbol and appropriate depth parameters.

img_3.png
Step 4: Add Intelligence with Calculator and Think Tools
Raw API data often needs processing. The Calculator tool performs mathematical operations like spread calculations, percentage changes, and price averages. The Think tool acts as a reasoning helper, allowing the AI to process complex logic before responding.
For instance, if you ask for the "Bitcoin spread," the AI will:
- Fetch bid/ask data using the Best Bid/Ask tool
- Use Calculator to subtract bid from ask price
- Use Think to format the response appropriately
Step 5: Handle Response Formatting and Message Delivery
Telegram has a 4,096 character limit per message. The "Splits message if more than 4000 characters" node prevents errors by automatically breaking long responses into multiple messages.
The AI agent formats all responses using clean Telegram HTML, creating professional-looking market reports with:
- Bold headers and price highlights
- Organized sections for different data types
- Easy-to-scan bullet points
- Properly formatted numbers and percentages
Finally, the Telegram node delivers the formatted response back to your chat, completing the automation cycle.
Step 6: Test and Customize Your Market Data Bot
Once deployed, test your bot with various commands like:
- "Show me Bitcoin price"
- "ETH order book depth"
- "DOGE 1-hour candlesticks"
- "Recent trades for ADA"
The AI understands natural language and automatically converts requests into proper API calls. It handles symbol formatting, selects appropriate timeframes, and chooses the right endpoints based on your query context.

img_4.png
Benefits and Use Cases: Why This Workflow Rocks
This cryptocurrency market data bot transforms how traders access information:
- Instant Access: Get market data anywhere Telegram works
- Natural Language: No need to learn complex API commands
- Multiple Data Types: Prices, volumes, order books, and technical indicators
- Conversation Memory: Ask follow-up questions naturally
- Professional Formatting: Clean, readable reports every time
- Privacy Focused: Your own bot, your own data
Whether you're a day trader needing quick price checks, a researcher analyzing market depth, or a developer building trading strategies, this workflow provides reliable, instant access to HTX market data through the familiar Telegram interface.
The combination of AI intelligence and comprehensive API coverage creates a powerful tool that adapts to your specific needs. Instead of bookmarking multiple websites or learning complex trading interfaces, you get a personal cryptocurrency data assistant that speaks your language and delivers exactly what you need, when you need it.
Share this article
Help others discover this content
Tap and hold the link button above to access your device's native sharing options
More in Data Processing & Analysis
Continue exploring workflows in this category

Data Processing & Analysisintermediate
1 min read
Generate Creative Solutions with Dual AI Agents, Randomization & Redis - Workflow
Kazi Sakib
Oct 21
Est: 35 minutes

Data Processing & Analysisadvanced
1 min read
Fully Automated Tech News Publishing Pipeline with n8n, OpenAI, Google Workspace & Slack
Nayma Sultana
Oct 20
Est: 1 hour

Data Processing & Analysisintermediate
1 min read
Build an AI-Powered Data Analytics Department with n8n and OpenAI: A Multi-Agent Workflow Guide
Kazi Sakib
Oct 20
Est: 45 minutes