/telegram-skills:tg-rich-streamingfrom telegram-skills
Streams AI-generated text into Telegram with native draft animation and a thinking indicator, replicating ChatGPT-style progressive output in a bot.
Ships in telegram-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Stream AI-generated text into a Telegram private chat with native draft animation and a "thinking" indicator — the same UX as ChatGPT or Claude, directly inside the bot.
Sending requires network access to api.telegram.org and TELEGRAM_BOT_TOKEN.
Checked against the official docs on 2026-12-02: Bot API 10.5 (latest, November 22, 2026). Nothing here was run against a live bot.
| Method | Content | Since | Finalize with |
|---|---|---|---|
sendMessageDraft | plain text 0–4096, parse_mode or entities; empty text shows a "Thinking…" placeholder | 9.3, all bots since 9.5 | sendMessage |
sendRichMessageDraft | InputRichMessage, including <tg-thinking> | 10.1 | sendRichMessage |
Both work only with a private integer chat_id. Both take draft_id, message_thread_id,
can_stop and keep_on_stop, and both drafts live 30 seconds. Bot API 10.2 also permits direct
InputRichMessage.blocks; the draft lifecycle below is unchanged. A rich draft can't upload new
files or upload by URL, so media in a draft must already have a file_id.
Open the draft, update it, finalize it; steps 1–3 are mandatory, and without step 3 the draft disappears after ~30 seconds. Step 4 is optional: edit the permanent message only when its content changes.
Send the first sendRichMessageDraft immediately after the LLM call starts.
draft_id is any non-zero integer you generate once per response; keep it for all updates.
RichBlockThinking signals the model is working.
POST /sendRichMessageDraft
{
"chat_id": <integer>, // private chat only — no @username
"draft_id": 42,
"rich_message": {
"markdown": "<tg-thinking>Thinking…</tg-thinking>"
}
}
Rich HTML tags (like
<tg-thinking>) are valid pass-through inside themarkdownfield — spec explicitly allows HTML tags in Rich Markdown.
RichBlockThinkingis only valid insendRichMessageDraft. It is never stored in aMessage.
Call sendRichMessageDraft again with the same draft_id each time you have enough new text. The client animates the transition.
Throttle: send at most once every 1–2 seconds. The draft is ephemeral (~30 s window) — keep sending updates or move to step 3 before the window closes.
Drop the Thinking block from the first update that contains real content.
# pseudocode — generic async LLM stream
draft_id = generate_nonzero_id()
accumulated = ""
last_sent = 0
send_draft(chat_id, draft_id, thinking_markdown()) # step 1
for chunk in llm.stream(prompt):
accumulated += chunk.text
now = time.monotonic()
if now - last_sent >= 1.5: # throttle
send_draft(chat_id, draft_id, accumulated)
last_sent = now
finalize(chat_id, accumulated) # step 3 — mandatory
After the LLM stream ends, call sendRichMessage. This creates the permanent message. If you skip this, the draft vanishes.
POST /sendRichMessage
{
"chat_id": <integer>,
"rich_message": {
"markdown": "<full generated text>"
}
}
Use editMessageText with the rich_message parameter to update the permanent message later (corrections, appended content, etc.).
POST /editMessageText
{
"chat_id": <integer>,
"message_id": <id from step 3 response>,
"rich_message": {
"markdown": "<revised text>"
}
}
textandrich_messageare mutually exclusive ineditMessageText— use exactly one.
An edit through
rich_messagecan drop custom emoji while returningok: true: tdlib #865 (open, status checked 2026-10-30). Finalization throughsendRichMessageisn't affected; this step and the group fallback are.
Pass can_stop: true on every draft call to show a button that stops further drafts. When the
user presses it, the bot receives the stopped_message_generation update
(MessageGenerationStopped: chat, message_thread_id, draft_id).
stopped_message_generation to allowed_updates, if the bot sets that list.chat.id, message_thread_id and draft_id.keep_on_stop: true on the draft calls and send the text as a
new message. keep_on_stop alone isn't persistence: the draft still disappears after a short
time or when the bot sends a message.POST /sendMessageDraft
{
"chat_id": <integer>,
"draft_id": 42,
"text": "Partial answer so far",
"can_stop": true,
"keep_on_stop": true
}
message_thread_id targets a topic when the bot has forum topic mode enabled in private chats.
Since Bot API 10.5 getMe returns BotFullInfo, and the mode is in its has_topics_enabled,
allows_users_to_create_topics and has_topic_sidebar; the bot switches them itself with
setMySettings (tg-bot-ops). Check two things before you turn it on:
tg-stars-payments/references/stars-economics.md.createForumTopic can succeed while the new topic answers
"message thread not found" to every bot write and TOPIC_ID_INVALID to deleteForumTopic:
tdlib #905 (practitioner report, filed
2026-09-29, closed as completed on 2026-11-10, yet reproduced again on 2026-11-16). Handle the
failed first write and create a replacement topic.Whether streaming needs topics, the sources disagree. Terms §6.2.6 still ties "the streaming of
message drafts" to topics in private chats and their fee; the
Bot API 9.5 changelog allowed all bots to use
sendMessageDraft. Follow the changelog for the method, and read §6.2.6 before enabling topics on
a selling bot. Neither was tested live.
| Trap | What happens | Fix |
|---|---|---|
Skipped sendRichMessage after stream ends | Draft disappears after ~30 s, no permanent message | Always call sendRichMessage with full text as last step |
chat_id is a String or @username | sendRichMessageDraft returns error | Only Integer chat_id supported for drafts; fall back to sendMessage + editMessageText in groups/channels |
| Sending a draft update every token | Flood / rate limit, poor animation | Batch tokens, send at most every 1–2 s |
RichBlockThinking in sendRichMessage | Not stored in Message; spec prohibits it | Remove Thinking block before finalization |
| Partial Markdown mid-stream | Unclosed ``` or ** renders broken | Either send complete blocks only, or use raw text during streaming and apply Markdown only at finalization |
| 30-second window expires mid-stream | Draft gone | If stream is slow, send a keep-alive draft update (even unchanged text) before the window closes |
| Stream keeps running after the user pressed Stop | Tokens are spent, drafts keep coming | Handle stopped_message_generation and cancel the model call |
keep_on_stop treated as saved text | The draft disappears after a short time | Send the partial text as a new message |
sendRichMessageDraft is private-chat only. For groups and channels:
sendMessage with "⌛ Generating…" placeholder.editMessageText (rich_message) when done.No real-time animation, but the final message is rich-formatted.
sendMessageDraft POST /bot<TOKEN>/sendMessageDraft
chat_id Integer required — private chat only
message_thread_id Integer optional
draft_id Integer required — non-zero; same id = animated update
text String optional — 0-4096; empty shows "Thinking…"
parse_mode String optional
entities Array of MessageEntity optional
can_stop Boolean optional — show the stop button
keep_on_stop Boolean optional — keep the draft briefly after stop
sendRichMessageDraft POST /bot<TOKEN>/sendRichMessageDraft
chat_id Integer required — private chat only
message_thread_id Integer optional
draft_id Integer required — non-zero; same id = animated update
rich_message InputRichMessage required
can_stop Boolean optional — show the stop button
keep_on_stop Boolean optional — keep the draft briefly after stop
sendRichMessage POST /bot<TOKEN>/sendRichMessage
chat_id Integer or String required, except for an ephemeral reply to a callback
rich_message InputRichMessage required
→ returns Message (use .message_id for edits)
editMessageText POST /bot<TOKEN>/editMessageText
chat_id Integer or String
message_id Integer
rich_message InputRichMessage (mutually exclusive with "text")
InputRichMessage fields: exactly one of html, markdown, or blocks, optional is_rtl, optional skip_entity_detection.
../tg-rich-messages/SKILL.md — full block & inline type reference../../reference/rich-messages-spec.md — Rich Message API referenceWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub serejaris/telegram-skills --plugin telegram-skills15 skills in this plugin
/tg-bot-opsUse when running a Telegram bot in production: webhook or long polling, allowed_updates, webhook secret token, bot settings from code (setMySettings, getMe, privacy mode, callback_query_mode), botinvite links, 429 and retry_after, file retries, broadcast limits and paid broadcasts, lost updates on shutdown, a poison update after new Bot API types, t.me outage and fallback domains, local Bot API server./tg-capability-mapUse before promising a Telegram feature or designing around one: what a bot can do in Bot API, what lives only in the client or MTProto (scheduled posts, channel stats, poll stats, channel stories, folders, boosts, welcome messages, communities), and what never to promise from a bot./tg-classic-messagesUse when sending or editing ordinary Telegram bot messages: sendMessage text, MarkdownV2/HTML escaping and entities, quotes, date_time, custom emoji, link previews, photos and documents with captions, albums, upload size limits, protect_content, copy, forward, delete. Also use to choose between a classic message and a rich message./tg-markdown-to-richUse when converting an existing Markdown file or stdin into a Telegram Rich Message (InputRichMessage.markdown) for sendRichMessage, including file_id, URL, and multipart upload media bindings. Triggers: "send markdown to Telegram", "convert doc to rich message", "telegram rich message from file"./tg-miniapp-launch-authUse when choosing how a Telegram Mini App opens (keyboard, inline or menu button, main app, direct link, startapp, join request) or when a server must trust a Mini App user: validating initData by HMAC or Ed25519, signature in the check string, auth_date, isVersionAtLeast gating, origin protection, test launch links in the test environment./tg-miniapp-uiUse when building or debugging the interface of a Telegram Mini App: theme colors and dark mode, safe areas and notches, fullscreen, keyboard and viewport height, MainButton and SecondaryButton, BackButton, haptic feedback, performance on weak Android, or a layout bug that shows up only on a real iPhone, Android or Desktop client.Other plugins' skills for the same job