RU

AI Agent in Telegram: Tool Statuses, Animations, and a Stop Button

Published: 2026-10-05 · Author: AI Release · @ai_release1
AI Agent in Telegram: Tool Statuses, Animations, and a Stop Button

⚡ The gist in 5 seconds - Telegram has a built-in interface for displaying an AI agent's progress: a temporary draft with a status block and animated icons. - The sendRichMessageDraft method lets you show tool statuses, and the can_stop parameter enables a Stop button. - Without updates, the draft disappears after 30 seconds, so it needs to be refreshed via events and a timer. ### 🔍 What was discovered In an article on Habr, Ivan Magda breaks down the operation of the swift-claw agent, which searches for headphone reviews, reads pages, and checks microphone feedback. To let the user see the progress, the bot uses sendRichMessageDraft with a <tg-thinking> tag in rich_message.html. Statuses are updated by sending a request with the same draft_id — this way Telegram replaces the content of the existing draft. The Stop button is activated by the can_stop parameter. To tie statuses to tool calls, you need start and finish events: when a step starts, a new entry with a clear label is added; when it finishes, the result is recorded. Multiple events are combined into a single draft update. All dynamic text (search queries, page titles) is escaped before being inserted into the HTML. When the agent has finished its work, the final response is sent via sendRichMessage — the <tg-thinking> block is not used there, since it is only allowed in drafts. This preserves the final message in the chat history. ### 💡 Why it matters This approach turns an empty chat with a "typing…" label into a visual status panel. The user can see what stage the agent is at: searching, reading a source, processing results. Animated emoji from the AIActions set complement the text statuses, and the Stop button lets you halt the task if it goes off track. The examples in the article use HTTP and pseudocode, so the implementation can be ported to a bot in any language or framework. ### 🧩 Context The article references previous Habr write-ups: streaming via sendMessageDraft and the Rich Messages format. Here, these capabilities are combined into a single interface for an agent that performs several actions before delivering its final answer. Keep the timer in mind: if a tool runs longer than 30 seconds, the draft must be refreshed periodically, even when the status text hasn't changed. Otherwise, the status block will disappear while the agent is still working on the task.

🔗 Read on habr.com

🤖 AI summary
TelegramAI-агентBot
📖
Read the guide on this topic
Read →
← Previoushermes-mobile-app: Android agent Hermes runs entirely on your phoneNext →Notepad — the program Microsoft was afraid to touch for forty years

Source: habr.com · post in Telegram