Created
August 19, 2025 15:20
-
-
Save AmrSaber/86241efcefcca5502936a624673b957a to your computer and use it in GitHub Desktop.
How to ping telegram programatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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