Most production applications need some form of real-time alerting.
When something goes wrong — a payment fails, an API crashes, or a user submits a contact form — someone needs to know immediately.
Large teams often use tools like Sentry, Datadog, or PagerDuty for this. These platforms are powerful, but they can also be expensive and complex to configure, especially for small projects or solo developers.
So instead of integrating a full observability stack, I built a lightweight alerting system using something I already use every day: Telegram.
In this guide, I’ll show you how to set up a free Telegram-based notification system that can alert you about:
- server errors
- new leads and contact form submissions
- important business events like payments or signups
Why Telegram Works So Well for Alerting
Telegram is surprisingly perfect as a developer alerting channel:
- It’s free
- Push notifications are instant
- Bots are easy to create
- Messages support Markdown, HTML, emojis, and buttons
- You can add your entire team to a group and everyone gets notified at once
Instead of building dashboards or constantly checking logs, your application can send messages directly to a Telegram group.
What You Need Before Starting
You only need four things:
- A Telegram account
- A Telegram bot
- A Telegram group
- Your bot token and chat ID
That’s it. No servers, no SDKs, no third-party monitoring service.
Step 1: Create a Telegram Bot
Open Telegram and search for @botfather.
Run the command:
/newbot
Follow the prompts and Telegram will give you a bot token.
This token is basically the password your application will use to send messages.
If you’ve never done this before, you can simply ask any AI assistant:
“How do I create a Telegram bot and get the bot token?”
Or follow this tutorial.
Step 2: Create a Group and Add the Bot
Create a Telegram group for alerts, then:
- Add your bot to the group
- Add your teammates
- Make sure notifications are enabled for the group
This allows your app to send one message and notify everyone at once.
Step 3: Get the Telegram Chat ID (Important Step)
Telegram bots don’t send messages using usernames or group names. They use a chat ID.
To get it:
- Send any message in the group
- Open your browser and visit:
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
You’ll see a JSON response. Look for:
"chat": {
"id": -1001234567890,
"title": "My Alerts Group"
}
Copy the id. That is your chat ID.
Step 4: Send Your First Message Using the Telegram Bot API
Telegram provides a simple HTTP endpoint called sendMessage.
POST https://api.telegram.org/bot<TOKEN>/sendMessage
Example payload:
{
"chat_id": "-1001234567890",
"text": "Hello from my web app"
}
You can test this using:
- curl
- Postman
- or directly from your backend code
Once this works, your alerting system is already functional.
Additionally, you can read more about the telegram api here.
Making Alerts Readable (Markdown, Emojis, and Structure)
Raw text alerts quickly become hard to read. Instead, format them so they are easy to scan on mobile.
Example:
🚨 *Server Error*
Endpoint: /api/payments
Status: 500
Telegram supports:
- Markdown
- HTML formatting
- emojis
- inline buttons
This means you can send alerts that look structured and professional instead of messy log dumps.
Real-World Things You Can Alert On
Once you have this set up, you can send notifications for almost anything.
Backend alerts
- Unhandled exceptions
- Failed background jobs
- Payment confirmations
Frontend alerts
- Contact form submissions
- New user registrations
- Demo bookings
DevOps alerts
- Deployment completed
- Server restarted
- Environment variables missing
This turns Telegram into a lightweight observability and business monitoring tool.
Sending Alerts from a Backend (Node.js Example)
Here’s a minimal reusable function:
import axios from "axios";
const token = process.env.TELEGRAM_BOT_TOKEN;
const chatId = process.env.TELEGRAM_CHAT_ID;
export async function sendTelegramAlert(message: string) {
const url = `https://api.telegram.org/bot${token}/sendMessage`;
await axios.post(url, {
chat_id: chatId,
text: message,
parse_mode: "Markdown"
});
}
Now you can call this anywhere in your application:
await sendTelegramAlert("🚨 Database connection failed");
Using Telegram Alerts in Frontend Applications
You can also trigger alerts from the frontend when API calls fail.
try {
await api.createOrder(data);
} catch (err) {
await sendTelegramAlert("⚠️ Order creation failed");
}
This is especially useful for catching silent failures during production that users might not report.
Example: Alerting on Contact Form Submissions
Instead of relying only on email, you can push new leads directly to Telegram:
📩 New Contact Form Submission
Name: John Doe
Email: john@example.com
Message: I’m interested in your services.
This ensures you never miss an important message because it landed in spam.
Limitations of This Approach
Telegram alerts are simple and effective, but they are not a full replacement for tools like Sentry or Datadog.
You won’t get:
- dashboards
- error grouping
- performance tracing
However, for:
- side projects
- startups
- internal tools
this approach provides a huge improvement over having no alerting at all.
Final Thoughts
You don’t always need a complex observability stack to stay informed about what’s happening in your application. With just a Telegram bot and a few lines of code, you can build a real-time alerting system that notifies you and your team instantly.
It’s free, quick to set up, and flexible enough to integrate with both frontend and backend workflows.
Sometimes, simple tools are all you need.
Top comments (0)