Sending a photo to a Telegram channel the easy way

Paolo Montalto
5 min readFeb 1, 2023

Today we’ll see by practical examples how to send a picture to a Telegram channel.

In order to be able to do so, you will have first to:

  • Create a Telegram public channel
  • Create a Telegram BOT via BotFather
  • Set the bot as administrator in your channel

Provided that you did the above, now you can send a picture to your channel by issuing a request to the sendPhoto Telegram BOT API.

There’s three ways you can send a picture to Telegram:

  1. If the file is already stored somewhere on the Telegram servers, you don’t need to reupload it, you can just provide its file_id as a parameter
  2. If the file is available at a given URL you can just provide the photo URL (the photo size must not exceed 5MB)
  3. If none of the above applies, you can post the file using multipart/form-data (the photo size must not exceed 10MB)

Since the first two are pretty trivial, we will focus on how to send picture data straight in the request.

The API we are going to use is

https://api.telegram.org/bot[BOT_API_KEY]/sendMessage

--

--

Paolo Montalto
Paolo Montalto

Written by Paolo Montalto

Android Engineer, freelance, mobile developer, software craftsman, guitar strummer, husband, father, humble.

No responses yet