Skip to content

Instantly share code, notes, and snippets.

@AmrSaber
Created August 19, 2025 15:20
Show Gist options
  • Select an option

  • Save AmrSaber/86241efcefcca5502936a624673b957a to your computer and use it in GitHub Desktop.

Select an option

Save AmrSaber/86241efcefcca5502936a624673b957a to your computer and use it in GitHub Desktop.
How to ping telegram programatically
## Pinging Telegram from Terminal
1. Create a bot
- In Telegram, chat with @BotFather β†’ ```/newbot``` β†’ copy the returned *HTTP API token*.
2. Find your chat ID (where the message should arrive)
- Send any message to your new bot.
- From a terminal run:
```bash
curl -s "https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates"
```
- In the JSON response look for ```"chat":{"id":123456789, ...}``` – that number is your ```chat_id```.
3. Send the notification
```bash
curl -s -X POST "https://api.telegram.org/bot<YOUR_TOKEN>/sendMessage" \
-d chat_id=<CHAT_ID> \
-d text="Hello from the terminal πŸš€"
```
Now you can save that curl as a command or a bash function with parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment