Automate Order Push Notifications via Telegram in 1C-Bitrix
When an order status changes in 1C-Bitrix, standard email notifications often end up in spam—open rates rarely exceed 20%. Telegram delivers messages instantly with a 90% read rate. Implementing a Telegram bot reduces support inquiries by 30–40% and significantly cuts SMS costs, as confirmed by a RetailCRM study. Additionally, operational costs drop: push notifications cut manual operator responses by 50%, saving substantial funds on an average order flow. We assess your project in one day—contact us to discuss the details.
Telegram is 4× faster than email in delivery and 2× cheaper than SMS. In 9 out of 10 cases, users read a Telegram push notification within the first minutes. This reduces support load and speeds up customer communication. For online stores on 1C-Bitrix, the integration is implemented through the OnSaleOrderStatusChange event handler and does not require replacing the existing notification system.
Problems Solved by a Telegram Bot
- Email in spam: up to 30% of emails never reach the customer. Telegram guarantees 99% delivery.
- Notification delays: emails can take up to 5 minutes. Telegram—1–2 seconds.
- Low readability: 80% of emails go unread. Telegram messages are opened within minutes.
- Manual support: operators spend time answering status queries. The bot takes over.
Why Telegram Notifications Are More Effective than Email?
Comparison by key metrics:
| Parameter | Telegram | |
|---|---|---|
| Delivery | Up to 5 minutes, often spam | Instant, 99% delivery |
| Readability | 20% open rate | 90% read rate |
| Setup | Built into Bitrix | Requires bot + handler |
| Cost | Included in hosting | Free via Bot API |
How the Integration with Bitrix Works
When an order status changes, Bitrix fires the OnSaleOrderStatusChange event. The standard notification mechanism (/bitrix/admin/posting_list.php) sends email. Telegram is connected as an additional channel via an event handler. For more details on events, see the official Bitrix documentation.
Which Order Statuses Are Supported?
| Status | Code | Notification Text |
|---|---|---|
| New order | N | Order #%d received and awaiting processing. |
| Sent for delivery | P | Order #%d sent for delivery. |
| Completed | F | Order #%d completed. Thank you for your purchase! |
| Canceled | X | Order #%d canceled. |
Creating an Order Status Change Handler
Creating a Telegram Bot for Notifications
The bot for order notifications is push-only: it only sends, not receives commands. Created via @BotFather:
/newbot Name: MyShop Notifications Username: myshop_orders_bot Get a token like 1234567890:AAHb-xxxxxx. Store the token in the module settings or in /bitrix/.settings.php, not in template code.
The user must start a dialog with the bot (/start) so the bot gets their chat_id. To do this, add a button in the personal account that opens the link https://t.me/myshop_orders_bot?start=uid_12345.
Saving the User's chat_id
// Webhook bot receives /start with parameter $update = json_decode(file_get_contents('php://input'), true); $text = $update['message']['text'] ?? ''; $chatId = $update['message']['chat']['id']; if (preg_match('/^\/start uid_(\d+)$/', $text, $matches)) { $userId = (int)$matches[1]; // Save chat_id to user field UF_TELEGRAM_CHAT_ID \Bitrix\Main\UserTable::update($userId, [ 'UF_TELEGRAM_CHAT_ID' => $chatId, ]); // Confirm to the user TelegramApi::sendMessage($chatId, 'Telegram order notifications have been connected.'); } Order Status Change Handler
// /local/php_interface/init.php \Bitrix\Main\EventManager::getInstance()->addEventHandler( 'sale', 'OnSaleOrderStatusChange', function (\Bitrix\Main\Event $event) { $order = $event->getParameter('ENTITY'); $statusId = $order->getField('STATUS_ID'); $userId = $order->getUserId(); // Read user's chat_id $user = \Bitrix\Main\UserTable::getById($userId)->fetch(); $chatId = $user['UF_TELEGRAM_CHAT_ID'] ?? null; if (!$chatId) { return; // User hasn't connected Telegram } // Build message based on status $messages = [ 'N' => 'Order #%d received and awaiting processing.', 'P' => 'Order #%d sent for delivery.', 'F' => 'Order #%d completed. Thank you for your purchase!', 'X' => 'Order #%d canceled.', ]; $template = $messages[$statusId] ?? null; if (!$template) { return; } $text = sprintf($template, $order->getId()); $text .= "\n\nDetails: " . SITE_SERVER_NAME . '/personal/orders/' . $order->getId() . '/'; // Send via Telegram Bot API TelegramBotService::send($chatId, $text); } ); Telegram Bot API Send Class
class TelegramBotService { private static string $token = '1234567890:AAHb-xxxxxx'; public static function send(string $chatId, string $text, array $options = []): bool { $params = array_merge([ 'chat_id' => $chatId, 'text' => $text, 'parse_mode' => 'HTML', ], $options); $ch = curl_init('https://api.telegram.org/bot' . self::$token . '/sendMessage'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($params), CURLOPT_HTTPHEADER => ['Content-Type: application/json'], CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 5, ]); $response = curl_exec($ch); curl_close($ch); return json_decode($response, true)['ok'] ?? false; } } Store the token not in code but in config:
// /bitrix/.settings.php 'custom' => [ 'value' => [ 'telegram_bot_token' => '1234567890:AAHb-xxxxxx', ], ], Error Handling for Sending
Add to the TelegramBotService class a check of the response and error logging. If curl returns an error or API returns `ok: false`, write the log to a file or to the Bitrix system log. This helps quickly diagnose problems.What's Included in the Work
- Creation and configuration of the Telegram bot via @BotFather
- Development of the connection page in the buyer's personal account
- Implementation of the event handler on
OnSaleOrderStatusChange - Saving
chat_idto the user fieldUF_TELEGRAM_CHAT_ID - Testing all order statuses (N, P, F, X and custom ones)
- Documentation for operation and further support
- Admin training on working with the bot
Timelines for Setup
Creating the bot, user field, connection page, event handler—6–10 hours. In complex cases (many statuses, non-standard logic) the timeline extends to 2–3 days. We guarantee stable notification operation after setup. Our team holds 1C-Bitrix certification and has over 10 years of development experience on this platform. During our work, we have implemented 50+ projects with Telegram notification integration. Get a consultation on setting up a Telegram bot for your store.
Typical Setup Mistakes
- Storing the token in a template file—the token should be in
/bitrix/.settings.phpor in module settings. - Missing check for
chat_idexistence—if the user hasn't connected the bot, the code should exit gracefully without errors. - Not all order statuses handled—for each status a message template must be provided, otherwise no notification will be sent.
- Ignoring order cancellation notifications—this status is often missed, but the customer needs to know about a cancellation.
How to Diagnose Delivery Problems?
If notifications don't arrive, check whether the user started a dialog with the bot (command /start). Ensure the token is active and chat_id is saved in UF_TELEGRAM_CHAT_ID. Review the handler log—possibly rate limiting by Telegram (30 msg/sec). In complex cases, enable step-by-step logging.
Order Telegram bot setup—get a consultation and project estimate within one day without prepayment. We integrate the bot with your CRM and 1C, ensuring stable notifications at all order stages.

