/telegram-skills:tg-rich-messagesfrom telegram-skills
Composes and sends structured Telegram bot messages with sendRichMessage: tables, headings, collapsible sections, collages, slideshows, maps, math formulas, rich buttons, and bot UI screens. Use when plain HTML/Markdown sendMessage is insufficient.
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.
Sending requires network access to api.telegram.org and a 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.
Bot API 10.1 introduced Rich Messages. Bot API 10.2 (July 14, 2026) added direct
outgoing block JSON and explicit media bindings. Bot API 10.3 (August 24, 2026) added buttons,
compact tables, expandable quotations and document blocks. Bot API 10.5 (November 22, 2026) made
expandable quotations hold any blocks (blocks instead of text, a breaking change). Rich messages are document-grade content
delivered directly in chat. Think Instant View articles — headings, tables, collage,
slideshow, map, math, collapsible blocks — but sent by a bot via sendRichMessage.
Use sendRichMessage instead of sendMessage when you need:
| Need | Mechanism |
|---|---|
| Section headings (h1–h6) | RichBlockSectionHeading |
| Tables with header rows / spanning cells | RichBlockTable |
| Collapsible sections | RichBlockDetails |
| Collage or slideshow of photos and videos | RichBlockCollage / RichBlockSlideshow |
| Embedded map | RichBlockMap |
| LaTeX math (inline or block) | RichTextMathematicalExpression / RichBlockMathematicalExpression |
| Streaming AI reply with "Thinking…" block | sendRichMessageDraft + RichBlockThinking |
| Footnotes / anchor links | RichTextReference / RichTextAnchorLink |
Stay on classic sendMessage when:
| Need | Why classic wins |
|---|---|
| Bold, italic, code, spoiler and links only | parse_mode: HTML covers it |
| Link preview under the post, or a chosen preview URL | sendRichMessage and InputRichMessage have no link_preview_options |
| A message you will edit, with custom emoji | Rich edits can lose them; see Known bugs |
Use the network-free Python helper for deterministic heading, paragraph, pre, compact table, details and photo blocks with literal strings. It validates a narrow subset, not the complete Bot API. Photo uploads stay in the consumer's authorized transport. See consumer integration for the exact API, illustrated previews, provenance, send/edit lifecycle and local tests.
Inline keyboard styles: primary, success, danger; omit for app default. Product composition: at most one primary CTA per screen; neutral secondary navigation. Green is reserved for confirmed success or a desirable commit, red for genuinely destructive actions. Ordinary Back/Cancel, bonus offers and verification actions remain neutral. Start with heading → brief value → next action; move provider plumbing and limits to contextual About/limits views. Review actual mobile outcomes and user feedback before adding emphasis. RichMessageButton additionally accepts link only for callback buttons. Never put link on InlineKeyboardButton. Native rich button rows use type: "buttons", 1–8 buttons and optional align: left|center|right; these are documented in the reference and intentionally outside the helper subset.
For decision/inference bots, explain what the product does and why it helps with a concrete input → criteria → result sequence. Offer a free catalogue and case preview before an explicit paid/quota-consuming run; cached navigation should not silently repeat inference. Attribute source-backed cases as your observed experiment, an external project, or a synthetic teaching adaptation. Keep source links available and longer provenance in a closed details block. Show actual outputs and disclose missing values honestly. See the onboarding section in consumer integration.
Direct block text is literal RichText. Keep dynamic strings unescaped; HTML escaping belongs only to an HTML renderer. A native JSON code block is {"type":"pre","text":json_string,"language":"json"}. Table cells require align and valign; compact tables use is_compact: true.
Update an acknowledged screen with editMessageText.rich_message, exactly one of text and rich_message. Keep returned Bot API message IDs and check callback ownership/current-screen binding. There is no editRichMessage. Do not silently duplicate a message after an unknown delivery outcome.
Since Bot API 10.5 a callback from the bot's own message may carry inline_message_id instead of message, when the bot set callback_query_mode to auto or inline with setMySettings (tg-bot-ops). Bind screens by whichever of the two arrives, and edit through inline_message_id when message is absent.
sendRichMessage takes an InputRichMessage object in its rich_message field.
Choose exactly one content field:
| Field | When to use |
|---|---|
html | Rich HTML with Telegram-specific tags |
markdown | GitHub-Flavored Markdown + Telegram extensions |
blocks | Direct InputRichBlock[] JSON for deterministic programmatic composition |
Do not pass multiple content fields. With html or markdown, add optional media bindings
for uploaded files, Telegram file_id values, or HTTP URLs.
Optional fields on InputRichMessage:
| Field | Type | Purpose |
|---|---|---|
is_rtl | Boolean | Render message right-to-left |
skip_entity_detection | Boolean | Disable auto-detection of URLs, emails, mentions, etc. |
media | InputRichMessageMedia[] | Resolve tg://photo, tg://video, tg://document, and tg://audio references in markup |
Reference media in markup:




Then bind each ID:
{
"markdown": "## Launch\n\n",
"media": [
{
"id": "cover",
"media": {"type": "photo", "media": "AgAC...file_id"}
}
]
}
Media IDs are 1–64 characters using only letters, digits, _, and -. The nested
InputMedia*.media accepts a Telegram file_id, an HTTP/HTTPS URL, or
attach://<part_name>. Use JSON for file_id and URLs. Use multipart/form-data for
attach:// uploads and provide a file part with the same name.
InputRichMessageMedia.media may be InputMediaAnimation, InputMediaAudio,
InputMediaDocument, InputMediaPhoto, InputMediaVideo, or InputMediaVoiceNote. Markup
exposes four reference schemes: photo, video, document, and audio; animation travels
through video, and voice note through audio.
The caption comes from the markup, not from the binding — the title argument of the
Markdown image syntax (or <figcaption> in HTML):

InputMedia*.caption inside the binding is ignored. What the binding does carry is
player metadata, and for audio it is what turns a raw file into a labelled track in the
message:
{
"id": "live_answer",
"media": {
"type": "audio",
"media": "attach://live_answer_file",
"duration": 4,
"performer": "Grok Voice 2.0",
"title": "Answer: 323"
}
}
| Type | Metadata worth setting |
|---|---|
audio | duration, performer, title — shown in the inline player |
video | duration, width, height, thumbnail, supports_streaming, has_spoiler |
photo | has_spoiler |
Set duration even when Telegram can infer it: several short clips in one message render
as a consistent list only when every one of them reports its length.
Telegram reports a bad binding as one opaque Bad Request. Validate locally first and the
failure names the offending id. Four checks, all cheap:
tg://photo, tg://video, tg://document or tg://audio reference with ?id=X in markup has a binding (tg://user and tg://emoji need none). Missing → the media silently never
renders or the call fails.tg://audio?id=X accepts audio or
voice_note; tg://video?id=X accepts video or animation; tg://photo?id=X accepts
photo; tg://document?id=X accepts document. A mismatch is a definite error.attach://<name> has a matching file part, and the file exists on disk.import re
REF = re.compile(r"tg://(photo|video|document|audio)\?id=([A-Za-z0-9_-]+)")
ACCEPTS = {"photo": {"photo"}, "video": {"video", "animation"}, "document": {"document"},
"audio": {"audio", "voice_note"}}
def check(markup: str, media: list[dict]) -> None:
bound = {item["id"]: item["media"]["type"] for item in media}
refs = set(REF.findall(markup))
referenced = {media_id for _, media_id in refs}
if missing := referenced - bound.keys():
raise ValueError(f"missing bindings: {sorted(missing)}")
if unused := bound.keys() - referenced:
raise ValueError(f"unused bindings: {sorted(unused)}")
for scheme, media_id in refs:
if bound[media_id] not in ACCEPTS[scheme]:
raise ValueError(f"{media_id}: tg://{scheme} cannot carry {bound[media_id]}")
Keep the file paths in a small manifest next to the payload — attachment name, path, MIME type — so the multipart step is a lookup rather than a second source of truth:
[
{"id": "cover", "attachment_name": "cover_file", "path": "cover.png", "mime_type": "image/png"}
]
Use blocks when code already has a structured document tree:
{
"blocks": [
{"type": "heading", "size": 2, "text": "Daily AI Brief"},
{"type": "paragraph", "text": ["One release matters today: ", {"type": "bold", "text": "Opus 5"}]},
{
"type": "photo",
"photo": {"type": "photo", "media": "AgAC...file_id"},
"caption": {"text": "Official launch image"}
}
]
}
Nested blocks use InputRichBlock. Media blocks embed InputMedia* directly. Put captions
in the outer block; captions inside nested InputMedia* are ignored.
curl -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendRichMessage" \
-H "Content-Type: application/json" \
-d '{
"chat_id": '"$CHAT_ID"',
"rich_message": {
"html": "<h2>Weekly Report</h2><p>Highlights from the past week.</p><table bordered><tr><th>Item</th><th>Value</th></tr><tr><td>Sales</td><td><b>142</b></td></tr></table>"
}
}'
import json
import os
import urllib.request
TOKEN = os.environ["TELEGRAM_BOT_TOKEN"]
CHAT_ID = int(os.environ["CHAT_ID"])
payload = {
"chat_id": CHAT_ID,
"rich_message": {
"html": (
"<h2>Weekly Report</h2>"
"<p>Highlights from the past week.</p>"
"<table bordered>"
"<tr><th>Item</th><th>Value</th></tr>"
"<tr><td>Sales</td><td><b>142</b></td></tr>"
"</table>"
)
},
}
req = urllib.request.Request(
f"https://api.telegram.org/bot{TOKEN}/sendRichMessage",
data=json.dumps(payload).encode(),
headers={"Content-Type": "application/json"},
method="POST",
)
with urllib.request.urlopen(req) as resp:
result = json.load(resp)
payload = {
"chat_id": CHAT_ID,
"rich_message": {
"markdown": (
"## Weekly Report\n\n"
"Highlights from the past week.\n\n"
"| Item | Value |\n"
"|------|-------|\n"
"| Sales | **142** |\n"
)
},
}
See examples.md for more complete examples including streaming drafts,
collages, details blocks, and a full multipart upload.
A rich message with uploads is a large multipart request, so the interesting failures are not validation errors — they are the ones where you do not know whether the message went out. Split the response three ways:
| Response | Meaning | Correct reaction |
|---|---|---|
ok: true | Accepted | Store a nonzero message_id as the handle for later editMessageText; 0 means the send was scheduled and the id is unknown (tg-classic-messages, Media) |
HTTP 429 with parameters.retry_after | Not applied | Wait retry_after, then resend (tg-bot-ops) |
Other HTTP 4xx with ok: false | Definite failure, nothing was posted | Fix the payload and resend |
| HTTP 5xx, a non-JSON body or a transport timeout | Unknown delivery outcome: the message may already be in the channel | Do not blind-retry |
Retrying a timed-out sendRichMessage is how a channel gets the same article twice, and there
is no dedup on Telegram's side. Record the delivery outcome as unknown instead, and require a
human (or a lookup of the channel's last message) to decide before anything is sent again.
Automatic retries belong only to the first two rows.
Key fields below are those of the received RichBlock. Outgoing blocks use the InputRichBlock* shapes (a photo block takes InputMediaPhoto, not PhotoSize[]): see the reference.
| Type string | HTML tag | Purpose | Key fields |
|---|---|---|---|
paragraph | <p> | Text paragraph | text: RichText |
heading | <h1>–<h6> | Section heading | text, size: 1–6 (1 = largest) |
pre | <pre> | Preformatted / code block | text, language?: string |
footer | <footer> | Footer text | text: RichText |
divider | <hr/> | Horizontal rule | (no content fields) |
anchor | <a name="..."> | Named anchor point | name: string |
mathematical_expression | <tg-math-block> | Block LaTeX formula | expression: string |
list | <ul> / <ol> | Ordered or unordered list | items: RichBlockListItem[] |
blockquote | <blockquote> | Block quotation | blocks: RichBlock[], credit?: RichText |
expandable_blockquote | <blockquote expandable> | Collapsible quotation (10.3) | blocks: RichBlock[] (10.5, was text), credit?: RichText |
pullquote | <aside> | Centered pull quote | text, credit?: RichText |
details | <details> | Collapsible section | summary: RichText, blocks: RichBlock[], is_open?: true |
table | <table> | Data table | cells: RichBlockTableCell[][], is_bordered?, is_striped?, is_compact?, caption?: RichText |
buttons | <tg-button-row> | One row of buttons (10.3) | buttons: RichMessageButton[], align? |
map | <tg-map> | Static embedded map | location: Location, zoom: 0–24, width, height, caption? |
collage | <tg-collage> | Photo/video grid | blocks: RichBlock[], caption?: RichBlockCaption |
slideshow | <tg-slideshow> | Swipeable photo/video deck | blocks: RichBlock[], caption?: RichBlockCaption |
photo | <img> | Photo block | photo: PhotoSize[], has_spoiler?: true, caption? |
video | <video> | Video block | video: Video, has_spoiler?: true, caption? |
animation | <video> (gif) | Animation / GIF block | animation: Animation, has_spoiler?: true, caption? |
audio | <audio> (mp3) | Audio / music block | audio: Audio, caption? |
voice_note | <audio> (ogg) | Voice message block | voice_note: Voice, caption? |
document | <tg-document> | General file block (10.3) | document: Document, caption? |
thinking | <tg-thinking> | "Thinking…" placeholder (draft only) | text: RichText |
thinkingis only valid insendRichMessageDraft. It cannot appear insendRichMessageand is never stored in a Message.
| Type string | HTML tag | Purpose | Extra fields |
|---|---|---|---|
bold | <b> | Bold | text |
italic | <i> | Italic | text |
underline | <u> | Underline | text |
strikethrough | <s> | Strikethrough | text |
spoiler | <tg-spoiler> | Hidden spoiler text | text |
marked | <mark> | Highlight | text |
code | <code> | Inline monospace | text |
subscript | <sub> | Subscript | text |
superscript | <sup> | Superscript | text |
custom_emoji | <tg-emoji> | Custom emoji | custom_emoji_id, alternative_text |
mathematical_expression | <tg-math> | Inline LaTeX | expression: string |
date_time | <tg-time> | Formatted timestamp | text, unix_time: int, date_time_format: string |
text_mention | <a href="tg://user?id=..."> | User mention by ID | text, user: User |
mention | auto-detected | Username mention | text, username: string |
url | <a href="https://..."> | URL link | text, url: string |
email_address | <a href="mailto:..."> | Email link | text, email_address: string |
phone_number | <a href="tel:..."> | Phone link | text, phone_number: string |
bank_card_number | auto-detected | Bank card highlight | text, bank_card_number: string |
hashtag | auto-detected | Hashtag | text, hashtag: string |
cashtag | auto-detected | Cashtag | text, cashtag: string |
bot_command | auto-detected | Bot command | text, bot_command: string |
anchor | <a name="..."> (inline) | Inline anchor point | name: string |
anchor_link | <a href="#..."> | Link to anchor | text, anchor_name: string (empty = top) |
reference | <tg-reference name="..."> | Footnote definition | text, name: string |
reference_link | <a href="#..."> (ref) | Link to footnote | text, reference_name: string |
**bold** *italic* __bold__ _italic_
~~strikethrough~~ `code` ==marked== ||spoiler||
[Link text](https://example.com)
[Email](mailto:[email protected])
[Phone](tel:+1234567890)
[Mention user](tg://user?id=123456789)


$inline LaTeX formula$
$$block LaTeX formula$$
# H1 ## H2 ... ###### H6
```python
code block with language
--- (divider)
blockquote line
# photo block
# with caption
# video block
# audio block
# voice note
# animation
| Col 1 | Col 2 |
|---|---|
| left | right |
Text[^fn1]. [^fn1]: Footnote text.
| Limit | Value |
|---|---|
| Max UTF-8 characters, including custom emoji alternative text and formula source | 32 768 |
| Max blocks, including nested blocks, list items, table rows, quotation and details blocks | 500 |
| Max levels of nested formatting and blocks | 16 |
| Max media attachments in total | 50 |
| Max table columns | 20 |
Buttons in one buttons block | 1–8 |
| Map zoom range | 0–24 |
Map width + height, ratio | 10 000 in total, ratio at most 20 |
Markup media has two source paths.
media.tg://photo?id=, tg://video?id=, tg://document?id=, and tg://audio?id= require a
matching entry in media.InputMedia*.media accepts file_id, HTTP/HTTPS URL, or multipart attach://.InputMedia* object.Table cells: inline formatting only.
No blocks (<p>, <ul>, <img>, etc.) inside <td> / <th>. Only inline tags.
RichBlockThinking is draft-only.
Can only appear in sendRichMessageDraft. Never in sendRichMessage. Never stored in a
Message object.
sendRichMessageDraft is private-chat only.
chat_id must be an Integer. @username strings are not accepted.
editMessageText: text and rich_message are mutually exclusive.
Pass exactly one. Sending both (or neither) is an error.
Map is static, no markers.
RichBlockMap renders a static tile at the given location and zoom level. No pins,
no interactivity.
Block count includes nesting.
The 500-block limit counts every RichBlockListItem, every table row, every block inside
blockquote / details. Deep nesting exhausts the budget fast.
Collage and slideshow accept both photos and videos.
blocks can mix photo and video blocks. Both may also be placed inside a details
block as collapsible media.
The formatting rules allow custom emoji for bots that purchased additional usernames on Fragment, or in messages the bot sends directly to private, group and supergroup chats when its owner has Telegram Premium. Channels aren't named in the second case. Without a Fragment username, plan a channel post without custom emoji. Rich messages from a bot to a channel with custom emoji were not tested live for this skill.
InputRichMessageContent carries a rich message as a result of an inline query, a guest query
or a Web App query. It has one field, rich_message. Only previously uploaded files may be used
in it, so bind media by file_id:
{
"type": "article",
"id": "report-1",
"title": "Weekly report",
"input_message_content": {
"rich_message": {"markdown": "## Weekly report\n\n",
"media": [{"id": "cover", "media": {"type": "photo", "media": "AgAC...file_id"}}]}
}
}
Practitioner reports, status checked on 2026-12-02. Details: reference.
editMessageText with rich_message returns ok: true and
drops custom emoji: tdlib #865
(2026-07-04), #904 in supergroups when
the original isn't a reply (2026-09-28), #880
for inline messages in groups and channels (2026-07-30). All open. Check the edited message in
a real client, or resend instead of editing.chosen_inline_result without inline_message_id when the result uses
InputRichMessageContent with rich buttons:
tdlib #895 (2026-08-28, open). Take the
id from the callback query of those buttons.| Mistake | Fix |
|---|---|
Passing an array directly as rich_message | Wrap it as {"blocks":[...]} |
Using tg://...id=cover without media | Add an InputRichMessageMedia with id: "cover" |
| Leaving a bound id that markup no longer references | Drop the binding — an unused one is an editing slip, not a no-op |
Binding voice_note behind tg://video?id= | Match the scheme: photo→photo, video→video/animation, document→document, audio→audio/voice_note |
Sending attach://cover in JSON only | Switch the request to multipart/form-data and add the cover file part |
| Nesting the multipart form fields as JSON objects | Every non-file field is a string: json.dumps(rich_message) in one form field |
Putting the caption in InputMedia*.caption of a binding | Captions come from markup — the image title argument or <figcaption> |
Shipping audio bindings without duration/title | The inline player shows an unlabelled blob; set the metadata on the binding |
Retrying a sendRichMessage that timed out | Outcome is unknown — retrying duplicates the post; resolve it before resending |
Putting an InputMedia* caption inside a direct media block | Put the caption on InputRichBlockPhoto / Video / Audio / Document |
Putting <img> or <video> inline in <p> | Move media to its own block, outside <p> |
Adding block elements inside <td> | Only inline tags inside table cells |
Forgetting to call sendRichMessage after streaming | Draft expires after 30 s — always finalize with full message |
| Assuming a narrower fixed map zoom range | Outgoing InputRichBlockMap.zoom is optional and ranges 0–24 |
Using skip_entity_detection for manual link formatting | Set it to true to prevent double-detection when you already mark up URLs manually |
All types, all fields, all format details: ../../reference/rich-messages-spec.md
What 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