Enable and use tags for your agent

This step-by-step guide explains how to enable and use tags to filter and organize your agent's knowledge base, allowing you to serve specific content based on context at query time.


🚧

This is an enterprise-only feature and must be specifically enabled for your account. Contact your account manager or support team to request access.


Default availability

  • Works on the following deployment types: API, Embed, Live Chat, Website Copilot, Instant Viewer, and Search Generative Experience (SGE).
  • No additional setup beyond enabling the toggle and adding the parameters to your deployment code.
  • Tags are evaluated at query time and do not permanently filter your knowledge base.
  • Tags data is used only during that request to preserve privacy. The agent does not store tag selections.
❗️

Note: Before you can use tags for filtering, you must first assign tags to your pages in your knowledge base. You can do this directly in the builder (no API access required) or through the API for programmatic workflows. tags can be assigned both manually and automatically. For detailed instructions on how to create and assign tags to your documents, refer to Labels API documentation.


How to enable and use tags

Step 1: Enable tags in deployment settings

  1. Select the agent you want to update and click the Deploy Agent icon.
Deploy agent icon
  1. If your agent is private, click Make Public. If it's already public, continue to the next step.
Make public button
  1. Select your preferred deployment method, then click the Settings (gear) icon.
Settings icon
  1. On the Settings page, go to Advanced tab.
  1. Enable the Labels toggle
  1. Click Save Changes to apply the changes.
Save changes button

Step 2: Add tag parameters to your embed script

Open your web page template, locate the embed code, and add the tag parameters to the embed snippet. Then save the template.

Parameters

  • labels - A comma-separated list of tag names.

    • Format: labels="label1,label2,label3"
    • Example with names: labels="English,Sales,ProductA"

    Note: Tag values are always treated as strings. Always pass tag names. Numeric IDs are not supported.

    If you are dynamically passing labels based on user actions (for example, via query string or session data), use tag names. If a tag is renamed in the builder, update your code to match the new name.

  • labels_exclusive - Controls whether untagged documents are included (optional, boolean).

    • Format: labels_exclusive="true" or labels_exclusive="false"
    • When true: Only documents with matching tags are used (strict filtering)
    • When false or omitted: Documents with matching tags AND documents without any tags are used (permissive filtering)
    • Default: false
      📘

      Note: To verify your filtering is working as expected, use the test agent in Test Source Label Filtering to run both exclusive and permissive modes before deploying.

Example embed code with tags

<div id="customgpt_chat"></div>
<script src="https://cdn.customgpt.ai/js/embed.js"
defer
div_id="customgpt_chat"
p_id="123456"
p_key="abcdefgh"
labels="English,Sales"
labels_exclusive="true"></script>
🚧

Note:

Replace the values of p_id, p_key, and labels with your specific Agent ID, key, and desired tag filters. In the above example, the agent will use only documents tagged with "English" or "Sales", and will exclude any untagged documents because labels_exclusive is set to true.


Using tags with the API

Tags are also available when querying your agent via the Send Message API endpoint. Include the labels and labels_exclusive parameters in your API request to filter content programmatically.

For complete API documentation and examples, visit the Labels API reference.


Related articles


Did this page help you?