Search code examples
pythontelegramtelegram-botpython-telegram-bot

How to send telegram mediaGroup with caption/text


I'm currently using python-telegram-bot and basically what I want to achieve with it is to send telegram messages like this:

telegram post with 3 photos and caption

So the message consists of 2+ photos/videos with text message underneath.

What I've already tried:

  1. sending message with send_message method, and including photo URLs, but it only shows 1 picture which is under the text

  2. sending media group using send_media_group, but this method has no caption parameter as send_photo.


Solution

  • You should use sendMediaGroup, where you can specify media field with an array of photo/video objects but the trick is to set caption property only for the first element of an array. In this case telegram will show that caption below the media content.

    If you'll specify captions for more than one element telegram will show them only when you click on photo preview for each photo separately.