Skip to content

Instantly share code, notes, and snippets.

@ferranb
Last active November 29, 2025 23:36
Show Gist options
  • Select an option

  • Save ferranb/5dae4d86948425f337e8be22f34818fb to your computer and use it in GitHub Desktop.

Select an option

Save ferranb/5dae4d86948425f337e8be22f34818fb to your computer and use it in GitHub Desktop.
Python snippet to send a Telegram message
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