# How to create two or more AI assistants in one chat

To enable combined assistant operation, we will need a funnel builder and three AI assistants. The blocks in the builder will be used to set variables, which will then be referenced in the assistants' conditions, while the assistants themselves will act as client consultants.

We will create three assistants with the following roles:

1. **Distributor Assistant**
2. **Sales Manager Assistant**
3. **Accountant Assistant**

### Working in the builder

We will need three blocks in the chatbot builder — all blocks must be set as "**Fallback**."

The role of the Fallback blocks is as follows:

1. They contain variables that will be assigned to the client with a value of 1 or 0;
2. One of the blocks will trigger the distributor assistant;
3. They reset variables for further switching from one assistant to another.

In the first block, we assign variables in the calculator with a value of 0:

<div data-with-frame="true"><figure><img src="/files/4nJu0G1pqxARTndYAeG4" alt=""><figcaption></figcaption></figure></div>

Also, specify the required message in the block.\
In the second block, which will be triggered by the assistant on command, set the variable values: `bookkeeper = 0`, `sales_assistant = 1`.

<div data-with-frame="true"><figure><img src="/files/Uk8WgmpIoIEgfAU93O4K" alt=""><figcaption></figcaption></figure></div>

In the third block, set the variable values: `bookkeper = 1`, `sales_assistant = 0`.

<div data-with-frame="true"><figure><img src="/files/kpg5ZBYgbKqPeM78FI67" alt=""><figcaption></figcaption></figure></div>

The block setup is complete.

### Configuring three AI assistants

Let's create the first assistant, which will act as the **distributor** to route clients to the appropriate specialized AI bots.

<div data-with-frame="true"><figure><img src="/files/JGcEbwSbrpVUdZSm1UG9" alt=""><figcaption></figcaption></figure></div>

`You are a distribution assistant. You have two colleagues: an bookkeeper/accountant and a sales manager. When a client writes to you, ask them how you can help and offer the assistance of the accountant and the sales manager. If the client needs the sales manager, execute the command "start_block_from_ai 11959" If the client needs the accountant/bookkeeper, execute the command "start_block_from_ai 11960".`

This assistant is needed to switch the client to the sales manager or the accountant.\
Now, configure the commands:

1\. Also, in the assistant’s settings, specify to the bot: “If the client needs a sales manager, send exactly ‘start\_block\_from\_ai 12345’,” where “12345” is replaced with the block number containing the variables `bookkeeper = 0` and `sales_assistant = 1`.

<div data-with-frame="true"><figure><img src="/files/Exk0r5X8i8hoMuKjxXgW" alt=""><figcaption></figcaption></figure></div>

2. Next, specify the second command in the settings:\
   "If the client needs an accountant, send exactly ‘start\_block\_from\_ai 12345’," where "12345" is replaced with the block number containing the variables `bookkeeper = 1` and `sales_assistant = 0`.

<div data-with-frame="true"><figure><img src="/files/nNUSlfcxXMLvLGT1l7yg" alt=""><figcaption></figcaption></figure></div>

The distributor assistant’s settings are complete.

### How to create a sales manager (role)

To do this, click the button to create the next assistant:

<div data-with-frame="true"><figure><img src="/files/qp3WV1kueJhNlIydRJcc" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="success" %}
You can rename the assistant as you wish.
{% endhint %}

Set the role to "sales manager" and apply any predefined settings as needed:

<div data-with-frame="true"><figure><img src="/files/Pnz7L4Woh9TFI2PgTMJP" alt="" width="563"><figcaption></figcaption></figure></div>

In the trigger line, be sure to set the variable with the value:

<div data-with-frame="true"><figure><img src="/files/U2A6hwSnPTGXLLmVx1ne" alt=""><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/fS7361jxGcCYkFIX5dv4" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
What is this for?

When the client tells your distributor that they want to contact the sales manager, the chatbot will trigger the block containing the variable `sales_assistant = 1`, which allows switching the client to the sales manager bot.<br>

The sales manager bot will only activate when its launch condition is met — specifically, only when the block with the variable `sales_assistant` set to 1 is triggered.
{% endhint %}

Now, go to the "Bot settings":

<div data-with-frame="true"><figure><img src="/files/RyjQs7ETHX0UJoku9Lgy" alt=""><figcaption></figcaption></figure></div>

{% hint style="warning" %}

## Important

It is essential to specify commands for switching to other assistants by triggering blocks from the builder!
{% endhint %}

Configure the commands for the sales manager assistant:

1. Specify in the settings: "If the client needs an accountant, send exactly 'start\_block\_from\_ai 12345'," where “12345" is replaced with the block number containing the variables `booker = 1`, `sales_assistant = 0` — this command is necessary to activate the accountant.
2. Add a second command to switch to the distributor assistant: "If the client needs the distributor, send exactly ‘start\_block\_from\_ai 12345'," where "12345" is replaced with the block number containing the variables `bookkeeper = 0`, `sales_assistant = 0`.

This command is needed to reset the variables and return to the first assistant.

<div data-with-frame="true"><figure><img src="/files/byz45DLQhdNeSwnqGri8" alt=""><figcaption></figcaption></figure></div>

The sales manager setup is complete.

**Let's move on to the last AI chatbot — the bookkeper.**

Create the third assistant and assign its name:

<div data-with-frame="true"><figure><img src="/files/4YWQBneRcOxJZfkHTkS8" alt=""><figcaption></figcaption></figure></div>

Set the launch condition variable to `bookkeeper == 1`:

<div data-with-frame="true"><figure><img src="/files/HR4PUsgc2ufzxBcSmtp7" alt=""><figcaption></figcaption></figure></div>

Once the trigger condition is met, proceed to configure the assistant's role, knowledge base, and response behavior.

<div data-with-frame="true"><figure><img src="/files/2zwqMW8xcpVexB3YsrVZ" alt=""><figcaption></figcaption></figure></div>

Specify the commands as you've done before:

1. `If the client needs a sales manager, execute the "start_block_from_ai 11959" command`, where "11959" is replaced with the block number containing the variables `bookkeeper = 0`, `sales_assistant = 1`.
2. `If the client needs to return to the distribution, execute the "start_block_from_ai 11958"`, where "11958" is replaced with the block number containing the variables `bookkeeper = 0`, `saleman = 0`.

The assistants setup is complete.

#### Work testing

1. When the bot is launched, the distributor assistant is triggered:

<div data-with-frame="true"><figure><img src="/files/POoMNxGUCvXwfONFleQ7" alt="" width="375"><figcaption></figcaption></figure></div>

2. Next, call the accountant manager has been activated:

<div data-with-frame="true"><figure><img src="/files/VJzCSwrheTnScdCzyk0F" alt="" width="375"><figcaption></figcaption></figure></div>

3. Then, ask the sales manager to switch you to the sales manager:

<div><figure><img src="/files/OLJNguh9uZfOlerogy1C" alt="" width="375"><figcaption></figcaption></figure> <figure><img src="/files/tGAz5zpUS6yyvojEPISv" alt="" width="375"><figcaption></figcaption></figure></div>

3. Now you can return to the distributor assistant:

<div data-with-frame="true"><figure><img src="/files/tCTFtHcK7vux9pmY1Huv" alt="" width="375"><figcaption></figcaption></figure></div>

Thus, the bot has worked correctly.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mavibot.ai/chatbot/ai/two-assistant.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
