Bot automator for site requests in 1C-Bitrix: development and integration

A request is submitted on the site — and then silence. The manager might notice it in an hour, a day, or not at all. According to statistics, 70% of clients don't wait for a response if it doesn't come within 5 minutes. We solve this with a bot handler: it instantly records the request in Bitrix24,

Our competencies:

Frequently Asked Questions

A request is submitted on the site — and then silence. The manager might notice it in an hour, a day, or not at all. According to statistics, 70% of clients don't wait for a response if it doesn't come within 5 minutes. We solve this with a bot handler: it instantly records the request in Bitrix24, notifies the relevant employee, sends an auto-reply to the client, and, if necessary, starts a dialog in the messenger. This approach accelerates response time from hours to seconds and reduces the risk of losing a client by 90%.

The bot processes a request in seconds — 20+ times faster than manual processing, as confirmed by implementation practice.

The bot works with any forms on the site: Bitrix web forms, custom AJAX forms, callbacks. It integrates through standard events and REST API, without requiring replacement of existing components. Implementation time — from 1.5 weeks, results are visible immediately. Below is how we build such a system: from event interception to duplicate handling and auto-reply.

How to intercept form events in Bitrix?

Any form on a Bitrix site — CWebForm, web forms of the form module, callbacks from sale.order.ajax, custom AJAX forms — generates an event on submission. We intercept the necessary events through standard handlers, for example, OnAfterResultAdd:

// local/php_interface/init.php AddEventHandler('form', 'OnAfterResultAdd', 'handleFormSubmit'); function handleFormSubmit(int $webFormId, int $resultId, array $arResult): void { if (!in_array($webFormId, [1, 3, 7])) { // IDs of required forms return; } BotQueue::push('process_form', [ 'form_id' => $webFormId, 'result_id' => $resultId, 'fields' => $arResult, ]); } 

For bitrix:main.feedback we use a handler in the component template, for sale.order.callback — the OnSaleOrderCallbackCreate event.

Creating a lead, notifying the manager, and auto-reply

After receiving the data, we create an entity in CRM. Selection logic: qualified request (has phone, clear need) → immediate deal; initial inquiry → lead.

$leadId = $b24Rest->callMethod('crm.lead.add', [ 'fields' => [ 'TITLE' => "Request from site: {$formName}", 'NAME' => $arResult['NAME'] ?? '', 'LAST_NAME' => $arResult['LAST_NAME'] ?? '', 'PHONE' => [['VALUE' => $arResult['PHONE'], 'VALUE_TYPE' => 'WORK']], 'EMAIL' => [['VALUE' => $arResult['EMAIL'], 'VALUE_TYPE' => 'WORK']], 'SOURCE_ID' => 'WEB', 'SOURCE_DESCRIPTION' => $formName, 'COMMENTS' => $arResult['COMMENT'] ?? '', 'ASSIGNED_BY_ID' => getResponsibleManager($webFormId), 'UTM_SOURCE' => $_COOKIE['utm_source'] ?? '', 'UTM_MEDIUM' => $_COOKIE['utm_medium'] ?? '', 'UTM_CAMPAIGN' => $_COOKIE['utm_campaign'] ?? '', ], ])['result']; 

UTM tags from cookies are a mandatory element for source analytics. After creating the lead, the bot sends a message to the responsible person in the Bitrix24 im-bot with action buttons:

$b24Rest->callMethod('imbot.message.add', [ 'BOT_ID' => $botId, 'DIALOG_ID' => 'u' . $managerId, 'MESSAGE' => "[b]New request from site[/b]", 'ATTACH' => [[ 'TITLE' => $formName, 'DESCRIPTION' => "Client: {$name}\nPhone: {$phone}\nComment: {$comment}", 'COLOR' => '#2fc6f6', 'LINK' => "https://b24.company.ru/crm/lead/show/{$leadId}/", ]], 'KEYBOARD' => ['BUTTONS' => [[ ['TEXT' => 'Open lead', 'LINK' => "https://b24.company.ru/crm/lead/show/{$leadId}/"], ['TEXT' => 'Take to work', 'COMMAND' => 'assign_lead', 'COMMAND_PARAMS' => $leadId], ]]], ]); 

The client receives a confirmation by email and/or SMS:

\Bitrix\Main\Mail\Event::sendImmediate([ 'EVENT_NAME' => 'FORM_SUBMIT_CONFIRM', 'LID' => SITE_ID, 'C_FIELDS' => [ 'CLIENT_NAME' => $name, 'CLIENT_EMAIL' => $email, 'FORM_NAME' => $formName, ], 'TO_EMAIL' => $email, ]); 

If the client has Telegram (determined via telephony.externalcall.searchcrm), the bot can also write there through Open Lines.

Why use a queue for request processing?

Under high traffic, synchronous processing can slow down server response. We implement a queue based on Redis: the form event puts a task into the queue in milliseconds, and a worker (PHP daemon or cron) processes it asynchronously. When the Bitrix24 REST API is unavailable, the task stays in the queue until the next attempt — this guarantees request delivery even during failures. Our queue handles up to 1000 tasks per second with no loss.

How does the bot avoid duplicates and route requests?

Before creating a new lead, the script searches by phone using the crm.duplicate.find method. If an open lead is found — the bot does not create a new one, but adds an activity with the text "Repeat request" and a link to the form result. This prevents duplicates and confusion in the sales funnel. Different forms are assigned different responsible persons:

function getResponsibleManager(int $formId): int { return [1 => 15, 3 => 22, 7 => 8][$formId] ?? 1; } 

On a repeat request with the same phone, the bot does not create a new lead but adds an activity to the existing one — this prevents duplicates and confusion.

What if the REST API is unavailable?

The Redis queue saves the day: the task remains in the queue and retries on the next worker run (every 1–3 seconds). If the API does not respond for more than 5 minutes, the bot sends an email notification to the administrator. This guarantees that no request is lost, even during temporary outages.

Comparison: bot vs manual processing

Parameter Manual processing Bot handler
Time from request to lead Hours Seconds
Risk of losing request High Minimal
UTM analytics Manual Automatic
Duplicate handling Manual Automatic
Client notification Manual Automatic

The bot processes a request 10+ times faster than a human — verified on dozens of projects.

What is included in the work

  • Analysis of current site forms and selection of interception method
  • Writing event handlers considering tagged caching in Bitrix
  • Configuring request routing by type, region, or load
  • Integration with Bitrix24 REST API for creating leads/deals
  • Developing an im-bot with buttons for managers
  • Setting up auto-reply by email/SMS
  • Implementing a queue for reliable processing under peak loads
  • Testing in 3 scenarios: single request, duplicates, API failure
  • Delivering documentation on access rights and logic
More about test scenariosWe check the bot's operation on single requests, on repeated submission with the same phone, and during simulation of REST API failure (e.g., disabling the webhook). In each case, we record correct behavior: lead creation, notification, auto-reply, no duplicates.

Timeline and cost

Stage Timeline
Intercepting Bitrix form events 1–2 days
Creating leads in B24, routing 2–3 days
Notifications via bot, action buttons 2–3 days
Auto-reply to client (email/SMS) 1–2 days
Duplicate handling, repeat requests 1–2 days
Queue + testing 1–2 days

Total: 1.5–2 weeks for a standard set of forms. Cost is calculated individually — contact us to evaluate your project. Get a transparent estimate and quality guarantee after implementation. We help automate request processing turnkey — order development right now.