Deals in the CRM system
Deals in the CRM are displayed as cards with information about the client, deal name, description and amount.

You can add other fields, if needed (see fig. 8-12).
"Create a deal" button

The Create a deal window lets you quickly set up and save a new deal.

Fill out the form to create a client. If the client exists, MaviBot will prompt you to select them from the database.

If the client isn’t found, connect a WhatsApp or email bot to the project.
Message the client through the connected channel — this will automatically create their profile.
Select the funnel stage where the deal should be placed.

Deal variables can be also added in the modal form:

Next, click "Create" to add the deal to the system.
The "Add quickly" button
This button can also help to manually add a new client to the CRM.

Click the button to open a window where you can enter the client's details.

Fig. 26 Quick deal creation window (Note: All data is fictional; any resemblance is purely coincidental.)
Thus, the deal will be created in the "Interested" stage.
Done!
Now you know how to create deals.
How to create a deal from the chatbot
Chatbot flow example for creating a deal via function
ПОСТАВИТЬ КАРТИНКУ ИТОГОВОЙ ВОРОНКИ
Process overview:
Create a Start block

Create two button blocks.

Go to the connection settings, enable the "User enters data" option, and specify the name of the service the user will input.

Then, add the question "What is your name?" in a white block. Create a new block below it and enable "User enters data" in its arrow settings.

The "User enters data" setting with the variable name is enabled in every connection leading to the "Enter your phone number" block.
Now, create two blocks — "Chat" and "Fallback" — from the "Enter your phone number" block.

Select the "RegEx math" type in the connection settings.
Enable the "User enters data" setting.
Enter the variable name:
phone.

Now, in the Fallback block, write the message: "This is incorrect! Try again."
This configuration will work as follows: if your client enters an incorrect phone number, they will receive the message from the Fallback block. The Fallback message will continue to be sent until the client enters a correct phone number.
Then, ask the client about their budget and immediately create a new block below it.

Enable the "User enters data" setting in the connection and enter the variable name:
budget.

Activate the "User enters data" checkbox on the connection and specify the phone variable client_name.
You can either change the type of the last block to "Leads" or use the
create_orderfunction.Here is the option with the red "Leads" block.

Example.

The function create_order(name, budget, description, client_name, phone, email, state_id) is used to create a deal from the chatbot in the CRM.
In the flow, we have collected the following data in stages:
Name - deal name (in the example, I need a website & I need a landing);
Budget — deal cost, which was announced in blocks after the client selected the type of website;
Phone — the client's phone number
Client_name — the client's name
If you need to create a deal in a specific transaction state, pass the state_id parameter.
Where to find the state id (state_id parameter)

Stage ID:

Other settings
The search bar is a search for a deal by the client's name.

Filter: allows you to filter deals with various parameters. You can also save the created filter if you use it frequently.

How to trigger a bot when a deal moves to a new funnel stage
To trigger a bot upon a deal's stage change in the CRM funnel:
Go to the project settings.
Open the "Callbacks" section.

Click on "CRM stage transition callback settings":

After that, you’ll see a modal window with all the funnels in the project. You can choose either the entire funnel or a specific stage.

Then save the settings.
Now, when the deal state changes—either automatically or manually—a notification is generated from anywhere on the site, which can be used to trigger a bot response.
The callback_query_id variable will also appear in the client’s card, storing the identifier of the deal for which the notification was sent.

To trigger your bot in response to this event, enter the callback text into the trigger field of a connection or a trigger-based block (such as a Start or Trigger block).

How to move a deal
To move a deal to any funnel stage, simply click and drag it with the left mouse button to the desired stage.

When a deal is moved to "Failed" or "Archived," a modal window appears prompting you to specify the reason. This action creates a corresponding deal variable: failed_reason or archived_reason.
The reason provided is saved to the respective variable. If the deal is later restored, the variable restored_from_failed or restored_from_archived is added with the value "true".
How to prevent moving a deal to the specified stage
If you need to restrict the stages to which deals can be moved manually, configure the restriction in the state settings.
Open the funnel and go to the stage settings.

Use the stage settings to restrict deal movement to specific stages. Select the desired stages in the checklist (multiple selections allowed) and save the changes.

After saving, the restricted stages will be visually highlighted in MaviBot CRM. They will appear darker, and moving deals to them will be disabled. If stage movement restrictions are applied, those stages will also be hidden in the client chat interface.
Reaction to deal deletion in CRM
When a deal is deleted in the CRM, the bot receives a callback named crm_lead_removed to notify the client.

How to switch deals
When actions are performed on deals directly within the CRM page, the following callbacks are triggered:
change_responsible_order— the deal's assigned manager has changed.crm_state_changed— the deal was moved to a different funnel stage.crm_system_state_changed— the deal was moved to Lost, Won, or Archived.crm_lead_removed— the deal was deleted.
Additionally, the client variables will include callback_order_id, which contains the ID of the specific deal affected by the CRM action.
When processing one of these callbacks, the corresponding deal becomes temporarily active within the processing block, allowing you to access its variables directly.
Once the flow moves to the next block, MaviBot's standard logic resumes — any subsequent access to deal variables will return values from the client's most recent active deal.
How to switch a deal to an active stage in the bot
The switch_order(order_id) function allows you to make a specific deal active in order to access its variables.
order_id— an optional parameter for the specific deal ID. If omitted, the client's most recent deal becomes active.To activate a particular deal, pass its ID to the
switch_order(order_id)function.If you call this function within a calculator block and provide a target deal ID, you will be able to access that deal's variables in all following blocks.

If the switch_order function is called with the ID of a deleted or non-existent deal, no switch will occur. In this case, the function will return the ID of the deal currently active for the client (or None if the client has no active deal).
You can therefore verify whether the switch was successful by comparing the order_id passed to the function with the value it returns:
switch_result = switch_order(order_id)
result = if(switch_result == order_id, value_if_true, value_if_false)

If no argument is passed to the switch_order() function, it will activate the client's most recent deal. This allows you to revert or reset the active deal — for example, after performing operations with another deal, or when you do not need to keep a deal temporarily activated by a CRM callback.
Last updated