# Use tags to limit your KBAI content

Once you've [added KBAI content](https://docs.chatlayer.ai/navigation/knowledge-base-ai/add-content-to-your-kbai) and [build you flow,](https://docs.chatlayer.ai/navigation/knowledge-base-ai/build-your-kbai-flow) it might be useful to tell your bot which content to scrape. For example, if a customer asks for something on topic X, it's better if your bot only looks for the content on topic X at that point in your conversation.&#x20;

You can optionally define different categories of topics by using tags.

## Add tags to your content

To add tags to your content:

1. [**Add content**](https://docs.chatlayer.ai/navigation/knowledge-base-ai/add-content-to-your-kbai) to your KBAI.
2. Add a tag under **Tag this source**. You can either:
   * Create a tag from this field
   * Select a tag that you already created
   * [Select a variable](#use-variables-as-kbai-tags)

<details>

<summary>Use variables as KBAI tags</summary>

You can use [variables](https://docs.chatlayer.ai/navigation/settings/secure-variables-gdpr) as tags. This means that any variable captured in your flow (for instance under button click) can be used to define which part of your knowledge base should be searched.

In the example below, a variable is saved under a button click, then the variable is used to search only documents tagged with pizza in the knowledge base.

<img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FNKCe7utwKaO0A7X9gdO2%2FScreenshot%202024-08-20%20at%2015.24.43.png?alt=media&#x26;token=a49b0d60-199c-4e7a-86cc-017fe6d87f5a" alt="" data-size="original">

</details>

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FcYWvY36LhkDCJF9VAQFf%2Fimage.png?alt=media&#x26;token=a042bd68-85c6-478a-9e08-011b912aae37" alt="" width="563"><figcaption><p>Tag your sources to differentiate them.</p></figcaption></figure>

3. Click **Save**.

## Edit tags

To edit your KBAI tags:

1. From your **Contents** page, click on the **3 dots** at the end of the line where your content is listed.
2. Click on **Edit**.&#x20;

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FKRh0P5JAMNdIfqIIZooS%2Fimage.png?alt=media&#x26;token=b0ac4e76-d848-476d-be22-1ba5594e8623" alt="" width="259"><figcaption></figcaption></figure>

3. In the window that pops up, you can remove existing tags or add new tags.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FWQxMYJibxW8gY0LlDDnn%2FScreenshot%202024-08-20%20at%2015.29.46.png?alt=media&#x26;token=0018a66b-52f3-4903-ab3b-153ada9be0d6" alt="" width="284"><figcaption><p>Update your content tags.</p></figcaption></figure>

4. Click Save.

## Use tags in your KBAI flow

To use tags in your KBAI flow:

1. [Build your flow](https://docs.chatlayer.ai/navigation/knowledge-base-ai/build-your-kbai-flow).
2. Open your KBAI block where the bot [retrieves the answer](https://docs.chatlayer.ai/navigation/build-your-kbai-flow#retrieve-the-answer).
3. Under **Limit your content**, choose the tags of the sources that you would like your bot to visit. Only content tagged with these tags will be searched by the bot.
4. **Save** your changes.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2FAHeh0yy4a9uQlY18ewPO%2Fimage.png?alt=media&#x26;token=6559e799-1d91-4384-a46b-81aad43a4f6b" alt="" width="563"><figcaption><p>Limit the content that your bot scrapes by using tags.</p></figcaption></figure>

## Example

An example use case would be a bot that has a lot of content uploaded to it from different sources, but needs to give a specific answers when it comes to questions about security.

The "security" intent that catches all questions related to security. When that intent is triggered, the bot answers through the Knowledge base AI content that is tagged with "security". Afterwards, the bot will provide a link where more security information can be found.

<figure><img src="https://2786867680-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LLTwFwbOqJj4dDhg8Ju%2Fuploads%2F7OjdQonoJG9uUKEOq7pi%2Fimage.png?alt=media&#x26;token=0802f387-bd7a-4910-84ee-d3045f1e8916" alt=""><figcaption><p>Example of a flow where a bot scrapes only content related to security.</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/use-tags-to-limit-your-kbai-content.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.
