Shipping manual segments via plugins
Summarize
Summary of Shipping manual segments via plugins
Business unit application developers can include manual segments—domain-specific saved searches—in their ServiceNow applications via plugins. This enables users to immediately perform natural language searches using business terminology relevant to the app’s data upon installation, without waiting for automated segments to be generated.
Show less
Manual segments have higher search priority and their filters are preserved by the language model unless irrelevant, ensuring accurate and relevant search results tailored to the domain.
How to Ship Manual Segments
- Create snquerygensegmenttableconfig records for manual segments in a development instance.
- Verify correct syncing and expected search results in test environments.
- Include these records in the application’s update set for shipping via plugin.
Important installation notes: Business rules are bypassed during plugin installation, so manual segments become active only after the next scheduled sync job (Generate Semantic Layer or Sync Segments) runs. Also, ensure no duplicate segment names exist per entity as there is no database-level uniqueness enforcement.
Example Configuration
Manual segments can be defined for specific tables like incident with filters to capture high-value queries, e.g., “Critical Open Incidents” (priority 1 and unresolved), “My Team’s Overdue Incidents” (assigned to user’s group and SLA overdue), and recent escalations.
Prerequisite: The target table must have an active entity in snquerygentableconfig with semantic generation enabled.
Best Practices
- Focus manual segments on high-traffic, business-critical tables for maximum impact.
- Use clear, user-friendly business language for segment names rather than technical codes.
- Provide descriptions to help disambiguate similar segments and guide the language model.
- Test segments in a non-production environment to ensure proper syncing and accurate search results.
- Avoid duplicating automated segments; improve existing ones if necessary instead of adding redundant manual segments.
Pre-Shipping Checklist
- Confirm target tables have active semantic layer entities with generation enabled.
- Use plain language for segment names and include descriptions where needed.
- Validate filters as correct encoded queries under 2,000 characters for prompt efficiency.
- Ensure no duplicates in name-table combinations within the update set.
- Verify segments synchronize properly and yield expected search results in test instances.
Post-Deployment Monitoring
- Review query logs to monitor which manual segments are matched and verify query accuracy.
- Gather user feedback on search relevance and coverage.
- Refine segment names and descriptions based on usage patterns to improve results.
- If segments match incorrectly, first adjust names and descriptions before changing system properties.
Business unit application developers can ship manual segments with their applications to provide domain-specific saved searches that work from the moment the app is installed.
Shipping overview
Manual segments are the recommended way to ship domain-specific saved searches with your application. They receive a priority boost over automated segments during search, and the LLM is instructed to retain all their filters unless completely irrelevant—whereas automated segment filters are critiqued individually.
Shipping manual segments with your plugin ensures that users can immediately ask natural language questions about your application's data using business terminology, without waiting for automated segments to be generated from usage patterns.
How to ship manual segments
- Create your manual segment config records in a development instance.
- Verify they sync correctly and produce expected search results.
- Include the sn_query_gen_segment_table_config records in your app's update set.
Plugin installation behavior
Understanding how manual segments behave during plugin installation is important for setting proper expectations:
- Business rules are bypassed during plugin installation—the async sync will not fire automatically at install time.
- The records will be synced into sn_query_gen_segment the next time the Generate Semantic Layer scheduled job runs (post-install) or when the weekly Sync Segments job runs.
- Ensure your plugin does not ship duplicate records. There is no unique constraint at the database level—admins must ensure no duplicate names per entity.
Example: Full configuration for a table
The following example shows manual segments for the incident table that could be shipped with an ITSM application:
Prerequisite: The incident table must have a record in sn_query_gen_table_config with enable_semantic_generation = true and an active entity.
| Name | Description | Table | Filter |
|---|---|---|---|
| Critical Open Incidents | High priority incidents that are currently open and unresolved. Includes all assignment groups. | incident | priority=1^state!=7^state!=8 |
| My Team's Overdue Incidents | Incidents assigned to the current user's group that have passed their SLA due date. | incident | assignment_group=javascript:getMyGroups()^sla_due<javascript:gs.nowDateTime()^state!=7 |
| Recent P1/P2 Escalations | Priority 1 and 2 incidents escalated in the last 7 days. | incident | priority<=2^escalation=1^sys_updated_on>=javascript:gs.daysAgoStart(7) |
Best practices for shipping segments
- Focus on high-value, high-traffic tables
- Concentrate manual segments on the tables your users ask about most. A handful of well-crafted segments on your app's primary tables will have more impact than broad coverage across rarely-queried tables.
- Use business language, not technical codes
- Segment names should match how users naturally speak about your domain. "Critical Open Incidents" is better than "P1_OPEN_INC".
- Provide descriptions for disambiguation
- If you ship multiple segments for the same table, descriptions help the LLM pick the right one. Without descriptions, the LLM may arbitrarily choose between similar matches.
- Test before shipping
- Verify in a test environment that segments sync correctly and appear in search results for relevant utterances. Check the query logs to confirm matching behavior.
- Avoid duplicating automated segments
- Before creating a manual segment, check whether an automated segment already covers the same filter. If one exists but has a poor name, consider improving the source rather than creating a duplicate.
Checklist before shipping
Verify the following before including manual segments in your plugin:
- Each target table has an active entity in the semantic layer (sn_query_gen_table_config with enable_semantic_generation = true)
- Segment names are written in plain user language, not technical shorthand
- Descriptions are provided for segments where the name alone may be ambiguous
- Filters are valid encoded queries and under 2,000 characters for optimal LLM prompt inclusion
- No duplicate records (same name + table combination) exist in your update set
- All sn_query_gen_segment_table_config records are included in your app's update set
- You have verified in a test environment that segments sync correctly and appear in search results for relevant utterances
Monitoring after deployment
After shipping manual segments with your application:
- Monitor which segments are being matched in the query logs
- Verify that generated queries are correct for the intended use cases
- Collect user feedback on query accuracy and coverage
- Iterate on segment names and descriptions based on usage patterns
If a segment is matching but producing wrong results, the issue is usually the name being too generic or the filter being too broad. Refine the name and description before adjusting system properties.