sendRichMessageDraft method lets you show tool statuses, and the can_stop parameter enables a Stop button.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. So that users can 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 contents of the existing draft. The Stop button is activated by the can_stop parameter. To tie statuses to tool calls, start and finish events are needed: on start, a step with a clear label is added; on finish, the result is recorded. Several 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.
This approach turns an empty chat with a "typing…" label into a visual status panel. The user sees what stage the agent is at: searching, reading a source, processing the result. 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.
The article references previous breakdowns on Habr: 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 the final answer. It's important to remember the timer: if a tool runs longer than 30 seconds, the draft must be periodically refreshed, even when the status text hasn't changed. Otherwise, the status block will disappear while the agent is still working.
Source: habr.com · post in Telegram