Developing a Calculator with Result Saving to Bitrix24 CRM
A website calculator that creates a lead or deal in Bitrix24 CRM upon calculation is a standard lead-generation task. Technically straightforward, but it breaks in one specific place: the Bitrix24 REST API has request rate limits (2 requests per second on cloud plans), and during traffic spikes some leads are silently lost with no error notification.
How the Site-to-CRM Integration Works
A 1C-Bitrix website and Bitrix24 are two separate products with separate APIs. To pass form data from the website to the CRM, the Bitrix24 REST API is used:
-
crm.lead.add— create a lead -
crm.deal.add— create a deal directly (when leads are not used) -
crm.contact.add+crm.deal.add— create a contact and link a deal to it
Authentication is via an incoming webhook (the simplest approach) or via an OAuth application (for production with multiple portals).
Example of creating a lead via the REST API:
$webhookUrl = 'https://your-portal.bitrix24.ru/rest/1/WEBHOOK_TOKEN/';
$fields = [
'TITLE' => 'Calculator enquiry: ' . $calculatorName,
'NAME' => $clientName,
'PHONE' => [['VALUE' => $clientPhone, 'VALUE_TYPE' => 'WORK']],
'EMAIL' => [['VALUE' => $clientEmail, 'VALUE_TYPE' => 'WORK']],
'COMMENTS' => $calcResultText,
'SOURCE_ID' => 'WEB',
'UF_CRM_CALCULATOR_PARAMS' => json_encode($calcParams), // custom field
'UF_CRM_TOTAL_PRICE' => $totalPrice,
];
$response = file_get_contents(
$webhookUrl . 'crm.lead.add.json?' . http_build_query(['fields' => $fields])
);
$result = json_decode($response, true);
Passing Calculator Parameters to CRM
Custom lead fields (UF_CRM_*) allow storing all calculation parameters: exactly what the user calculated, which values they selected, and the total amount. This is critical for managers: they open the lead and immediately see the configuration, not just an anonymous phone number.
Fields must be created in Bitrix24 in advance: CRM → Leads → Field Settings → Add Field. The type depends on the data: string, number, list. After creation the field name takes the form UF_CRM_1_XXXXXXXXXX (the number is the ID of the owning user).
Handling API Rate Limits and Errors
Cloud Bitrix24 limits incoming REST requests: 2 requests per second, 5,000 requests per day (depending on the plan). When exceeded, the response is {error: "QUERY_LIMIT_EXCEEDED"}. A typical implementation without rate-limit handling loses leads under peak load.
Correct implementation:
- Save calculator data to a queue table on the Bitrix side (
b_hl_*highload block or a dedicated table) - A Bitrix agent that every 30 seconds sends records from the queue to CRM in batches, respecting rate limits
- Retry on error (with exponential backoff — 1s, 2s, 4s, 8s)
- An
is_syncedflag in the queue table to track status
// Agent for sending leads to CRM
function sendPendingLeadsToCRM(): string {
$pendingLeads = getUnsentLeads(limit: 10); // from the queue table
foreach ($pendingLeads as $lead) {
$result = sendLeadToB24($lead);
if ($result['result']) {
markLeadAsSent($lead['id'], $result['result']); // store B24 ID
} else {
incrementRetryCount($lead['id']);
}
usleep(600000); // 0.6 s between requests
}
return __FUNCTION__ . '();';
}
Case Study: Loan Calculator on a Bank Website
Client — a non-banking financial organisation. Calculator: loan amount, term, collateral type. Result — preliminary rate and monthly payment. On submission — a lead in Bitrix24 with full parameter details.
Challenge: peak-hour load of up to 50 enquiries per minute from various advertising campaigns. Direct submission to the B24 API is impossible due to rate limits.
Solution: queue in PostgreSQL (the site runs on a non-standard stack), a sending agent every 15 seconds processing 5 leads at a time, logging of all B24 responses. In parallel — an immediate email to the client with calculation results (so they don't wait for CRM synchronisation). The manager sees the lead in B24 within 15 seconds of form submission at most.
Additionally: when a lead is created, the B24 business process "Initial Application Processing" is automatically triggered, assigning the lead to the credit product manager and setting a first-contact deadline of 30 minutes.
What Is Included in Development
- Calculator development (client-side and server-side)
- Creation of custom lead/deal fields in Bitrix24
- Development of the handler with queue and retry logic
- Incoming webhook configuration in Bitrix24
- Logging of all API requests and responses
- Monitoring: alert when the unprocessed queue exceeds N records
Development Timeline
A calculator with CRM integration takes 4 to 10 business days depending on the complexity of the calculation formula and data transmission requirements. Basic variant (simple formula, lead with 5–10 fields, no queue) — 2–3 days. With queue, retries, and monitoring — 5–8 days.







