Send messages to Telegram using curl
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
- Search for @BotFather and click start
- Type /newbot to add a new bot
- Enter the name of the new bot
- Save the API Key
Add a new channel
- Goto the Menu
- Create a new channel
- Make the channel private
- Choose Add user
- Add the bot user
- Adjust the permissions to your needs
Obtaining the chat id
- Send test message
- Get the chat ID by using the following URL:
https://api.telegram.org/bot<BOT-ID>/getUpdates
Sending messages using curl
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'