Telegram Setup¶
Telegram requires a TELEGRAM_BOT_TOKEN and a TELEGRAM_CHAT_ID.
1. Get the Bot Token¶
- Open Telegram and search for
@BotFather. - Start the chat and send
/newbot. - Follow the prompts to set a display name and username (e.g.,
my_test_bot). - Copy the token provided (e.g.,
123456:ABC-DEF...). This is yourYOUR_BOT_TOKEN.
2. Get your Chat ID¶
- Start a chat with your new bot and send any message (e.g., "hi").
- In a browser, open:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates - In the JSON response, find the numeric
idinside thechatobject.
Environment Configuration¶
Add these to your .env file:
TELEGRAM_BOT_TOKEN="YOUR_BOT_TOKEN"
TELEGRAM_CHAT_ID="YOUR_CHAT_ID"
Sample Program¶
from fenn.notification.services.telegram import Telegram
telegram = Telegram()
resp = telegram.send_notification("Testing Telegram")