# Manage handover where KBAI is unsatisfactory

If your [**Knowledge base AI (KBAI)**](https://docs.chatlayer.ai/navigation/knowledge-base-ai) cannot retrieve an appropriate answer to the user's question, it will result in "no finding." This behavior ensures that KBAI avoids providing unrelated answers or hallucinations.

To maintain a balance between efficiency and support, it's best practice to allow users to reformulate their questions and provide an option to connect with a human agent when the bot cannot assist effectively.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FC7sSBeAyE2IzOYuK7B3q%2FScreenshot%202024-08-07%20at%2013.30.20.png?alt=media&#x26;token=89bf44c5-899e-4545-a3c4-e1f8fe98761d" alt="" width="331"><figcaption><p>Example of handover where the KBAI fails.</p></figcaption></figure>

This article presents a flow model that detects intents before using [Knowledge base AI (KBAI)](https://docs.chatlayer.ai/navigation/knowledge-base-ai). The model will count the number of times where an answer was unsatisfactory before handing the user over to an agent.

The handover flow presented in this article follows this flowchart:

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FwXbPyDoX0qEVneSIf7Yn%2Fimage.png?alt=media&#x26;token=528eaa33-d986-4612-826e-34873233423f" alt=""><figcaption><p>KBAI handover flow model.</p></figcaption></figure>

Let's see step by step how this flow is working.

## 1. Provide built-in answers for crucial matters

When building your bot, there are typically some issues that would 100% of the times need the help of a human. To make sure these matters are tackled as early as possible, the best strategy is to catch them at the start of your flow by using [intents](https://docs.chatlayer.ai/navigation/analytics/intents).

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FfKXoTkTmhkwxIioH0SHz%2FScreenshot%202024-07-24%20at%2011.56.48.png?alt=media&#x26;token=e6bcdd7c-4f3e-4306-abc0-0e9683483993" alt="" width="328"><figcaption><p>Provide built-in answers by building a strong NLP model.</p></figcaption></figure>

{% hint style="success" %}
Build your NLP model from your [**NLP**](https://docs.chatlayer.ai/navigation/natural-language-processing-nlp) tab.
{% endhint %}

## 2. Use your KBAI for other questions

For any question that is not urgent or that doesn't need a built-in answer, use the KBAI. Your bot will then see if an answer can be found based on your documentation.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FMrTNK49J4wqZHmYNLExE%2FScreenshot%202024-07-24%20at%2011.59.20.png?alt=media&#x26;token=110073d6-0c3d-4516-9838-73bbf5634fe6" alt="" width="563"><figcaption><p>Use KBAI to find an answer when the bot doesn't understand what the user said.</p></figcaption></figure>

{% hint style="success" %}
To use [Knowledge base AI ](https://docs.chatlayer.ai/navigation/knowledge-base-ai)inside your bot, you'll need to [set up a KBAI flow](https://docs.chatlayer.ai/navigation/knowledge-base-ai/build-your-kbai-flow) or start with our [KBAI bot template](https://docs.chatlayer.ai/start-quickly/bot-templates/knowledge-base-ai-template).
{% endhint %}

## 3. Count the number of unsatisfactory answers

Count the number of times that your bot wasn't able to help the user by incrementing a `count` [variable](https://docs.chatlayer.ai/navigation/settings/secure-variables-gdpr) with 1 each time you go through an unsatisfactory answer.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FjsQwcH8nmcZ07jtGF3M2%2FScreenshot%202024-07-24%20at%2012.01.09.png?alt=media&#x26;token=2e83810c-e40b-4d6e-81fc-6ee24a076dae" alt="" width="563"><figcaption></figcaption></figure>

On Chatlayer, you can increment variables inside the [**Go to** ](https://docs.chatlayer.ai/buildabot/flow-logic/go-to-connections)section inside a block.&#x20;

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FMGfIdjByoY9uswj09xGh%2FScreenshot%202024-07-24%20at%2012.03.22.png?alt=media&#x26;token=4cbf834f-178b-4fa8-85a6-9ebb9e0420e6" alt=""><figcaption><p>Example: we pass on an incremented {count} variable to the next block.</p></figcaption></figure>

{% hint style="warning" %}
Please note that for this tutorial we are using the new [expression syntax](https://docs.chatlayer.ai/integrateandcode/expression-syntax). If you're using the old expression syntax, you'll need to use the `{counter|increment}` syntax.
{% endhint %}

## 4. Transfer to agent after multiple unsatisfactory answers

After 2 unsatisfactory answers, the user is [handed over to an agent](https://docs.chatlayer.ai/integrateandcode/human-offloading-live-chat).&#x20;

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2Fc5iHvD17gGaEIYly1745%2FScreenshot%202024-07-24%20at%2012.07.48.png?alt=media&#x26;token=6675d191-d50f-4fe7-a3b4-c701df7a5824" alt="" width="474"><figcaption><p>After 2 unsatisfactory answers, hand over the bot to an agent.</p></figcaption></figure>

***

This is what this handover flow looks like after it was build on Chatlayer:

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FTJoIIuzuGkHxoG9GAmaq%2FScreenshot%202024-07-24%20at%2011.17.42.png?alt=media&#x26;token=c8350978-3824-494d-8092-ef4ba3a2fd83" alt=""><figcaption><p>KBAI handover flow model build on Chatlayer.</p></figcaption></figure>


---

# 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.chatlayer.ai/navigation/knowledge-base-ai/manage-handover-where-kbai-is-unsatisfactory.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.
