# Use Tables to store your KBAI questions

<figure><img src="/files/zOKzvPG71EtbAnTI2gcd" alt=""><figcaption><p>Collect what the user asked.</p></figcaption></figure>

## Collect your KBAI answers

To store your KBAI questions and answers with Tables:

1. [Create a KBAI flow](/navigation/knowledge-base-ai/build-your-kbai-flow.md) inside your bot or use the [KBAI template bot](/start-quickly/bot-templates.md#knowledge-base-ai).
2. Make sure to [add content to your KBAI](/navigation/knowledge-base-ai/add-content-to-your-kbai.md).
3. [Create a Table](/navigation/tables/create-a-table-with-records.md) called *QuestionCollection*, with 2 text columns:&#x20;

   * *questionAsked*
   * *answerGiven*

   <figure><img src="/files/ZPyirZV69DISntezLNhb" alt="" width="375"><figcaption><p>Create a table that collects your KBAI questions and answers.</p></figcaption></figure>
4. **Save**.
5. Go back to your [**Flows**](/navigation/bot-builder/flows.md).
6. Open the block where the KBAI search happens. In our case, it will be the **Not understood** block.&#x20;
7. Add a **Go to** after this block that you'll call *Populate table*.

<figure><img src="/files/w4kF2ca5Fk2wla0IYVm9" alt="" width="375"><figcaption><p>After the KBAI block, populate your table.</p></figcaption></figure>

7. **Save** this block.
8. Open the **Populate table** bloc&#x6B;**.**
9. Add a [**Table operations** ](/navigation/tables/operate-on-your-records.md#add-a-table-operation-to-your-flow)step.
10. Select **Insert record** to the ***QuestionCollection*** table.
11. Configure the operation so that:
    * `{internal.nlp.expression}` is added to the **questionAsked** column
    * `{knowledgebase.answer}` is added to the **answerGiven** column

<figure><img src="/files/DP3ZAQk1P3NPgC6Tlg0T" alt="" width="360"><figcaption><p>Populate your table with the KBAI question and answer.</p></figcaption></figure>

You could also add a time stamp:

<details>

<summary>Add the timestamp to your Table</summary>

To add a timestamp to your Table:

1. Make sure your Table has a *timestamp* column with a [timestamp](/navigation/tables/column-types.md#timestamp) column type.&#x20;
2. Open the block that happens just before the **Populate Table** block.
3. Add a [**Set variables**](/buildabot/flow-logic/dialog-state/action-bot-dialog.md#set-variables) step to it.
4. Set a `{timestamp}` variable as an expression for `NOW()`. You will need [expression syntax](/integrateandcode/expression-syntax.md) for this.

<img src="/files/igB3aJ1nzWpZ7tmSit8H" alt="" data-size="original">

4. Click **Save**.
5. Open your **Populate Table** block.
6. Insert a `{timestamp}` record in the **timestamp** column.
7. Click **Save**.

The time stamp would appear like this in your Table:

</details>

12. **Save** your changes.

Now you should be able to see a list of your questions and answers from your Tables!

<figure><img src="/files/60MUoGkvHdTgQ0j8Ih8t" alt=""><figcaption><p>What your Table should look like after collection.</p></figcaption></figure>

## Collect questions where KBAI was unsatisfactory

It can be useful for you to store the places where your KBAI didn't answer to what the user said.

To collect variables where your KBAI was unsatisfactory:

1. Find the blocks where your KBAI goes when either an error occured or no result was found.
2. In each of them, pass on a variable that you'll call failure\_reason, and give it the value error occured or no result.
3. Make sure you have a column in your Table to store those.
4. When you populate your table, add those to the Table.&#x20;


---

# 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/use-tables-to-store-your-kbai-questions.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.
