When a lead moves to the bot stage, the bot will automatically fill in the field based on the calculation results.
Setting up a bot in a pipeline:
Select the stage where the bot will work and click + Add trigger.
In the list, select Salesbot → configure the conditions → click + Add new bot.
In the bot settings, go to the Widgets section → select Formula.
Click on the pencil icon.
Select the field in which the result will be written.
Enter the formula. Example: lead['Product price'] - lead['Product cost']
Add multiple formulas if necessary → repeat steps.
If necessary, add the following steps and terminate the bot. Next, save the bot and pipeline settings.
Realtime formulas
Realtime formulas are configured in the general settings of the “Formulas” widget (not in Salesbot).
Open the general settings of the Formulas widget.
Click on Add.
Enter/select the field where to record the result.
Enter the formula.
Save your settings.
How it works at the front:
After opening a lead card, the formulas are executed automatically.
When you change field values in a card, the formulas are recalculated automatically.
The result is immediately recorded in the selected fields in the same card.
The recalculation is performed with a slight delay to avoid unnecessary recalculations when entering.
⚡Realtime formulas are suitable for online calculations in the lead card: margin, discounts, bonuses, cost, planned profit and other derived indicators.
Mathematical operations
You can use any mathematical operations in formulas:
addition (+)
subtraction (-)
multiplication (*)
division (/)
The formula is not limited to two variables. You can use any number of fields and values necessary to calculate the result.
Constant values
If you need to use a constant value in formulas, you can set it using a trigger:
Go to formula bot.
Click Set Variables.
3. Create a new variable, specifying:
Name (Latin letters only).
Value (number or text).
Important when working with variables:
If the variable is not a number, convert it to a numeric type:
chislo(lead['Название поля с типом текст'])
If the variable is not text, convert it to a text type:
text(lead['Название поля с типом число'])
This is necessary for the formulas to work correctly and to prevent errors in calculations.
After this, the variable can be used in formulas along with Kommo fields.
Hints in formulas
In the formula input field, tooltips are available with the names of fields that can be used in calculations.
To display a tooltip, enter the symbol "[". After this, a drop-down list of available fields will appear.
Correct work with numbers
Sometimes Kommo treats values as text, which results in a “glue” instead of addition (for example: 10+14+5 = 10145).
To avoid this, each value must be wrapped in parseInt().
Example:
parseInt(lead['Сумма в договоре']) - parseInt(lead['Бюджет'])
Logical conditions
Creating logical conditions (if-else in one line)
Example:
lead['поле1'] == 'успех' ? 'да' : 'нет'
Here:
if field1 = "success" → result "yes"
otherwise → result "no"
Various comparison operators are supported:
>= - greater than or equal to
<= - less than or equal
> - more
< - less
!== - not equal
Example with conditions:
lead['Расстояние до заказчика (в км)'] <= '50' ? '300р.' : '250р.'
You can check field values and return different results.
Nested conditions
This example shows a nested condition (ternary operator) - when another condition is used inside one condition.
🔹 Analysis of the formula:
lead['Расстояние до заказчика (в км)'] <= '10' ? '300р.' : (lead['Расстояние до заказчика (в км)'] <= '30' ? '1000' : '2000')
The condition is checked: if the distance is ≤ 10 km → the result is “300 rub.”
If the first condition is not met, the second is checked: if the distance is ≤ 30 km → result “1000”.
If both conditions are not met: default result → “2000”.
Essentially, this is an analogue of “if - otherwise if - otherwise”:
Up to 10 km → 300 rub.
From 11 to 30 km → 1000
More than 30 km → 2000
Limitation of decimal places
Sometimes the result of calculations may be a number with a large number of decimal places. To limit their number, use the .toFixed(x) function, where:
x is the number of decimal places that should remain.
Example:
(lead['Сумма'] / lead['Количество']).toFixed(2)
If sum = 105, quantity = 7, then the result will be 15.00 (2 decimal places).
Field keys
Leads (lead):
lead['ID'] — lead ID
lead['Title'] — Lead name
lead['Budget'] — Budget
lead['status_id'] — status ID
lead['pipeline_id'] — pipeline ID
lead['status_name'] — Status name
lead['pipeline_name'] — Pipeline name
lead['Responsible'] - full name of the responsible person
lead['Field'] — Additional lead field
Contact:
contact['ID'] — Contact ID
contact['Name'] — contact name
contact['Name'] — Name
contact['Last Name'] — Last name
contact['Responsible'] - full name of the responsible person
contact['Field'] — Additional contact field
Company:
company['ID'] — company ID
company['Name'] — Company name
company['Responsible'] - full name of the responsible person
company['Field'] — Additional company field
Last invoice:
last_invoice['Status'] — Status
last_invoice['Legal. face'] - Jur. face
last_invoice['Payer'] — Payer
last_invoice['VAT type'] — VAT type
last_invoice['Payment date'] — Payment date
last_invoice['Invoice items'] — Invoice items
last_invoice['Invoice items']?.length — Number of items
ℹ️If you need to count by company, replace lead['contact_leads'] with lead['company_leads']. In the example with status 123123, specify the ID of the desired status from your pipeline.
Notes
The variables available in formulas are lead['notes'] (an array of all lead notes) and lead['last_note_text'] (the text of the last note).
The widget provides functions for automatically linking contacts and companies to leads:
Linking contacts
Attach contact by Phone - search for a contact by phone number
Attach contact by email - search for a contact by email address
Attach a contact by custom field - search for a contact by any custom field (for example, TIN, internal ID, etc.)
Linking companies
Attach a company by custom field - search for a company by any custom field (for example, TIN, internal ID, etc.)
Using these functions, you can automatically find and attach contacts/companies to leads, or create new ones if they are not found. You can set this up using Salesbot.
Setting up binding by phone or email
In the field selection, find the Functions section:
In the formula you need to enter a field from which you need to take phone or email to create a contact:
Setting up binding using a custom field
To link a contact or company using a custom field, select the desired field from the list of available fields in the widget interface.
Example 1: Link a contact using the TIN field:
Select "Options" → "Attach a contact using a custom field" → select the "TIN" field from the list
In the formula, indicate the lead field from which to take the TIN value: return lead["TIN"]
Example 2: Link a company using the "Internal ID" field:
Select "Options" → "Attach company by custom field" → select the "Internal ID" field from the list
In the formula, indicate the lead field where to get the ID from: return lead["Internal ID"]
If a contact or company with the specified field value is not found, the system will automatically create a new entity with this value and link it to the lead.
Currency conversion
The convertCurrency() function is available in formulas for automatic currency conversion at official rates of the Central Bank of the Russian Federation.
Function format:await convertCurrency(amount, "source_currency", "target_currency")
Supported currencies (54 currencies)
Major world currencies:
USD - US dollar
EUR - Euro
GBP - Pound sterling
CHF – Swiss franc
CNY - Chinese Yuan
JPY - Japanese yen
RUB - Russian ruble
Popular currencies: AUD (Australian Dollar), CAD (Canadian Dollar), NZD (New Zealand Dollar), HKD (Hong Kong Dollar), SGD (Singapore Dollar), TRY (Turkish Lira), INR (Indian Rupee), BRL (Brazilian Real), ZAR (South African Rand), KRW (South Korean Won)