Telegram
Configure Telegram notifications and send messages from GoLiveKit.
AI Skill for notifications
/notifications in your Copilot / Cursor or other chat to use skill with the provided context./notifications Add notification sending for [describe action/event].
This guide shows how to:
- Create a Telegram bot
- Get your bot token
- Create a group and connect the bot
- Get the group chat ID
- Send notifications from your code
Environment variables
Add the following variables to your .env:
TELEGRAM_BOT_TOKEN=123456789:your_bot_token
TELEGRAM_CHANNEL_ID=1001234567890Both variables are optional. If one is missing, the notifier safely skips sending.
1. Create a Telegram bot
- Open Telegram and search for
@BotFather. - Start a chat and run
/newbot. - Enter a display name for your bot.
- Enter a unique bot username ending in
bot(for examplegolivekit_notify_bot). - Copy the token from BotFather.
Save this token as TELEGRAM_BOT_TOKEN.
2. Create a group and add the bot
- Create a new Telegram group.
- Add your bot to the group.
- Promote the bot to admin if your group permissions require it.
3. Get the group chat ID
The Easiest Way (Using an ID Bot):
- Add
@GetIDsBotto your group. - The bot will instantly post the Chat ID for that group.
- Once you have the ID, you can remove that bot.
Telegram groups use negative chat IDs. In this project, keep only the numeric part in env (TELEGRAM_CHANNEL_ID) and the code adds the - prefix.
Use this URL in your browser (replace <BOT_TOKEN>):
https://api.telegram.org/bot<BOT_TOKEN>/getUpdatesThen send any message in the group and refresh the URL. Look for:
{
"message": {
"chat": {
"id": -1001234567890,
"title": "My Project Alerts"
}
}
}Set TELEGRAM_CHANNEL_ID=1001234567890 (without -).
4. Send notifications from code
Use the default notifier
import notify from '@/lib/notify';
await notify('*Build succeeded* on production');Use Telegram provider directly
import { notifyTelegram } from '@/lib/notify/providers/telegram';
const sent = await notifyTelegram([
'*Deployment completed*',
'',
'Environment: `production`',
'Commit: `abc1234`',
].join('\n'));
if (!sent) {
console.error('Telegram notification was not sent');
}5. How to test notifications
To verify your setup, open this endpoint in your browser or call it with any HTTP client:
http://localhost:3000/api/v1/test/notify/telegramIt sends a test Telegram message using your configured credentials.
If TELEGRAM_BOT_TOKEN or TELEGRAM_CHANNEL_ID is missing, or Telegram responds with a non-2xx status, the helper logs the failure and returns false.