Telegram Bot Integration for Notifications
How it works
- create a bot with BotFather
- get the bot token
- find your chat_id
Example (HTTP API)
telegram_notify.py
import os
import requests
def telegram_send(text: str):
token = os.environ["TELEGRAM_BOT_TOKEN"]
chat_id = os.environ["TELEGRAM_CHAT_ID"]
url = f"https://api.telegram.org/bot{token}/sendMessage"
r = requests.post(url, data={"chat_id": chat_id, "text": text}, timeout=10)
r.raise_for_status()
# telegram_send("Build finished")telegram_notify.py
import os
import requests
def telegram_send(text: str):
token = os.environ["TELEGRAM_BOT_TOKEN"]
chat_id = os.environ["TELEGRAM_CHAT_ID"]
url = f"https://api.telegram.org/bot{token}/sendMessage"
r = requests.post(url, data={"chat_id": chat_id, "text": text}, timeout=10)
r.raise_for_status()
# telegram_send("Build finished")If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
