close

How to send photo on telegram bot

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to send photo on telegram bot in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to send photo on telegram bot?

  1. How to send photo on telegram bot?

    I've tried also sending from python using requests. Maybe it's late answer, but leaving this here for others like me.. maybe it'll come to use..

  2. send photo on telegram bot

    I've tried also sending from python using requests. Maybe it's late answer, but leaving this here for others like me.. maybe it'll come to use..

Method 1

If you have local image path:

bot.send_photo(chat_id, photo=open('path', 'rb'))

If you have url of image from internet:

bot.send_photo(chat_id, 'your URl')

Method 2

I’ve tried also sending from python using requests. Maybe it’s late answer, but leaving this here for others like me.. maybe it’ll come to use.. I succeded with subprocess like so:

def send_image(botToken, imageFile, chat_id):
        command = 'curl -s -X POST https://api.telegram.org/bot' + botToken + '/sendPhoto -F chat_id=' + chat_id + " -F [email protected]" + imageFile
        subprocess.call(command.split(' '))
        return

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read