# Semantic search

Semantic search in the match type of blocks -  is an AI that is trained to extract context from the conditions embedded in the client's message.

The blocks have priority over the AI assistant, so you can use a block with a condition and a choice of matching "comparison in meaning" if you want to send the client a clearly verified and prescribed response.

## How it works

Semantic search compares the **meaning** between a user's message and predefined conditions, rather than relying on exact keyword matching.

**Core principle**

The system analyzes the **context and intent** within the user's message and searches for a match with the **meaning embedded in the trigger condition**.

**Processing workflow**

1. The AI extracts the semantic meaning from the client's message.
2. The system compares this meaning against the semantic phrases defined in the trigger's conditions.
3. If a **semantic match** is found, the chatbot processes the corresponding event within the block (e.g., sending a specific message).

**Example**

In the condition, we define a semantic phrase (e.g., *"closing accounts and acts"*). If the AI identifies this meaning within the user's remark, it triggers the associated event block.

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

The block setting looks like this:

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

During choosing a "Semantic search" match, the bot need to find similar meaning words/phrases in the client's message, which are based on the block trigger:

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

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

Each time the bot processes the client's message, it correctly processes the necessary event in the block.

## How to write a trigger

The trigger in the corresponding field is written in the same way as other trigger for any match selection:

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

Creating clear, concise, and accurate conditions is critical for **performance, reliability, and user experience**. Here’s why it matters:

* **Correct processing:** Precise conditions ensure the chatbot correctly identifies and executes the intended event.
* **Processing speed:** Complex, ambiguous, or verbose phrases increase AI processing time and can degrade response speed.
* **Scheme reliability:** Vague wording heightens the risk of misinterpretation, potentially causing your workflow to behave incorrectly.

Avoid overly complex words, ambiguous terms, and long, multi-sentence phrases in your conditions.

**Example of an effective trigger condition**

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

An example of an <mark style="color:red;">**INcorrect trigger condition**</mark>:

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

{% hint style="danger" %}
**Avoid single-word trigger conditions**

While conditions should be concise, they must also be **semantically meaningful**. A single word (e.g., “invoice”) often lacks sufficient context for accurate semantic matching.

**Use descriptive phrases**

Instead of isolated words, use short, descriptive phrases that capture the intent.

**Example:**

❌ `"invoice"`\
✅ `"monthly invoice payment"`

This provides clearer context for the AI model to perform an accurate semantic comparison.

**Key principle**

The AI compares the *meaning* of conditions, not just keywords. A well-defined phrase establishes the necessary semantic criteria for reliable matching.
{% endhint %}

### **Example**

When you write more detailed triggers for Semantic Search, the AI understands the context and responds quickly.

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

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

If you define a trigger condition using only a **single word** (as in the example below), the AI may **fail to detect sufficient context** and will not trigger a response, resulting in silence.

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

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

Also, the block with the correct settings doesn’t work because the AI cannot find the trigger from the correct block in the client’s message and cannot send them any message.

{% hint style="warning" %}

#### Be careful

Also, if the trigger for Semantic Search is incorrect (too short or ambiguous), the AI may respond to such triggers at the wrong time or in the wrong place.
{% endhint %}

## **Smart station AI chatbot example**

{% hint style="success" %}
In this example, we will clearly demonstrate the priority of blocks over AI assistants and the search by context in the client's message with the choice the Semantic search type.
{% endhint %}

In the chatbot builder, we create two "Start" blocks, in each of which we choose the "Semantic search" type and the message "Turning on/off the light":

1. Block 1 "Turn on the light"

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

2. Block 2 "Turn off the light"

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

To understand that it was the block that was worked out, and not the AI assistant, we will add an additional line in the message of each block.

Next, we switch to the AI assistant.

Creating a bot with the role of "Universal AI assistant".

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

For demonstration purposes, we will not apply any restrictions to the assistant’s behavior when processing blocks.

All settings are now complete. Let’s proceed to testing.

1. Start a chat with the smart station to begin.

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

Since we have not limited the station in any way, it can talk about completely abstract topics.

2. Now, in the context of our message, we write down the key meaning - turn on or turn off the light:

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

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

The bot worked correctly.

Thus, at times when the trigger from the block are not fulfilled, the assistant works.

However, if the bot detects the context defined by the block’s condition, the block itself will be triggered.


---

# 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/search.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.
