Send message , photo , document files to Telegram

7 Likes Comment

These are some useful command for you to use a telegram bot send messages in bash shell.

Send message:

curl -s -X POST https://api.telegram.org/botAPI-KEY/sendMessage -d chat_id=CHAT_ID -d text="YOUR MESSAGE HERE"

Send Photo:

curl -F "chat_id=CHAT_ID" -F "[email protected]/path/to/yourimage.png" https://api.telegram.org/botAPI_KEY/sendphoto

Send document files

curl -F [email protected]"path/to/yourfile" https://api.telegram.org/botAPI-KEY/sendDocument?chat_id=CHAT_ID

How to get CHAT_ID for your telegrambot?

  1. Add your bot to a group , and grant the send messages to him.
  2. Chat with your bot, send a welcome message.
  3. Run the following url to get chat_id
https://api.telegram.org/botAPI_KEY/getUpdates

An additional tip for you: Change your bot avatar? Just chat with botfather, and select your botname, send a photo as his avatar. That’s done.

You might like

About the Author: Toc Xoan

This guy likes taking photos, hunting cheap tours, exploring the unique culture of every cities of Vietnam. Contact: [email protected]