> For the complete documentation index, see [llms.txt](https://agpt.co/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://agpt.co/docs/integrations/block-integrations/triggers-4.md).

# Telegram Triggers

These trigger blocks let your agent receive incoming messages and reactions from Telegram in real time via webhooks. When a user sends a message or reacts to one, the trigger fires and outputs structured data (chat ID, user info, message content, file IDs) that downstream blocks can process.

## Telegram Message Reaction Trigger

### What it is

Triggers when a reaction to a message is changed. Works in private chats automatically. In groups, the bot must be an administrator.

### How it works

This block uses the Telegram Bot API webhook system, subscribing to `message_reaction` updates. When a user adds, changes, or removes a reaction on a message in a chat with your bot, Telegram sends an update to the registered webhook URL. The block extracts the chat ID, message ID, reacting user's info, and both the old and new reaction lists. In private chats this works automatically; in group chats the bot must be an administrator to receive reaction updates.

### Outputs

| Output         | Description                                | Type            |
| -------------- | ------------------------------------------ | --------------- |
| error          | Error message if the operation failed      | str             |
| payload        | The complete webhook payload from Telegram | Dict\[str, Any] |
| chat\_id       | The chat ID where the reaction occurred    | int             |
| message\_id    | The message ID that was reacted to         | int             |
| user\_id       | The user ID who changed the reaction       | int             |
| username       | Username of the user (may be empty)        | str             |
| new\_reactions | List of new reactions on the message       | List\[Any]      |
| old\_reactions | List of previous reactions on the message  | List\[Any]      |

### Possible use case

**Sentiment tracking** — Monitor reactions on bot-posted announcements to gauge audience sentiment in real time.

**Approval workflows** — Use a thumbs-up reaction as a lightweight approval signal to trigger downstream actions like deployments or task assignments.

**Engagement analytics** — Aggregate reaction data across messages to identify which content resonates most with your audience.

***

## Telegram Message Trigger

### What it is

Triggers when a message is received or edited in your Telegram bot. Supports text, photos, voice messages, audio files, documents, and videos.

### How it works

This block registers a webhook with the Telegram Bot API that subscribes to `message` and `edited_message` updates. Incoming messages are routed by content type — text, photo, voice, audio, document, or video — based on the event filter you configure. When a matching message arrives, the block extracts common fields (chat ID, sender info, message ID) along with type-specific data such as the text content, file IDs for media, or captions. File IDs can be passed to the Get Telegram File block to download the actual media. If the "edited\_message" event is enabled, the block also fires when a user edits a previously sent message, with the `is_edited` output set to `true`.

### Inputs

| Input  | Description                  | Type          | Required |
| ------ | ---------------------------- | ------------- | -------- |
| events | Types of messages to receive | Message Types | Yes      |

### Outputs

| Output          | Description                                                                              | Type            |
| --------------- | ---------------------------------------------------------------------------------------- | --------------- |
| error           | Error message if the operation failed                                                    | str             |
| payload         | The complete webhook payload from Telegram                                               | Dict\[str, Any] |
| chat\_id        | The chat ID where the message was received. Use this to send replies.                    | int             |
| message\_id     | The unique message ID                                                                    | int             |
| user\_id        | The user ID who sent the message                                                         | int             |
| username        | Username of the sender (may be empty)                                                    | str             |
| first\_name     | First name of the sender                                                                 | str             |
| event           | The message type (text, photo, voice, audio, etc.)                                       | str             |
| text            | Text content of the message (for text messages)                                          | str             |
| photo\_file\_id | File ID of the photo (for photo messages). Use GetTelegramFileBlock to download.         | str             |
| voice\_file\_id | File ID of the voice message (for voice messages). Use GetTelegramFileBlock to download. | str             |
| audio\_file\_id | File ID of the audio file (for audio messages). Use GetTelegramFileBlock to download.    | str             |
| file\_id        | File ID for document/video messages. Use GetTelegramFileBlock to download.               | str             |
| file\_name      | Original filename (for document/audio messages)                                          | str             |
| caption         | Caption for media messages                                                               | str             |
| is\_edited      | Whether this is an edit of a previously sent message                                     | bool            |

### Possible use case

**Conversational AI bot** — Receive text messages from users and feed them into an AI agent that generates and sends replies.

**Photo processing pipeline** — Trigger on incoming photos, download them with Get Telegram File, run image analysis or OCR, and reply with the results.

**Voice message transcription** — Capture voice messages, download the audio file, pass it to a speech-to-text service, and send the transcript back to the user.

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://agpt.co/docs/integrations/block-integrations/triggers-4.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
