# Messages, Editing, Pinning & Rich Text Formatting

> Complete guide to sendMessage, editMessageText, deleteMessage, pinChatMessage, copyMessage, and full HTML / MarkdownV2 rich typography.

**Category:** Telegram Bot API — Methods (A-Z)  
**URL:** https://docs.botlify.cloud/messages-and-formatting  
**Platform:** Botlify Cloud (https://botlify.cloud)  

---

## Telegram Message Lifecycle Overview

   

Every interaction in Telegram begins with message delivery. Beyond standard text, Telegram bots have complete programmatic control over editing existing bubbles, deleting spam, pinning announcements, forwarding/copying messages, and styling typography with rich HTML and MarkdownV2 entities.

   

## 1. Sending Messages & Link Preview Options (sendMessage)

   

In modern Telegram Bot API (v7.0+ / 8.x), link previews are controlled via the dedicated `link_preview_options` object rather than deprecated boolean flags:

   
```php

```

   

## 2. Comprehensive HTML Formatting Reference

   

Botlify Cloud strongly recommends `parse_mode => 'HTML'` for all bot messages because HTML tags can be safely escaped with PHP's native `htmlspecialchars($var, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8')` without risk of syntax breaks.

   
    
| Formatting Style | HTML Tag Syntax | Visual Output / Behavior |
| --- | --- | --- |
| Bold | bold text or text | bold text |
| Italic | italic text or text | italic text |
| Underline | underlined text or text | underlined text |
| Strikethrough | strikethrough or text | strikethrough |
| Spoiler | secret | Blurs text until user taps to reveal |
| Inline Code | $balance = 50; | Monospaced inline snippet (one-tap copy in Telegram) |
| Code Block | code | Multi-line monospaced block with syntax label |
| Blockquote | Quoted note | Indented quotation with accent bar |
| Expandable Quote | Long text... | Collapsible quotation with "Show More" accordion (API 7.3+) |
| Hyperlink | Visit Site | Clickable web link |
| Mention by User ID | John Doe | Mentions user even if they do not have a public username |
| Custom Emoji | 🔥 | Renders verified Telegram Premium custom emoji (API 6.2+) |

   

   
```php

```

   

## 3. Editing Messages & Captions Dynamically

   

Rather than sending a flood of new messages, update existing bubbles in place to create smooth, app-like interfaces:

   
```php

```

   

## 4. Deleting, Pinning & Copying Messages

   
```php

```

   

## 5. Realistic Bot UX with Chat Actions (sendChatAction)

   

When performing heavy tasks (such as AI generation, downloading files, or complex SQLite queries), tell the user your bot is working by showing dynamic status indicators in the Telegram header:

   
    
| Action Name | Displayed Header Status | Ideal Use Case |
| --- | --- | --- |
| typing | "is typing..." | Waiting for AI responses, text formatting, or database lookups. |
| upload_photo | "is sending a photo..." | Generating or fetching high-resolution images. |
| record_video / upload_video | "is sending a video..." | Processing or uploading MP4 video files. |
| record_voice / upload_voice | "is sending audio..." | Synthesizing text-to-speech voice memos. |
| upload_document | "is sending a file..." | Compiling ZIP archives or generating PDF reports. |
| choose_sticker | "is choosing a sticker..." | Selecting animated or reaction stickers. |
| record_video_note | "is sending a video message..." | Processing circular round video notes. |

   

   
```php

```

   

## 6. Real-Time Streaming Message Drafts (sendMessageDraft)

   

Telegram allows AI bots to stream partial message drafts in real time to the user while content is being generated:

   
```php

```

> [!TIP]
> **Botlify Cloud Runtime**
> Credentials are auto-injected in .env — always load them with getenv(): BOT_TOKEN, ADMIN_CHAT_ID, BOT_USERNAME. Main database: database.db (SQLite, WAL mode). Runtime errors: error.log. Quick test: send to $ADMIN_CHAT_ID. Full details: Runtime Reference.
