pythonapitelegram

How can I send image with text using telegram bot API?


I'm trying to send a message to telegram using Telegram API bot.

I want to make a GET request, that will send both text and image to my telegram channel.

Now fetch looks like that:

telegram_msg = requests.get('https://api.telegram.org/<botname>:botAPI/sendMessage?chat_id=<chat_id>=some text')

How can I include an image that is located here and send both text and image in one message?

Thank you for your help.

UPD: I can send image using sendPhoto, but how can I combine these two requests into one? So that I can send both image and text?


Solution

  • use caption parameter in sendPhoto method

    telegram_msg = requests.get('https://api.telegram.org/bot<botAPI>/sendPhoto?chat_id=<chat_id>&caption=some text')