> ## Documentation Index
> Fetch the complete documentation index at: https://help.bots.lt/llms.txt
> Use this file to discover all available pages before exploring further.

# Rich Messages

> Send advanced structured messages with HTML/Markdown formatting, slideshows, tables, buttons, and streaming drafts.

Rich messages support advanced structured formatting like headings, lists, tables, media collages, block quotations, collapsible blocks, footnotes, and LaTeX formulas.

> **Limits:**
>
> * Up to **32,768 UTF-8 characters** in the message text
> * Up to **500 blocks** (including nested blocks)
> * Up to **16 levels** of nesting
> * Up to **50 media attachments**
> * Up to **20 columns** in a table

***

## sendRichMessage

Sends a rich formatted message. Use either `html`, `markdown`, or `blocks` in the `rich_message` object — not multiple.

| Parameter              | Type              | Required | Description                               |
| ---------------------- | ----------------- | -------- | ----------------------------------------- |
| `chat_id`              | Integer or String | Yes      | Target chat ID or `@username`.            |
| `rich_message`         | Object            | Yes      | An `InputRichMessage` object (see below). |
| `disable_notification` | Boolean           | No       | Sends silently.                           |
| `protect_content`      | Boolean           | No       | Prevents forwarding/saving.               |
| `reply_parameters`     | Object            | No       | Message to reply to.                      |
| `reply_markup`         | Object            | No       | Inline keyboard to attach.                |

### InputRichMessage Fields

| Field                   | Type    | Required | Description                                                        |
| ----------------------- | ------- | -------- | ------------------------------------------------------------------ |
| `html`                  | String  | No\*     | Message content using HTML formatting.                             |
| `markdown`              | String  | No\*     | Message content using Markdown formatting.                         |
| `blocks`                | Array   | No\*     | Message content as an array of `InputRichBlock` objects.           |
| `is_rtl`                | Boolean | No       | If `True`, message is displayed right-to-left.                     |
| `skip_entity_detection` | Boolean | No       | If `True`, disables auto-detection of URLs, emails, hashtags, etc. |

> **\*** Exactly one of `html`, `markdown`, or `blocks` must be provided.

```python BLP Example (HTML Table) theme={null}
rich_html_content = """<table bordered>
  <caption>Student Information List</caption>
  <tr>
    <th>Roll</th>
    <th>Name</th>
    <th>Class</th>
    <th>Status</th>
  </tr>
  <tr>
    <td><b>01</b></td>
    <td>Mobassher Ahmed</td>
    <td>Class 10</td>
    <td>Passed</td>
  </tr>
  <tr>
    <td><b>02</b></td>
    <td>Humayun Kabir</td>
    <td>Class 10</td>
    <td>Passed</td>
  </tr>
</table>"""

Bot.sendRichMessage(
    chat_id=u,
    rich_message={
        "html": rich_html_content,
        "is_rtl": False,
        "skip_entity_detection": False
    }
)
```

```python BLP Example (HTML Slideshow + Details + Buttons) theme={null}
rich_html = """
<h1><tg-emoji emoji-id="6163613480936021313">🔒</tg-emoji> Hidely - Hide Photos</h1>

<tg-slideshow>
  <img src="https://example.com/screen1.jpg"/>
  <img src="https://example.com/screen2.jpg"/>
  <figcaption>App Screenshots<cite>Version 2.0</cite></figcaption>
</tg-slideshow>

<aside><b>Your ultimate privacy companion.</b></aside>

<hr/>

<h3>Core Features</h3>
<ul>
  <li><input type="checkbox" checked> <b>Private Vault</b></li>
  <li><input type="checkbox" checked> <b>App Disguise</b></li>
  <li><input type="checkbox" checked> <b>Intruder Selfie</b></li>
</ul>

<details open>
  <summary><b>How it works</b></summary>
  <p>Your files are stored <b>locally</b> with zero cloud exposure.</p>
  <blockquote>We never see your data.<cite>Privacy Promise</cite></blockquote>
</details>

<hr/>

<footer>Your privacy is our architecture.</footer>
"""

Bot.sendRichMessage(
    chat_id=u,
    rich_message={"html": rich_html}
)
```

```python BLP Example (Markdown) theme={null}
md_content = """
# Welcome to Rich Messages
**Bold**, *italic*, ~~strikethrough~~, `code`, ==highlighted==, ||spoiler||

| Feature | Supported |
|:--------|:---------:|
| Tables  | ✅ |
| LaTeX   | ✅ |
| Media   | ✅ |

$$E = mc^2$$

> This is a block quotation
"""

Bot.sendRichMessage(
    chat_id=u,
    rich_message={"markdown": md_content}
)
```

***

## sendRichMessageDraft

Streams a **partial/in-progress** rich message to the user — useful for AI responses that appear progressively. The draft is ephemeral (disappears after \~30 seconds). After generation is complete, call `sendRichMessage` to persist the final message.

| Parameter      | Type    | Required | Description                                                                                                                             |
| -------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `chat_id`      | Integer | Yes      | Target private chat ID.                                                                                                                 |
| `draft_id`     | Integer | Yes      | Non-zero integer identifying the draft. Changes with the same `draft_id` are animated. Different `draft_id` replaces without animation. |
| `rich_message` | Object  | Yes      | The partial message as an `InputRichMessage` object.                                                                                    |
| `can_stop`     | Boolean | No       | If `True`, shows the user a "Stop" button.                                                                                              |
| `keep_on_stop` | Boolean | No       | If `True`, keeps the draft visible when user presses Stop.                                                                              |

> **Note:** Direct file uploads are not supported in drafts. Use already-uploaded file IDs only.

```python BLP Example (Streaming AI Response) theme={null}
import time

# Step 1: Show thinking animation
Bot.sendRichMessageDraft(
    chat_id=u,
    draft_id=1001,
    rich_message={
        "html": "<tg-thinking>Thinking...</tg-thinking>"
    },
    can_stop=True
)

# Step 2: Stream partial content
Bot.sendRichMessageDraft(
    chat_id=u,
    draft_id=1001,
    rich_message={
        "html": "<h2>Analysis</h2><p>Processing your request...</p>"
    },
    can_stop=True
)

# Step 3: Finalize with sendRichMessage
Bot.sendRichMessage(
    chat_id=u,
    rich_message={
        "html": "<h2>Analysis Complete</h2><p>Here are your results: <b>All checks passed!</b></p>"
    }
)
```

***

## Supported HTML Tags

### Text Formatting

| Tag                                 | Effect                  |
| ----------------------------------- | ----------------------- |
| `<b>`, `<strong>`                   | **Bold**                |
| `<i>`, `<em>`                       | *Italic*                |
| `<u>`, `<ins>`                      | Underline               |
| `<s>`, `<del>`, `<strike>`          | ~~Strikethrough~~       |
| `<code>`                            | `Inline code`           |
| `<mark>`                            | ==Highlighted==         |
| `<sub>`                             | Subscript               |
| `<sup>`                             | Superscript             |
| `<tg-spoiler>`                      | Spoiler (tap to reveal) |
| `<tg-emoji emoji-id="...">`         | Custom emoji            |
| `<tg-time unix="..." format="wDT">` | Formatted date/time     |
| `<tg-math>`                         | Inline LaTeX math       |

### Links & Anchors

```html theme={null}
<a href="https://t.me/">Regular URL</a>
<a href="mailto:user@example.com">Email</a>
<a href="tel:+123456789">Phone</a>
<a href="tg://user?id=123456789">User mention</a>
<a name="chapter-1"></a>           <!-- Create anchor -->
<a href="#chapter-1">Jump to chapter 1</a>   <!-- Link to anchor -->
<tg-reference name="note-1">Footnote text</tg-reference>
<a href="#note-1">[1]</a>          <!-- Link to reference -->
```

### Structure

```html theme={null}
<h1>Heading 1</h1> ... <h6>Heading 6</h6>
<p>Paragraph</p>
<pre>Preformatted block</pre>
<pre><code class="language-python">print("Hello")</code></pre>
<footer>Footer text</footer>
<hr/>
<tg-math-block>E = mc^2</tg-math-block>
```

### Lists

```html theme={null}
<!-- Unordered -->
<ul>
  <li>Item one</li>
  <li>Item two</li>
</ul>

<!-- Ordered -->
<ol start="1" type="1">
  <li>First</li>
  <li>Second</li>
</ol>

<!-- Checkboxes -->
<ul>
  <li><input type="checkbox" checked> Done</li>
  <li><input type="checkbox"> Pending</li>
</ul>
```

### Block Quotations

```html theme={null}
<!-- Standard -->
<blockquote>Quote text<cite>The Author</cite></blockquote>

<!-- Expandable (collapsed by default) -->
<blockquote expandable>Long quote...<cite>Source</cite></blockquote>

<!-- Pull quote (centered) -->
<aside>Pull quote text<cite>Author</cite></aside>
```

### Media

```html theme={null}
<!-- Standalone media -->
<img src="https://example.com/photo.jpg"/>
<video src="https://example.com/video.mp4"></video>
<audio src="https://example.com/audio.mp3"></audio>
<tg-document src="https://example.com/file.pdf"></tg-document>

<!-- With caption and spoiler -->
<figure>
  <img src="https://example.com/photo.jpg" tg-spoiler/>
  <figcaption>Caption<cite>Credit</cite></figcaption>
</figure>

<!-- Map -->
<tg-map lat="41.9" long="12.5" zoom="14"/>
```

### Collage & Slideshow

```html theme={null}
<!-- Collage (grid layout) -->
<tg-collage>
  <img src="https://example.com/1.jpg"/>
  <img src="https://example.com/2.jpg"/>
  <figcaption>Caption</figcaption>
</tg-collage>

<!-- Slideshow (swipeable) -->
<tg-slideshow>
  <img src="https://example.com/1.jpg"/>
  <video src="https://example.com/video.mp4"/>
  <figcaption>Slideshow Caption<cite>Credit</cite></figcaption>
</tg-slideshow>
```

### Tables

```html theme={null}
<!-- Basic table -->
<table>
  <tr><th>Name</th><th>Score</th></tr>
  <tr><td>Alice</td><td>95</td></tr>
</table>

<!-- Styled table (bordered + striped + compact) -->
<table bordered striped compact>
  <caption>Table Title</caption>
  <tr>
    <td colspan="2" align="left">Merged Cell</td>
    <td align="right" valign="top">Right Top</td>
  </tr>
</table>
```

### Collapsible Details Block

```html theme={null}
<!-- Collapsed by default -->
<details>
  <summary>Click to expand</summary>
  <p>Hidden content here.</p>
</details>

<!-- Expanded by default -->
<details open>
  <summary><b>Always visible summary</b></summary>
  <ul>
    <li>Item 1</li>
    <li>Item 2</li>
  </ul>
</details>
```

### Interactive Buttons

Buttons can appear **inline** inside text or in **row blocks**.

```html theme={null}
<!-- Inline buttons inside paragraph -->
<p>Choose an action:
  <tg-button type="url" style="success" url="https://bots.lt">Visit Site</tg-button>
  <tg-button type="callback_data" style="link" data="btn_info">More Info</tg-button>
  <tg-button type="web_app" style="danger" url="https://bots.lt">Open App</tg-button>
  <tg-button type="copy_text" text="copied!">Copy Code</tg-button>
  <tg-button type="disabled">Unavailable</tg-button>
</p>

<!-- Button rows with alignment -->
<tg-button-row align="left">
  <tg-button type="url" url="https://t.me">Telegram</tg-button>
  <tg-button type="callback_data" data="info">Info</tg-button>
</tg-button-row>

<tg-button-row align="center">
  <tg-button type="switch_inline_query" query="search">Search Inline</tg-button>
</tg-button-row>

<tg-button-row align="right">
  <tg-button type="login_url" url="https://t.me" forward-text="Login" request-write-access>Login</tg-button>
</tg-button-row>
```

**Button types:**

| `type`                             | Description                        |
| ---------------------------------- | ---------------------------------- |
| `url`                              | Opens a URL                        |
| `callback_data`                    | Sends callback to bot              |
| `web_app`                          | Opens a Mini App                   |
| `login_url`                        | Telegram Login Widget              |
| `switch_inline_query`              | Opens inline mode in another chat  |
| `switch_inline_query_current_chat` | Opens inline mode in current chat  |
| `switch_inline_query_chosen_chat`  | Opens inline mode with chat filter |
| `copy_text`                        | Copies specified text to clipboard |
| `disabled`                         | Shows a non-interactive button     |

**Button styles:** `success` (green), `danger` (red), `primary` (blue), `link` (borderless link).

***

## Supported Markdown Syntax

| Syntax                       | Effect             |
| ---------------------------- | ------------------ |
| `**bold**` or `__bold__`     | Bold               |
| `*italic*` or `_italic_`     | Italic             |
| `~~strikethrough~~`          | Strikethrough      |
| `` `code` ``                 | Inline code        |
| `==marked==`                 | Highlighted        |
| `\|\|spoiler\|\|`            | Spoiler            |
| `[text](URL)`                | Link               |
| `[user](tg://user?id=...)`   | User mention       |
| `![👍](tg://emoji?id=...)`   | Custom emoji       |
| `$x^2$` or `$$E=mc^2$$`      | Inline/block math  |
| ` ```python ``` `            | Code block         |
| `# H1` to `###### H6`        | Headings           |
| `---`                        | Divider            |
| `- item`, `* item`, `+ item` | Unordered list     |
| `1. item`                    | Ordered list       |
| `- [ ] task`, `- [x] done`   | Task list          |
| `> quote`                    | Block quotation    |
| `![](URL "Caption")`         | Media with caption |
| `\| col \| col \|`           | Table              |
| `[^id]: text`                | Footnote           |
