Developing a notification bot for Bitrix24

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1173
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    745
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Development of Notification Bot for Bitrix24

A notification bot is a service agent in Bitrix24 that writes to employees in private chat when events occur: new lead, overdue task, order payment, server alert. Unlike standard B24 email notifications, the bot works in real time, reaches the Bitrix24 mobile app, and supports quick action buttons.

Bot Registration

The bot is registered via REST API with a single imbot.register call:

POST /rest/imbot.register
{
  "NAME": "Notifications",
  "CODE": "notify_bot",
  "TYPE": "S",  // S = System, not shown in contacts
  "COLOR": "GREEN",
  "PROPERTIES": {
    "OPENLINE": "N"
  }
}

After registration, Bitrix24 returns BOT_ID. This identifier is used to send messages on behalf of the bot.

Sending Notifications

A message to a user is sent via im.message.add or imbot.message.add. The difference: im.message.add creates a dialog on behalf of the OAuth application user; imbot.message.add — on behalf of a registered bot. For a notification bot, we use the second option.

$b24->callMethod('imbot.message.add', [
    'BOT_ID'    => $botId,
    'DIALOG_ID' => 'u' . $userId, // private chat with user
    'MESSAGE'   => '[b]New lead:[/b] ' . $leadTitle,
    'ATTACH'    => [
        [
            'TITLE'       => $leadTitle,
            'DESCRIPTION' => "Phone: {$phone}\nSource: {$source}",
            'COLOR'       => '#ff6600',
            'LINK'        => $crmUrl,
        ],
    ],
    'KEYBOARD'  => [
        'BUTTONS' => [[
            ['TEXT' => 'Open in CRM', 'LINK' => $crmUrl, 'BG_COLOR' => '#2fc6f6'],
            ['TEXT' => 'Take into work', 'COMMAND' => 'take_lead', 'COMMAND_PARAMS' => $leadId],
        ]],
    ],
]);

ATTACH — card formatting block. KEYBOARD — buttons under the message. When clicking a button with COMMAND, Bitrix24 sends an ONIMBOTMESSAGEADD event with the command type — the bot handles it as an action.

Event Sources for Notifications

CRM events. Register a handler on onCrmLeadAdd, onCrmDealUpdate via event.bind:

POST /rest/event.bind
{
  "event": "ONCRMDEALUPDATE",
  "handler": "https://your-server.com/webhook/deal-update"
}

When a deal moves to "Won" stage — bot writes congratulations to the manager and manager's supervisor with amount and link.

Tasks. Event onTaskUpdate — on status change, deadline change, assignee change. Bot notifies the right employee.

External systems. Monitoring (Zabbix, Prometheus Alertmanager) sends POST to server bot webhook-endpoint → bot writes to on-call engineer in chat. Similarly — payment systems, 1C, third-party CRM.

Schedule. Cron on bot server runs a script once an hour — checks overdue tasks via tasks.task.list, deals without activity for N+ days via crm.deal.list, and sends a summary to those responsible.

Typical Notification Scenarios

Event Recipient Message Content
New lead from website Responsible manager Name, phone, source, "Take into work" button
Deal stage change Manager + supervisor Deal, old and new stage, amount
Task overdue Executor + assigner Task, deadline date, days overdue
New task comment All task participants Author, text fragment, link
Server error On-call engineer Error type, time, server, stack
Successful order payment Order processing department Order number, amount, customer

Group Notifications

Bot can write to group chats. DIALOG_ID in this case is the chat ID (chatXXX). To create a service chat for a project or department, use im.chat.add, bot is added as a participant via im.chat.user.add.

Queue and Reliability

If there are multiple event sources and many notifications — add a queue (Redis, RabbitMQ). The webhook handler immediately accepts the event and puts it in the queue (response 200 in < 1 second). Worker pulls from queue and sends to Bitrix24. This prevents message loss if REST API is temporarily unavailable.

Timeline

Task Duration
Bot registration, basic message sending 1–2 days
Connect 1–3 event sources (CRM, tasks) 2–3 days
Quick action buttons + command handling 2–3 days
Queue for reliable delivery 1–2 days
Testing all scenarios 1–2 days

Total: 1–2 weeks depending on number of scenarios and event sources.