Tag Management

Overview

Tags in vCon are key-value pairs that provide simple, flexible metadata for categorization, filtering, and organization. Tags are stored as a special attachment with type: "tags", encoding: "json", and a body containing an array of "key:value" strings.

Storage Format

Tags are stored internally as an attachment in the vCon:

{
  "type": "tags",
  "encoding": "json",
  "body": "[\"department:sales\", \"priority:high\", \"status:open\"]"
}

This format is automatically managed by the tag tools - you don't need to interact with attachments directly.

Available Tools

1. add_tag - Add or Update a Single Tag

Add or update a tag on a vCon.

Input:

Examples:

Response:


2. get_tag - Get a Single Tag Value

Retrieve the value of a specific tag.

Input:

Examples:

Response:


3. get_all_tags - Get All Tags

Retrieve all tags from a vCon as a key-value object.

Input:

Example:

Response:


4. update_tags - Update Multiple Tags

Update multiple tags at once.

Input:

Examples:

Response:


5. remove_tag - Remove a Single Tag

Remove a specific tag from a vCon.

Input:

Example:

Response:


6. remove_all_tags - Remove All Tags

Remove all tags from a vCon.

Input:

Example:

Response:


7. search_by_tags - Search vCons by Tags

Search for vCons that have specific tag values. All specified tags must match (AND logic).

Input:

Behavior:

  • Always returns vcon_uuids for all matching vCons (up to limit)

  • For small result sets (≤20), full vCon objects are returned by default

  • For large result sets (>20), only UUIDs are returned by default to prevent response size limits

  • Use get_vcon to fetch individual vCons by UUID when needed

Examples:

Response:


8. get_unique_tags - Get All Unique Tags

Get a list of all unique tag keys and their possible values across all vCons. This is useful for:

  • Discovering what tags are in use

  • Building tag selection UIs

  • Analytics and reporting

  • Understanding your tag taxonomy

Input:

Examples:

Response (without counts):

Response (with counts):

Use Cases:

  • UI Building: Populate dropdown menus with available tag values

  • Analytics: Understand tag distribution and usage patterns

  • Data Quality: Find tags that are rarely used or might be misspelled

  • Tag Cleanup: Identify tags that should be standardized or removed


Integration with Search Tools

Tags can also be used to filter results in the main search tools:

Keyword Search with Tags

Semantic Search with Tags

Hybrid Search with Tags


Tag Discovery and Analytics

Get All Tags in Your System

Build Tag Selection UI

Find Rarely Used Tags

Analyze Tag Distribution


Common Use Cases

1. Customer Tracking

2. Department Organization

3. Status Tracking

4. Priority Management

5. Campaign Tracking


Best Practices

Tag Naming

  • Use lowercase with underscores: customer_id, created_date

  • Be consistent across your application

  • Avoid spaces in tag keys

  • Use descriptive names: priority instead of p

Tag Values

  • Keep values simple and consistent

  • Use a predefined set of values for categorical tags (e.g., status: "open", "closed", "pending")

  • For dates, use ISO 8601 format: "2025-10-14T10:30:00Z"

  • For booleans, use "true" or "false" strings

Performance

  • Use tags for filtering, not for storing large amounts of data

  • Limit the number of tags per vCon to what's needed

  • Tags are indexed for fast searching

  • Consider using the materialized view for tag-heavy queries

Organization

  • Define a tagging schema for your application

  • Document which tags are used and their possible values

  • Use tags hierarchically: department, then team, then region


Technical Details

Storage

  • Tags are stored as an attachment with type: "tags"

  • The attachment has encoding: "json"

  • The body contains a JSON array of "key:value" strings

  • Example: ["department:sales", "priority:high"]

Querying

  • Tags are indexed using a GIN index for fast containment queries

  • A materialized view (vcon_tags_mv) provides optimized tag queries

  • Search functions use JSONB containment operators (@>)

Updates

  • Adding/updating tags modifies the tags attachment

  • If no tags attachment exists, one is created

  • The vCon's updated_at timestamp is updated on tag changes

  • Tags are atomic - you can't have partial updates


Troubleshooting

Tag not appearing after adding

  • Check that the vCon UUID is correct

  • Verify the tag was added successfully (check response)

  • Use get_all_tags to see all current tags

Search returning unexpected results

  • Remember that search_by_tags uses AND logic (all tags must match)

  • Check that tag values match exactly (case-sensitive)

  • Verify tags are strings in the search query

Performance issues

  • Consider refreshing the materialized view: REFRESH MATERIALIZED VIEW vcon_tags_mv;

  • Check index usage with EXPLAIN ANALYZE

  • Limit the number of tags per vCon


Examples in Different Scenarios

Phone Call Center

Chat Support

Email Threads


Migration from Other Systems

If you're migrating from systems that use different tag formats:

From flat metadata

From nested structures


API Reference

For the complete API reference, see the tool definitions in src/tools/tag-tools.ts.

For database implementation details, see the query methods in src/db/queries.ts.

Last updated