Back to Articles How-to

How to Send Telegram Notifications from Your Server

Julio Andres March 25, 2026 6 min read Telegram · Backend · API

You have a server running somewhere — maybe a Node.js API on a VPS, a Python script on a cron job, or a Go service in a Docker container. Something happens (a deploy finishes, a payment comes in, a background job fails) and you want to know about it. Right now. On your phone.

Telegram is perfect for this. It's fast, it works on every device, notifications actually show up (unlike email), and you probably already have it open. The problem is that setting up the Telegram Bot API directly is a pain: you need to create a bot with BotFather, manage tokens, figure out chat IDs, handle the webhook or polling, and write the HTTP calls yourself. For what? To send a text message.

There's a simpler way. Let me show you how I do it.

The Hard Way: Telegram Bot API Directly

If you've tried this before, you know the drill. You go to BotFather, create a bot, get a token, then figure out what chat_id your user or group has. You end up writing something like this:

The manual approach
# You need to know your chat_id beforehand
# And manage the bot token yourself
# And handle errors, retries, rate limits...

curl -s -X POST \
  https://api.telegram.org/bot<YOUR_BOT_TOKEN>/sendMessage \
  -d chat_id=<CHAT_ID> \
  -d text="Deploy finished"

It works. But now you need to manage that bot token securely, keep track of chat IDs for every person or group you want to notify, handle Telegram's rate limiting (30 messages per second to different chats, 1 per second to the same chat), and deal with delivery failures. If you want to also send to Discord or Slack later, that's a completely separate integration.

For a quick script, maybe that's fine. But if you're building something real — a SaaS, a monitoring setup, a team notification system — this gets messy fast.

The Easy Way: One API Call

With NotificationsBot, you skip all of that. No bot tokens, no chat IDs, no webhook servers. You make one HTTP POST to a REST API, and the message shows up in Telegram. Here's what it looks like:

cURL
curl -s -X POST https://api.notificationsbot.com/event \
  -H "Authorization: Bearer $NOTIFICATIONSBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "server-alerts",
    "title": "Deploy finished",
    "message": "v2.4.1 deployed to production successfully."
  }'

That's it. The notification arrives on your Telegram in under 2 seconds. No Telegram-specific code, no bot management, no chat IDs to look up. And if tomorrow you want the same notification on Discord or Slack, you just add a subscriber to the channel — no code changes.

Setting It Up (5 Minutes)

Before you can send that first request, you need three things: an account, a channel, and a subscriber. Here's the quick version:

That's the one-time setup. From here on, it's just API calls from your code.

Need a detailed walkthrough?

Check out Getting Started with Telegram Notifications in 5 Minutes for a step-by-step guide with screenshots.

Real Examples from Real Servers

Here's how I actually use this in production. These aren't hypothetical — these are patterns I've put in real projects.

Deployment Notifications

At the end of your CI/CD pipeline, add one step. Your team knows the moment a deploy goes out, without checking GitHub or waiting for someone to say "I just deployed."

GitHub Actions / Shell
# Add this as the last step in your deploy script
curl -s -X POST https://api.notificationsbot.com/event \
  -H "Authorization: Bearer $NOTIFICATIONSBOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"channel\": \"deployments\",
    \"title\": \"Deployed to production\",
    \"message\": \"$APP_NAME v$VERSION deployed by $GITHUB_ACTOR\"
  }"

Cron Job Failures

Cron jobs fail silently. That's their whole thing. The backup script that's been broken for two weeks? Nobody noticed because the output goes to /dev/null. Fix that with three lines:

Bash
#!/bin/bash
# backup.sh

pg_dump mydb > /backups/mydb_$(date +%F).sql

if [ $? -ne 0 ]; then
  curl -s -X POST https://api.notificationsbot.com/event \
    -H "Authorization: Bearer $NOTIFICATIONSBOT_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "channel": "server-alerts",
      "title": "Backup failed",
      "message": "Database backup for mydb failed. Check the server."
    }'
fi

Error Monitoring in Your App

You don't need a full observability platform to know when things break. Sometimes a Telegram message is all you need. Here's how to wire it up in the languages you're probably using:

Python
# notify.py
import os
import requests

API_KEY = os.environ["NOTIFICATIONSBOT_API_KEY"]

def notify(title: str, message: str, channel: str = "server-alerts"):
    requests.post(
        "https://api.notificationsbot.com/event",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json={"channel": channel, "title": title, "message": message},
        timeout=5,
    )

# In your code:
try:
    process_payment(order)
except Exception as e:
    notify("Payment failed", f"Order #{order.id}: {str(e)}")
Node.js
// notify.js
const API_KEY = process.env.NOTIFICATIONSBOT_API_KEY;

async function notify(title, message, channel = "server-alerts") {
  await fetch("https://api.notificationsbot.com/event", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ channel, title, message }),
  });
}

// In your Express error handler:
app.use((err, req, res, next) => {
  notify("Server error", `${req.method} ${req.path}: ${err.message}`);
  res.status(500).json({ error: "Internal server error" });
});
Go
// notify.go
package main

import (
    "bytes"
    "encoding/json"
    "net/http"
    "os"
)

func notify(title, message string) {
    body, _ := json.Marshal(map[string]string{
        "channel": "server-alerts",
        "title":   title,
        "message": message,
    })

    req, _ := http.NewRequest("POST",
        "https://api.notificationsbot.com/event",
        bytes.NewBuffer(body))
    req.Header.Set("Authorization", "Bearer "+os.Getenv("NOTIFICATIONSBOT_API_KEY"))
    req.Header.Set("Content-Type", "application/json")

    http.DefaultClient.Do(req)
}

Why Not Just Use the Telegram Bot API?

You absolutely can. If you have one server, one person to notify, and you don't mind managing bot tokens and chat IDs, the direct approach works. But here's what you get with NotificationsBot that you don't get with raw Telegram:

If you're building something for yourself and a quick script is enough, go direct. If you're building something for a team or a product, use an API that handles the hard parts.

Going Further

Once the basics are working, here are some ideas to make your notification setup really useful:

Keep it useful

The biggest mistake with notifications is sending too many. If your Telegram is flooded with noise, you'll start ignoring everything — including the alerts that matter. Be selective. Notify on things that require action, not on things that are "nice to know."

Start Sending Notifications in 5 Minutes

Sign up for the free tier, create a channel, and send your first Telegram notification. No credit card, no bot setup.

Start for free