Blog and knowledge base of the service

Sending an animated message in a Telegram bot

An animated Telegram message is a method for sending GIFs and video animations to chats, groups, and channels. Unlike regular videos (`sendVideo'), animations are automatically played without sound, looped, and displayed with previews. Telegram optimizes them for instant viewing, which makes the format ideal for advertising, displaying interfaces, and viral content. The maximum duration is 3 minutes, but less than 15 seconds is recommended for maximum engagement.

Sending an animated message in a Telegram bot

What formats does an animated Telegram message accept and what are the limitations?

Telegram supports various animation message formats, among them:

GIF, ANPG, MP4

Some restrictions:

  1. GIF: When adding a gif through the "Picture" card, the animation will not be played, a static image will be displayed in the messenger. To download the animation, you need to use the "File" card.
  2. Creating a GIF from a collection of photos: To animate a GIF from a collection of photos, you need to use a looped video without audio format.webm is 512x512 pixels in size, weighing up to 256 KB and lasting up to three seconds.
  3. Number of saved GIFs: 200 GIFs can be saved (with Telegram Premium — 400 GIFs)


Popular errors when sending an animated message

400 Bad Request: Wrong file identifier

- Reason: Invalid URL or broken file_id. 

- Solution: Check the Content-Type: video/mp4 for MP4. 

400 Bad Request: Animation duration too long

- Reason: Animation >180 seconds. 

- Solution: Crop via ffmpeg: 

413 Request Entity Too Large

- Reason: The file is >50 MB. 

- Solution: Compress without loss of quality: 

400 Bad Request: Can't parse caption entities

- Solution: Escape special characters in the signature: 

403 Forbidden: Bot was blocked by the user

- Solution: Unblocking is required.

Foreign information

Technical information for the BOT-MARKET API

  1. Message type code (`MessageType'): "9" (for `sendAnimation`). 
  2. Max. Sending speed: 20 messages/second in groups. 


Tips for effective use

1.Animation optimization

  - Convert GIF to MP4 (90% reduction in size): 

  - Frame rate: 15-24 FPS (enough for smoothness). 

2. Preview triggers:

  - The first frame should contain text/invocation (for example: "Swipe down!").

Create a custom JPEG preview if the auto-generated one doesn't fit. 

3. Interactivity:

  Add buttons for actions: 

4. Increased engagement

  - Use loops: 3-5 repetitions of animation. 

  - Add text explanations to the frame (as there is no sound).