I Built a Telegram AI Agent That Can Actually Use Tools O.O
I've been building Hexzie (HexTelegram) a Telegram-based AI assistant that goes beyond just sending text back and forth. The idea was simple: What if an AI assistant inside Telegram could actually use tools, inspect files, execute commands, search the web, and interact with Telegram itself? So I built it. HexZoNetwork / HexTelegram Hexzie HexTelegram (HTG) — AI Telegram bot by HexzoNetwork ⚠️…
I have built Hexzie, an innovative AI Telegram assistant that goes beyond simple text exchange. This cutting-edge tool allows the AI to use various tools, inspect files, execute commands, search the web, and interact directly with Telegram.
Hexzie is constructed using Telegraf as the Telegram framework, coupled with Node.js. For the tool execution side, I utilized Go, which manages tasks such as shell commands, file manipulation, web searches, screenshot capturing, system information retrieval, and more.
The AI makes use of an OpenAI compatible API, which enables it to determine when it needs to invoke tools. Here's a simplified view of its architecture: Telegram ─► Telegraf ─► Authentication ─► Prompt / Context Builder ─► Agent Loop ──► AI API (tool_calls) ─► Go Tool Runner (shell, files, web, screenshots, calculator, sysinfo) ─► Telegram Tools (send/receive messages, photos, documents, buttons, edit/delete, forward/pin, chat actions, get_chat).
One fascinating feature is the agentic loop. The loop allows the AI to interact with the environment through structured tools. For example, when a user asks the model to check a website and identify its server, the AI sends a web_check() tool request. The Go tool runner then retrieves HTTP/server/technology information. The AI subsequently analyzes this result and responds accordingly.
To provide a more natural user experience, Hexzie maintains a single progress message throughout the tool execution. As the AI streams its reasoning, the progress message updates with action descriptions, status updates, and rotating tips. This method makes tool execution feel more transparent and engaging.
Hexzie also addresses the issue of multiple requests in a chat by keeping track of the newest request. If an older request becomes stale, it is aborted, preventing outdated responses. The bot also features multi-API failover, allowing it to use various endpoints and automatically switch to a backup if the primary one fails.
The assistant retains two layers of conversation context for efficient memory management. Recent messages are kept directly in memory, while older conversations are summarized by the model. It also includes Telegram-native tools, enabling the AI to perform actions specific to Telegram, such as sending messages, documents, photos, and editing or deleting messages.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.