Send message , photo , document files to Telegram

102 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 "photo=@/path/to/yourimage.png" https://api.telegram.org/botAPI_KEY/sendphoto

Send document files

curl -F document=@"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

Avatar

About the Author: Toc Xoan

Leave a Reply

Your email address will not be published. Required fields are marked *