Skip to content

Instantly share code, notes, and snippets.

@MadaShindeInai
Forked from dideler/bot.rb
Last active March 12, 2025 21:40
Show Gist options
  • Save MadaShindeInai/57f42efdcfb4d8fc76a448da5ac4f29e to your computer and use it in GitHub Desktop.
Save MadaShindeInai/57f42efdcfb4d8fc76a448da5ac4f29e to your computer and use it in GitHub Desktop.
Sending a notification message to Telegram using its HTTP API via cURL
  1. Create a bot
  2. Get the bot's API token from @BotFather
  3. Add your bot to the chat you'll be sending messages to
  4. Get the ID of the chat
    a. Fetch bot updates and look for the chat id:
    curl https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getUpdates | -r '.result[].message.chat.id'
    b.
https://api.telegram.org/bot<YourBOTToken>/getUpdates
Eg:- 
https://api.telegram.org/bot123456789:jbd78sadvbdy63d37gda37bd8/getUpdates
  1. Send a message using the HTTP API: https://core.telegram.org/bots/api#sendmessage
    curl -X POST \
         -H 'Content-Type: application/json' \
         -d '{"chat_id": "123456789", "text": "This is a test from curl", "disable_notification": true}' \
         https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment