Send messages to Telegram using curl

From test.coolscript.org
Jump to navigation Jump to search

The following samples shows how to send messages to Telegram using curl.
To be short, this is working with an existing account, no need to add two account for doing this.
To setup you first create a bot, then a channel and then obtaining the required ID's for curl.


Add a new bot[edit]

  • Search for @BotFather and click start

Final-bot01.png]


  • Type /newbot to add a new bot

Final-bot02.png


  • Enter the name of the new bot

Final-bot03.png

  • Save the API Key

Final-bot04.png

Add a new channel[edit]

  • Goto the Menu

Final-bot04A.png

  • Create a new channel

Final-bot05.png


  • Make the channel private

Final-bot06.png

  • Choose Add user

Final-bot07.png

  • Add the bot user

Final-bot08.png

  • Adjust the permissions to your needs

Final-bot09.png

Obtaining the chat id[edit]

  • Send test message

Final-bot10.png

  • Get the chat ID by using the following URL:
https://api.telegram.org/bot<BOT-ID>/getUpdates

Final-bot11.png

Sending messages using curl[edit]

Before you send messages make sure that you've added all participants to the channel.

  • Curl
curl 'https://api.telegram.org/bot<BOT-ID/sendMessage?chat_id=-<CHAT-ID>&text=Message Text'