Integrating Telegram Bot API: A Free & Instant System Alert Solution
While Zalo serves mass consumers and Messenger drives sales, Telegram is the "darling" of administrators (Admin/Dev) and the Crypto/Tech community. With blazing-fast speed, a completely free open API, and the ability to send files up to 2GB, Telegram Bot is an indispensable tool for building a Notification System for businesses.
1. What Can a Telegram Bot Do?
- System Alert: Instant notifications when a server goes down, a website hits a 500 error, or a new order arrives (Real-time).
- Group Management: Automatically block spam, welcome new members, and pin important messages in groups of thousands of people.
- Automation: Turn Telegram into a pocket dashboard, allowing Admins to issue commands to reboot servers or check revenue with just a chat message.
2. Bot Creation Process (Meet BotFather)
Telegram doesn't have a complex Developer Dashboard like Facebook. Everything starts with @BotFather.
- Open Telegram and search for <code>@BotFather</code>.
- Type the command <code>/newbot</code>.
- Set a Display Name and a Username (must end with <code>...bot</code>).
- Receive your HTTP API Token (a secret string used to control the Bot).
3. Technical Guide (Sending Order Notification Messages)
Step 1: Get Your Chat ID
For the Bot to send messages to you (or a Group), it needs to know the "home address" (Chat ID).
- Send any message to your newly created Bot.
- Open your browser and visit: <code>https://api.telegram.org/bot[TOKEN]/getUpdates</code>
- Find the line <code>"id": 123456789</code> in the returned JSON. That is your Chat ID.
Step 2: PHP Code to Send Order Alerts
<code>function sendTelegramAlert($message) {
$token = "YOUR_BOT_TOKEN";
$chatId = "YOUR_CHAT_ID"; // Personal ID or Group ID (usually starts with a minus sign -)
// Encode content to avoid URL errors
$text = urlencode($message);
$url = "https://api.telegram.org/bot$token/sendMessage?chat_id=$chatId&text=$text&parse_mode=HTML";
// Send asynchronous request (to avoid slowing down the website)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 2); // Fast timeout
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
// Use when a new order arrives
$orderInfo = "🔥 NEW ORDER!\n";
$orderInfo .= "Customer: Nguyen Van A\n";
$orderInfo .= "Total: 500,000 VND\n";
sendTelegramAlert($orderInfo);</code></pre>
4. Limitations to Know
- Bots cannot proactively message strangers: A Bot can only send messages to users who have previously chatted with it (clicked Start). This is Telegram's anti-spam mechanism.
- 30 messages/second: This is the Bot's sending rate limit. If you broadcast to millions of users simultaneously, the Bot will be blocked (Flood Limit). You need to split messages into a Queue.
5. Real-World Applications at JAYbranding
<p>At JAYbranding, we deeply integrate Telegram into our operational workflow:
- ✅ Server Monitoring: When server CPU exceeds 80%, the Bot automatically tags the SysAdmin in the technical group.
- ✅ Daily Report: At exactly 23:00 every day, the Bot compiles the revenue report and sends it to the Board of Directors group.
- ✅ VPN & OTP: Send internal login OTP codes via Telegram instead of SMS to save costs.
📞 Automate your business with Telegram Bot!
Hotline: 0989 971 131
FAQ About Telegram Bot
[faqs]
#### Is Telegram Bot free?
Completely free. Telegram currently has no policy for charging API fees.
#### Is data on Telegram secure?
Very secure. Telegram is renowned for its high security and strict policy of not sharing user data.
[/faqs]