A simple chatbot
In this article, we'll explain and show you how to create a simple chatbot for your project step by step.
Creating a chatbot on Mavibot platform is quite simple if you have completed the “Basics of Mavibot bot building” section, which explains the basics of working with the funnel constructor (editor), with types of blocks and arrows, with types of attachments, buttons, as well as a calculator, etc.
Before you start creating a simple chatbot, we strongly recommend you to study the “Mavibot Bot Building Basics" section! ссылка “Основы ботостроения Salebot”!
How to create a block
To create the first block in the funnel, double-click on the editor field with the left mouse button:

As you can see in the example above, the block can be moved throughout the field editor by selecting any convenient location.
You can also create a block by simply clicking on "Save" at the bottom of the screen and selecting its type:

You can select the following block types to start the chatbot: "Start a dialog" or "Primary condition check":

We know from the article "Creating blocks and their types" ссылка Создание блоков и их типы" that the "Primary Condition verification" block type has the highest priority: like the "Dialog Start" block type, the block diagram chain of your chatbot can be started from it
Technically, the main difference is that if there is a block with the "Primary condition verification" type in the chatbot scheme and if the user enters a keyword (phrase) of this block during the dialogue, the conversation with the client will continue from this block. This allows you to provide additional flexibility in the structure of the dialogue, and the client can immediately get what they need (for example, to conclude a deal with you or register for your course).
In the block conditions, you need to specify a keyword (for example, the Tag of a mini landing page/website or another phrase necessary for the bot to work, "Hi; hello, separated by a semicolon), to which the bot will respond:

As can be seen in the example above (Pic. 2), in the block condition, we specified the tag of the mini landing page created on the Mavibot platform from which the subscription will take place, and in the "Match selection" field, we selected the "full match" type.
If necessary, you can specify keywords of a different type in the condition (for example, "Hi, Hello", etc.). In this case, select the matching type "Ignoring errors and inaccuracies", which will help the bot recognize keywords in your clients' messages written with typos or errors:

How to create the following block in the diagram and specify the arrow conditions
Pull the arrow from the first block downwards. In this way, the designer automatically creates a new block and uses the arrow to connect the blocks into one scheme, which will allow the client to move further along the funnel:

In the arrow settings, we will specify such conditions so that the chatbot collects the data entered by the user and saves it to the variable we need.
To do this, go to the arrow settings, where you need to activate the "User enters data" switch, and also specify the variable to which the chatbot will save the client's data:

After the user sends his name in the message, the bot will write it to the required variable:

In the second block of the diagram, we will write a message that will request the age of your client. To do this, use regular expressions. ссылкарегулярными выражениями.
Regular expressions that are used in this article:
mobile number -> ^((\+7|7|8)+([0-9]){10})$
email -> ^[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,4}$
entering numbers (for age) -> ^[1-9]+[0-9]*$
See the full list of regular expressions here. ссылка здесь.
In the message field of the second block of the Chatbot diagram, write down the necessary question: for example, "How old are you?":

Then follow these steps:
Step 1. Pull the arrow from the second block to create the next block diagram in the same way as the previous one was created.
Step 2. In the arrow settings in the condition, write a regular expression like ^[1-9]+[0-9]*$ and select the match type "Regular Expression"

Remember, the matching choice during using regular expressions need to be "Regular Expression", otherwise the chatbot scheme will work with errors!
Step 3. In the arrow settings, activate the "User enters data" switch and enter the name of the variable where the chatbot will save the client's data:

The example (Pic. 8) shows that the chatbot writes the client's data to his card:

Customer data collection unit: phone number/email
During the dialogue with clients, there is often a need for subsequent communication with the client by phone, but the question arises: how can I set up a chatbot to automatically collect information about the client? Using regular expressions, of course.
To use the phone number (or email) collection feature, use the following regular expressions:
Mobile number (Russia): ^((\+7|7|8)+([0-9]){10})$
Mobile number (with any country code): ^(\+)?((\d{2,3}) ?\d|\d)(([ -]?\d)|( ?(\d{2,3}) ?)){5,12}\d$
Email: ^[-\w.]+@([A-z0-9][-A-z0-9]+\.)+[A-z]{2,4}$
Make sure that there is no space before the regular expression in the arrow condition!

Otherwise, the chatbot scheme will work with errors.
In the scheme, we used a regular expression for phone numbers of any country.
Just as the bot recorded the client's name and age, the user's phone number (or email address, if the appropriate regular expression is selected) will be added to the system.
Create a block where you will use the bot to send a message to the client asking them to send a phone number (or email) to the user:

Next, pull the arrow out of this block, where the corresponding regular expression need to be written in the arrow condition.

As noted earlier, do not forget to set the matching option to "Regular expression" in order to avoid errors in the chatbot.
With the condition where regular expressions are prescribed, the chatbot will accept only the values of the mobile number in the form of numbers, and in the case of a postal address, only the established standardized types of postal addresses.
If the client has sent a message that does not match the value of the phone number (email), you can create a block that will inform the client about the incorrectly entered data:

To do this, from the block where you entered the message for the client's phone number, swipe the second arrow and write the necessary message in the created block, for example, "This is not a phone number. Please enter the phone number!":

Select the "Out of condition" block type (Pic. 11). This block does not have a condition like in the "Dialog Status" block, but you cannot go to it.
In relation to our scheme, the "Not state" block will be very useful, because then the user will not switch from the last block, and to proceed further through the funnel, he will need to enter a phone number:

You can find out about the various functions of the "Not state" block in the article of the same name. ссылка "Не состояние"
Blocks of the bot's next dialogue with the client
Let's start setting up blocks with buttons, during clicking by the client, the chatbot will respond in accordance with the conditions of the button (for example, consent to payment; direct payment or redirection to another third-party site, etc. functions).
To do this, from the block marked in red in Pic. 12, pull the arrow below, where you can set the timer in the settings:

To set the timer, go to the arrow settings and set the required time interval, after which the chatbot will send a message to the client:

In the next block, add the "Call me back today" and "Call me back tomorrow" buttons.
Read more about button settings in the chatbot scheme in this "article". ссылка статье.
To learn how to connect and configure payment systems in order to do payments in buttons (links) in the bot, see the section "Integrations" -> "Payment systems". ссылка Платежные системы".
How to add buttons
To add buttons that the chatbot will send to the client, click on the "Buttons" inside the block settings:

Next, click on the "Add button".

Next, a window will open for adding a button, where you need to specify the name of the button and configure it according to your requirements:

Now this block will direct the buttons to your client, which will allow you to later identify the time (in relation to the scheme made in this article) when it would be better to contact him:

The dialogue with the client will be displayed in the Clients tab, where you can track all changes in the dialogues with clients:

After the client clicks on a certain button, a corresponding message will be sent to the dialog in the "Clients" tab: for example, "call me back today":

End of dialogue with the client blocks
After adding the buttons, it is necessary to end the dialogue with the client in some way so as not to leave him in the dark after he clicks on the corresponding button.
Let's create two blocks with arrows coming from the block with the buttons for this:

Now we will write the name of each button in the conditions of each arrow:

In the conditions of the created blocks, write down the necessary messages that the chatbot will send when the client clicks the button:

Now the chatbot will notify the client that his request has been accepted.

In the "Clients" section, you can see the client's response and call them back at a convenient time, as well as continue the dialogue if necessary or clarify details.
To check the data that the client sent you, go to the "Clients" tab:

The final scheme of the chatbot looks like this:

Thus, we have created a simple chatbot consisting of only eight blocks, which receives information about the client and records them in variables in the form of name, age and phone number, as well as when it is better for your manager to contact the user.
Last updated