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

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.
- Format:
-
labels_exclusive- Controls whether untagged documents are included (optional, boolean).- Format:
labels_exclusive="true"orlabels_exclusive="false" - When
true: Only documents with matching tags are used (strict filtering) - When
falseor omitted: Documents with matching tags AND documents without any tags are used (permissive filtering) - Default:
falseNote: 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.
- Format:
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, andlabelswith 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 becauselabels_exclusiveis set totrue.
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
Updated 13 days ago
