Minimal Telegram bot backend that broadcasts any POST body to subscribed users.
- User sends
/startto your Telegram bot. - Telegram delivers updates to
/telegram/webhook. - Any service posts to
/webhook. - The server broadcasts the payload to every subscribed chat.
/helpshows commands and endpoints./stopunsubscribes a user.
| Variable | Required | Description |
|---|---|---|
TELEGRAM_BOT_TOKEN |
yes | Telegram bot token |
WEBHOOK_BASE_URL |
recommended | Public base URL of the deployed app, for example https://your-app.example.com |
PORT |
no | Defaults to 3000 |
PUBLIC_URL also works if present.
cp .env.example .env
bun install
bun run startThe app sets the Telegram webhook automatically on startup.
If you want to set it manually:
curl -X POST "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook" \
-H 'Content-Type: application/json' \
-d '{"url":"https://your-app.example.com/telegram/webhook"}'Then send /start to subscribe, /help for info, or /stop to unsubscribe.
Send any text or JSON payload to:
curl -X POST https://your-app.example.com/webhook \
-H 'Content-Type: application/json' \
-d '{"status":"SUCCESS","message":"Build finished"}'stage('notify') {
steps {
sh "curl -X POST https://your-app.example.com/webhook \
-H 'Content-Type: application/json' \
-d '{\"job\":\"${env.JOB_NAME}\",\"buildNumber\":\"${env.BUILD_NUMBER}\",\"result\":\"${currentBuild.currentResult}\"}'"
}
}- Subscriber chat IDs are stored in
subscribers.json. - Use persistent storage if you want subscriber data to survive restarts.