How to build a Telegram notification bot for alerts
By the Botable team
A Telegram notification bot pushes alerts into a chat from something else — a webhook, a scheduled check, an API. Describe what should trigger a message and who should get it, and Botable builds the endpoint and the routing.
What is a notification bot?
A Telegram notification bot is an output device: something else decides an event happened, and the bot's job is to deliver it somewhere a person will actually look. Two input shapes cover nearly everything. A push model exposes an endpoint your system posts to, which suits deploys, errors and form submissions — anything your own code already knows about. A pull model runs a scheduled check against an API or a page and fires when a condition is met, which suits things you do not control. The design work is entirely in restraint: an alert that fires on every event trains people to mute the chat, so useful notification bots deduplicate repeats, group bursts into one message, and route by severity so that the things which can wait until morning do. Storing a short history of what was already sent is what makes deduplication possible.
What commands does it have?
| Command | What it does |
|---|---|
POST /hook | Endpoint your system posts events to |
/subscribe errors | Opts a user into one alert channel |
/mute 2h | Silences non-critical alerts temporarily |
/last | Replays the most recent alerts |
/test | Sends a sample alert to check routing |
What do you need before you start?
- A Telegram bot token from @BotFather
- Either a system that can POST to a URL, or an API worth polling
- A severity model — what wakes someone up, and what does not
How do you build it?
Should alerts be pushed to the bot or polled by it?
Push if your own system knows about the event: it is instant and costs nothing when nothing is happening. Poll when you are watching something you do not control, and say how often — a check every minute against a slow API is how you get rate-limited rather than informed.
How do you stop a notification bot becoming noise?
Ask for three things explicitly: deduplication so the same alert firing fifty times sends one message with a count, grouping so a burst arrives as one summary, and severity routing so only genuine emergencies bypass the mute. A bot without these gets muted in a week and then it is worse than nothing.
How should an alert message be formatted?
What happened, where, and what to do — in that order, in the first line. A stack trace pasted whole is unreadable on a phone. Put the summary in the message and the detail behind a link, and include a timestamp, because "just now" is meaningless when you read it an hour later.
Can different alerts go to different people?
Yes. Store a subscription per user per channel, so the billing alerts go to one group and the deploy failures to another. Describe the channels when you build it; retrofitting routing means re-onboarding everyone who already subscribed.
A prompt you can use as-is
Paste this into Botable and adjust the details. It is specific on purpose — a vague description produces a vague bot.
Build a notification bot. Expose an endpoint that accepts JSON with fields: title, body, severity (info|warn|critical), and source. Post it to my chat formatted as one line of summary, then details, then a timestamp. Deduplicate identical alerts within 10 minutes into a single message with a count, and group bursts of more than 5 alerts into one summary. /mute <duration> silences info and warn but never critical. /subscribe and /unsubscribe manage which sources a user receives. /test sends a sample.
Who is this bot for?
- Small teams who want deploys, errors and uptime in the chat they already watch
- Solo operators without a full on-call platform
- Anyone piping form submissions, orders or sign-ups to a phone
What goes wrong with this kind of bot?
- No deduplication means one flapping check can send hundreds of messages in a minute
- Telegram rate-limits bot sends; a burst without grouping will be throttled and arrive late
- Protect the endpoint with a shared secret, or anyone who finds the URL can post to your chat
Questions about notification bots
Can it alert me when a website goes down?
Yes — that is the pull model. The bot checks the URL on a schedule and messages you when the status code or response time crosses a threshold you set. Say how often to check and how many consecutive failures count as down, so one blip does not page you.
Can alerts go to a channel instead of a private chat?
Yes. Add the bot to a channel or group as an admin and point the alerts there. Channels suit broadcast-only alerting; groups suit alerts people reply to.