HTX Crypto Market Data AI Agent via Telegram - n8n Workflow

Build a powerful n8n workflow crypto AI agent. This n8n template integrates Telegram, the HTX API, and GPT-4o-mini to deliver formatted market reports directly to your chat, triggered by an n8n trigger.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Cryptocurrency traders and analysts requiring fast, structured access to HTX data.

  • Developers looking for advanced n8n templates demonstrating AI Agent tooling and complex HTTP integration.

  • Users needing a secure, authenticated method to query market data via a Telegram bot.

  • Professionals building custom AI agents within the n8n platform.

Overview

This professional n8n workflow solution provides a robust, self-hosted infrastructure for accessing HTX (Huobi) spot market data on demand. The primary challenge this n8n workflow solves is abstracting complex API interactions behind a simple chat interface. By utilizing a specialized HTX AI Agent n8n node, the system intelligently translates a user’s plain text query (via Telegram) into specific HTTP requests to the HTX REST API (e.g., fetching Klines, Order Book Depth, or 24h stats). The AI then formats the raw JSON response into a clean, structured Telegram report. This n8n template is essential for anyone who values efficiency and requires immediate, tailored market data updates, all secured by a user authentication layer built directly into the n8n automation.

How it Works

The entire process begins when a user sends a message to the bot, activating the n8n trigger.


  1. Trigger & Validation: The Telegram Trigger n8n node initiates the n8n workflow upon receiving a new message. An initial security check is performed by the User Authentication Code n8n node, ensuring only an authorized Telegram ID can proceed.

  2. Metadata Setup: The Adds "SessionId" n8n node extracts the user's chat ID for routing the final reply and sets the input message.

  3. AI Orchestration: The core HTX AI Agent n8n node, powered by GPT-4o-mini (via the OpenAI Chat Model n8n node) and connected to Simple Memory, takes the user input. The agent decides which specialized HTX httpRequestTool n8n nodes to call (such as '24h Stats', 'Klines (Candles)', or 'Order Book Depth').

  4. Data Fetching: The selected n8n tool executes the HTTP request against the public HTX API, retrieving raw market data.

  5. Reasoning and Formatting: The agent processes the raw data, using tools like Calculator for spread analysis and Think for JSON cleanup, and then formats the final report into Telegram-compatible HTML structure.

  6. Output Handling: The Splits message is more than 4000 characters Code n8n node checks if the AI's response exceeds Telegram’s message limit, splitting the output into smaller, manageable chunks if necessary.

  7. Delivery: Finally, the Telegram n8n node sends the complete, formatted market report back to the original chat ID, completing the n8n workflow execution.

Installation Guide

To deploy this specialized n8n workflow template, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n Editor UI using the 'New' -> 'Import from JSON' function.

  2. Set Credentials: You must configure two credential sets:

OpenAI API Credential: Required for the OpenAI Chat Model n8n node to power the AI Agent’s reasoning and formatting capabilities (requires access to GPT-4o-mini or similar model).
Telegram API Credential: Required for the Telegram Trigger and final Telegram message node. This is the API key for your bot.

  1. Configure User Authentication: Open the User Authentication (Replace Telegram ID) Code n8n node and replace <> with your personal Telegram User ID to secure access to this n8n automation.

  2. Activate: Ensure all nodes are connected and save the n8n workflow. Activate the n8n trigger by toggling the workflow 'Active' switch.

Node Details

Telegram Trigger (n8n trigger):
Function: Listens for incoming messages from the configured Telegram bot, starting the n8n workflow.
Key Configuration: Configured to listen for message updates.
User Authentication (Code n8n node):
Function: Acts as a security gate, verifying the incoming Telegram user ID against a hardcoded value to prevent unauthorized API usage.
Key Configuration: Contains JavaScript logic to check message.from.id.
Adds "SessionId" (Set n8n node):
Function: Creates a sessionId using the Telegram chat.id and extracts the user's text message, preparing data for the AI Agent and memory modules.
OpenAI Chat Model (LLM n8n node):
Function: Provides the language understanding and output formatting capabilities for the AI Agent (configured for gpt-4.1-mini, serving as the reasoning engine).
Simple Memory (Memory n8n node):
Function: Stores conversational context using the sessionId, enabling multi-turn interactions within this n8n workflow.
HTX AI Agent (Agent n8n node):
Function: The central orchestrator. It uses the LLM to decide which HTX httpRequestTool n8n node to execute based on the user's request. Its system message dictates that it must only fetch and format raw data, not give trading advice.
HTTP Request Tools (e.g., 24h Stats, Klines, Order Book Depth):
Function: These are specialized n8n node tools that the AI Agent can call. They are configured with the specific HTX REST API endpoints (https://api.huobi.pro/market/...).
Key Configuration: Uses expressions ($fromAI) to dynamically populate query parameters (like symbol, period, size) based on the AI's selection.
Splits message is more than 4000 characters (Code n8n node):
Function: Prevents delivery errors by automatically segmenting the final, formatted report into multiple messages if it exceeds the Telegram API's character limit.
Telegram (n8n node):
* Function: Sends the final, structured market data report (or report chunks) back to the user via their Telegram chat.

Related n8n Workflows

Free

Nodes: 11 Nodes
Updated: December 26 2025
View all
Created by

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.

Featured*