> For the complete documentation index, see [llms.txt](https://docs.chatlayer.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chatlayer.ai/navigation/knowledge-base-ai/use-tables-to-store-your-kbai-questions.md). Agents can also search and read this documentation through its [MCP server](https://docs.chatlayer.ai/~gitbook/mcp).

# Use Tables to store your KBAI questions

You'd like to pull a list of what are your customers questions managed by your KBAI? You can set that up with our in-house Tables.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2F8pbikA4UpG1L4jl5B842%2FScreenshot%202024-10-01%20at%2016.23.57.png?alt=media&amp;token=6151fbe3-eae1-422e-8575-41d94eb7212f" 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](https://docs.chatlayer.ai/navigation/knowledge-base-ai/build-your-kbai-flow.md) inside your bot or use the [KBAI template bot](https://docs.chatlayer.ai/start-quickly/bot-templates.md#knowledge-base-ai).
2. Make sure to [add content to your KBAI](https://docs.chatlayer.ai/navigation/knowledge-base-ai/add-content-to-your-kbai.md).
3. [Create a Table](https://docs.chatlayer.ai/navigation/tables/create-a-table-with-records.md) called *QuestionCollection*, with 2 text columns:

   * *questionAsked*
   * *answerGiven*

   <figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2Fpbpwy2JWf9nYM2zsVg2N%2FScreenshot%202024-09-13%20at%2011.35.54.png?alt=media&amp;token=76ff9fbd-6777-47c3-a50e-f7c9f771f779" 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**](https://docs.chatlayer.ai/navigation/bot-builder/flows.md).
6. Open the block where the KBAI search happens. In our case, it will be the **Not understood** block.
7. Add a **Go to** after this block that you'll call *Populate table*.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2F3ztdFW2QNJLSlZTjIYpU%2FScreenshot%202024-09-13%20at%2011.45.40.png?alt=media&amp;token=778cc867-e871-48e2-a556-0b24f9907000" 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** ](https://docs.chatlayer.ai/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="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2F1zjOES3b6d4IhWVEP3Fm%2FScreenshot%202024-09-13%20at%2011.47.27.png?alt=media&amp;token=a566c88d-9ff6-4c03-87d0-45103b5ec4e4" 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](https://docs.chatlayer.ai/navigation/tables/column-types.md#timestamp) column type.
2. Open the block that happens just before the **Populate Table** block.
3. Add a [**Set variables**](https://docs.chatlayer.ai/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](https://docs.chatlayer.ai/integrateandcode/expression-syntax.md) for this.

<img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2F9balGrQEBNmoZNgc4uC2%2FScreenshot%202024-10-01%20at%2016.29.35.png?alt=media&amp;token=7a783347-ffad-4f9d-97c0-1c53e1697e50" 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="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FjHTSsWu8ZF9o9wrBM0zx%2FScreenshot%202024-10-01%20at%2016.21.49.png?alt=media&amp;token=8f6e5aaf-4259-4907-adf2-c72c83c2b207" 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.chatlayer.ai/navigation/knowledge-base-ai/use-tables-to-store-your-kbai-questions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
