Last active
November 29, 2025 23:36
-
-
Save ferranb/5dae4d86948425f337e8be22f34818fb to your computer and use it in GitHub Desktop.
Python snippet to send a Telegram message
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
| import requests | |
| TOKEN = "GET-FROM-@BotFather" | |
| ID_CHAT = 123 # You have to find it lisening for a https://api.telegram.org/botTOKEN/getUpdates | |
| message = "Hello world!" | |
| url = f"https://api.telegram.org/bot{TOKEN}/sendMessage" | |
| payload = { | |
| "chat_id": ID_CHAT, # https://gist.github.com/ferranb/42542c3122fae6631f7aa27e45ad9c83#file-get_telegram_updates-py | |
| "text": message | |
| } | |
| response = requests.post(url, data=payload) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment