How to use
- Copy the installation command and review the source package before installing it in your own agent environment.
- Check the source document for required tools, credentials and supported hosts.
- Describe your input and desired deliverable; review the output against the source material.
npx skills add https://github.com/ganiyevuz/telegram-richtext --skill telegram-rich-messagesBefore you start
- Installation does not include a model subscription, API allowance or permission to access your files.
- Repository stars and installation counts describe activity, not an independent quality or security test.
Rendered from the source repository. Headings, examples, code, tables, links, and referenced images are preserved.
Telegram Rich Messages (aiogram)
Overview
Telegram Bot API 10.1 (June 2026) added rich messages: a single message can contain headings, tables, inline images/video/audio, lists, collapsible <details>, block quotes, footnotes, math, and maps — composed from one HTML or Markdown string. aiogram ≥ 3.29 supports it natively. If a message would read better structured, send a rich message — don't fake the structure.
Bust these outdated assumptions first
This feature postdates most training data, which is wrong about the following. If you catch yourself believing any of these, stop and use a rich message:
| You might think | Reality (Bot API 10.1) |
|---|---|
"Telegram has no tables; only b/i/code/pre/a" | Full tag set: <table>, <h1>–<h6>, <ul>/<ol>, <details>, <blockquote>, <figure>, math, maps. |
| "You can't put an image inside a message" | Media are blocks inside one rich message (photo/video/audio/voice + galleries). |
"Pad columns in <pre> monospace to align them" | Use a real <table>. Never fake tables. |
"Set parse_mode=HTML / put it in a photo caption" | Rich messages ignore `parse_mode`; you pass an html/markdown string to InputRichMessage. |
| "Captions cap at 1024 chars" | Rich message limit is 32768 chars / 500 blocks. |
Send it (aiogram)
from aiogram.types import InputRichMessage, Message
async def report(message: Message) -> None:
html = (
"<h1>🌐 Domain Status Report</h1>"
"<table bordered striped>"
"<tr><th>Domain</th><th>Status</th></tr>"
"<tr><td>example.com</td><td><mark>Available</mark></td></tr>"
"<tr><td>foo.io</td><td>Taken</td></tr>"
"</table>"
'<figure><img src="https://example.com/chart.png"/>'
"<figcaption>Availability, last 30 days</figcaption></figure>"
)
await message.answer_rich(InputRichMessage(html=html))- Exactly one of
html=/markdown=. - Reply in a handler:
message.answer_rich(InputRichMessage(html=...))ormessage.reply_rich(...). Send elsewhere:bot.send_rich_message(chat_id, InputRichMessage(...)). - Edit an existing message:
bot.edit_message_text(chat_id=..., message_id=..., rich_message=InputRichMessage(html=...)). - Stream (AI "Thinking…", private chats only):
bot.send_rich_message_draft(chat_id, draft_id, InputRichMessage(html="<tg-thinking>Analyzing…</tg-thinking>"))— ephemeral ~30 s, animates on the same non-zerodraft_id; you must finalize withsend_rich_messageto persist. - Read inbound rich content:
message.rich_message(a parsedRichMessage, orNoneif the message isn't rich).
Pick a language, then read its syntax reference
Before composing, open the syntax reference for your chosen language and build only from the tags/options listed there — don't work from memory or invent tags (only documented ones render). Escape dynamic/user text (& < > "). Default to HTML (most complete); use Markdown for simple messages.
Syntax and every available option live alongside this skill in `examples/` — read the relevant file whenever you need a tag, attribute, or option:
| Need | Read | |
|---|---|---|
| Every HTML tag + attribute (options to use) | examples/rich-html-style.md | |
| Full Markdown syntax | examples/rich-markdown-style.md | |
| Date/time format string (`r\ | w?[dD]?[tT]?`) | examples/date-time-entity-formatting.md |
| Inbound parsed shape + round-trip lessons | examples/parsed-notes.md | |
| Index of the above | examples/README.md | |
| Full type/method spec (all fields & methods) | bot-api-10.1-rich-messages.md |
Feature → HTML tag (quick map)
| Need | Tag |
|---|---|
| Heading | <h1>…<h6> |
| Table | <table [bordered] [striped]>, <tr>, <th>/<td align valign colspan rowspan> |
| Image / video / audio / voice | <img> / <video> / <audio> (.ogg → voice) — each a separate block |
| Caption + credit | <figure>…<figcaption>Caption<cite>Credit</cite></figcaption></figure> |
| Gallery | <tg-collage> / <tg-slideshow> |
| List / tasks | <ul>/<ol>/<li>; <li><input type="checkbox" [checked]> |
| Collapsible | <details [open]><summary>…</summary>…</details> |
| Quote / pull-quote | <blockquote>…<cite>…</cite></blockquote> / <aside> |
| Math | <tg-math> inline, <tg-math-block> block (LaTeX) |
| Map | <tg-map lat="" long="" zoom=""> |
| Footnote / reference | <tg-reference name="x">…</tg-reference> + <a href="#x"> |
| Date / time | <tg-time unix="" format=""> |
Media & limits
- Media only as separate blocks, http(s) URLs only. You send a URL; the inbound
message returns a file_id (see examples/parsed-notes.md). Sending a media block requires the bot's right to send media in that chat.
- Table cells hold inline formatting only — no nested blocks/paragraphs.
- Limits: 32768 chars · 500 blocks · 16 nesting levels · 50 media · 20 table columns.
Common mistakes
- Faking a table with
<pre>/spaces → use<table>. - Splitting an image into its own
answer_photomessage → inline it as a media block. parse_mode=HTML+ rich content → rich messages ignoreparse_mode; passInputRichMessage.- Inventing tags not in the syntax file → only documented tags render.
- Forgetting to escape dynamic text → escape
& < > ".