# Knowledge base setup

## Configuration when explicitly requested by the end user:

1. Create your **context condition** to check operator availability. To do this, go to the **Contents > Context Conditions page**.
2. Fill in the fields as shown in the example below:

<figure><img src="/files/0O0pHXLr3YyrsFOMhwJF" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
It is also possible to check if the Livechat is open by following the operating hours configured in **Preferences** > **Livechat Settings** > **General**.

To do this, you can use the **LiveChatOpen()** condition, which only checks if the Livechat is open.

On the other hand, the **LiveChatAvailable()** condition checks both if the Livechat is open and if an operator is available.
{% endhint %}

3. Go to **Contents > Knowledge** and create a knowledge of the type "answer to a question".

Example: "I want to speak to an advisor."

<figure><img src="/files/aJcN9nnD7DKsWgjl7K6k" alt="" width="407"><figcaption></figcaption></figure>

4. Insert a context condition between the user's question and the response, and select the condition you created in step 1.

<figure><img src="/files/uNSWDsTnxLRdr1rEZsUF" alt="" width="272"><figcaption></figcaption></figure>

5. Click on Update.
6. Complete the success and failure responses:

Example of success: "I'll connect you with an advisor."\
Example of failure: "Unfortunately, no advisors are available."

<figure><img src="/files/ug8CmcHFsXg0FzLgaKl4" alt="" width="563"><figcaption></figcaption></figure>

7. Edit the response to display when an operator is available (the branch on the left), then click on **More options > Other options > Set GUI action** and select **Connect Livechat**.

<figure><img src="/files/vO4nQSj1ndCSTx9vkfVd" alt="" width="307"><figcaption></figcaption></figure>

<figure><img src="/files/Sjm2J58BlrAhgeQhiKJu" alt="" width="315"><figcaption></figcaption></figure>

<figure><img src="/files/nx50fyL1q9lobnwqRuxY" alt="" width="305"><figcaption></figcaption></figure>

8. Click on **Update** to save the response. Your Livechat escalation is now effective.

If an operator is available, the user is directed to the branch on the left and connected with an operator. Otherwise, the user will receive the response provided in the branch on the right.

It's also possible to redirect the user to an operator with specific expertise. Once you have defined skills for each operator, you can choose to assign each skill to a knowledge item. The skills will appear in the list of context conditions when you create your responses.

{% hint style="info" %}
Note: you have the ability to create predefined answers for your Livechat sessions. To learn more, click [here](https://dev.docs.dydu.ai/docs/Knowledge/Types/predefined_answer).
{% endhint %}


---

# 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-en.dydu.ai/livechat/knowledge-base-setup.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.
