Ai-assistant with MaviBot table

Using a function developed by Mavibot team, the AI chatbot perfectly understands the values entered into the sheet, and then writes them to a system variable in the project settings.

For example, you may need this for an AI assistant who will advise your clients on the available range of products in your online store, as well as to advertise your capabilities with a smart bot.

Exactly how to use a bot to read a Google-sheets is up to you, and we, in turn, will show you how to create a sheet and configure the bot to work with it.

Getting ready a table

To get started, go to the sheets section:

Next, you will see the "Add sheet" button, which opens a modal window in which you need to enter the name of the sheet:

Enter the name for the sheet and click on the "Done" button. Then a new sheet will be created in the project and will appear in the "Sheets" section:

Sheet settings

After creating the sheet, you need to add rows and columns. To do this, find the "Go to" button on the card of the desired sheet and click on it.

You see next settings:

To add column with a name, click "Plus":

when you click on the button, a modal window will appear in which you need to enter a name for added column:

Afte entering the column name, click on the "Done" button, then the new column will be added to the sheet. Add the required number of columns and then rows:

Now, you sheet looks like this:

Copy (remember) the sheet ID: to do this, click on the address bar:

Next, let's go to configuring the blocks in the builder.

Working in the funnel constructor

Function get_records_from_table()

To use the get_info_from_table() function, you need one block in the funnel constructor.

Go to the appropriate tab in Mavibot and create a block with a condition (starting condition or non-state with a condition):

Define a variable (it will be used for the AI assistant's knowledge): in this example, the variable is 'online_shop'.

Example of code from the calculator

project.online_shop = get_records_from_table(5)

  1. project. - is a constructor for setting a variable in the project configuration;

  2. online_shop - name variable;

  3. get_records_from_table(5) - function, where the parameter is passed as table ID.

Подробнее о функции

get_records_from_table(table_id, start_row, count, start_col, end_col) - получение записи из таблицы

Параметр
Описание
Примечание

! table_id

id таблицы (обязательный параметр)

start_row

необязательный параметр, целое число. Указывает начало диапазона строк.

Передается номер строки, с которой включительно необходимо прочесть значения таблицы. Указывается без кавычек.

count

необязательный параметр, целое число. Указывает количество строк, которое нужно получить

По умолчанию - 1000, максимум - 5000. Указывается без кавычек.

start_col

необязательный параметр, строка. Указывает начало диапазона столбцов

Передается название колонки, с которой включительно необходимо прочесть значения таблицы. Указывается в кавычках

end_col

необязательный параметр, строка. Указывает конец диапазона столбцов

Передается название колонки, до которой включительно необходимо прочесть значения таблицы. Указывается в кавычках.

Если указать только начало диапазона строк/столбцов, то будут получены все данные от указанного значения без ограничения по концу диапазона. Аналогично можно не указывать начало диапазона, указав только конец.

Instead of #{none}, we will write our variable in the message using the #{} construct to visually see what data has been written to the project variable.

The variable name can be any name that you like.

Data trasnfer block

Next, we will create "Status" block for transferring data to the client's card.

"This block can also transmit a closing message from the bot, such as: 'Thank you for your order! Your data has been forwarded to the manager.'"

Next, copy the block ID. You will need it to configure the AI assistant in the command "calling block 31241050", where instead of the block ID from the example, you need to insert your block ID.

Reading the table

Now go to the bot testing and launch the block with the condition:

Thus, the block worked correctly: you can see the values that are in the variable in the project settings.

You can verify this by going to the appropriate section:

In the "Variables" tab in the project settings, you will see your variable with the values added in it from the table. So now, inside your project, there is a variable with goods, cost, and everything that you specified in the table.

Working in AI-assistant

Go to the "AI assistant" section and start chatbot with AI settings.

"AI Assistant Role: Sales Representative"

We will also set additional settings:

AI-assistant settings

In the bot settings we write the following data:

  1. The position and instructions for the bot.

  1. The command to call the block and transfer variables to the system is written as follows:

<If the customer wrote "The order is correct" or "Correct", then write "start_block_from_ai N">, where instead of N the block ID is written with the final message: the Status block transmits data to the customer's card:

Bot Knowledge

In the "Bot Knowledge" field, pass the variable that was previously cached as a block with the condition:

Bot knowledge:

This way, the bot will take information from a variable in the project settings and advise your clients on the available product range.

Data format

In the format of the transmitted data, you specify the data you are collecting yourself (for example, a product), then enter the phrase with the "key" and assign a value to the key:

This way, when calling the block, variables will be passed to the client's card: then you can work with variables, for example, in the constructor:

"Since we declared the variable payment_sum in the data format, you will be able to generate a payment link directly in the bot when payment services are connected.

At this stage, the AI assistant setup is complete.

The remaining parameters can be set at your discretion:

Testing a bot

"If you already have bots running, specify in the AI assistant's launch condition to start only in the testing window."

Step 1. Click on the condition constructor

Step 2. Select the tab with the test window and click "Add":

Now, in the launch condition, you will see the following value:

This way, the bot will run only in the test window and nowhere else.

After debugging the bot, remove this condition.

In the example, we will test it directly in the messenger:

Дополнительно

В схеме мы создали блоки для формирования ссылки на оплату и реакции на колбек об успешной оплате.

АИ-ассистент вызывает блок для формирования ссылки на оплату, затем отправляется блок с кнопкой:

Далее после успешной оплаты приходит колбек в диалоге с клиентом (колбек пользователь не видит):

Обратите внимание, что на примере выше, видно, где отработал AI, а где бот из конструктора.

  1. Серые сообщения — сообщения AI-ассистента;

  2. Синие — сообщения из блоков в конструкторе.

На данный колбек настроена реакция в блоке с условием:

This message is being sent in test mode due to the command "calling block 31241050"

After testing and debugging the bot, write the command in the settings of the bot "start_block_from_ai 31241050".

Last updated