Customizing AI Response Assist sources
Summarize
Summary of Customizing AI Response Assist sources
The Smart Assessment Response Assist skill in ServiceNow leverages previous assessments and attached documents to generate answer suggestions for assessment questions. By default, it uses scope-based matching to identify relevant previous assessments and documents attached to the current assessment instance. To tailor the sources of information used for specific template categories, ServiceNow provides a scripted extension point—allowing you to customize how previous assessments and documents are selected without modifying core application code.
Show less
How Customization Works
The extension point snsmartaiassist.SmartAsmtResponseAssistExtensionPoint lets you implement custom logic for selecting:
- Previous smart assessments
- Previous classic assessments
- Documents available for response assist
You implement this by creating a script include that overrides relevant methods:
- handles(templateCategoryId): Determines if your implementation applies to a given template category.
- getPreviousSmartAssessmentIdsForResponseAssist(assessmentId): Returns IDs of prior smart assessments to consider.
- getPreviousClassicAssessmentIdsForResponseAssist(assessmentId): Returns classic assessment record IDs and filtering information.
- getDocumentIdsForResponseAssist(assessmentId): Supplies additional document attachments to include in the response assist document picker.
Default Behavior and Override Effects
- Previous Assessments (Smart and Classic): By default, smart assessments are matched if their scope items fully cover the current assessment's scope; classic assessments match on individual scope items. If you override these methods, your returned IDs completely replace the default filtering logic for categories your implementation handles. Returning an empty result suppresses that source.
- Documents: The document picker always includes files attached to the assessment instance. Your implementation can add more documents but does not replace these default attachments.
Practical Application for ServiceNow Customers
This extension point empowers you to fine-tune the AI Response Assist functionality to better fit your organization's assessment workflows. For example, you can:
- Include previous assessments outside the default scope-based matching rules.
- Incorporate documents stored in related records, external systems, or other strategic locations as sources for drafting responses.
- Suppress specific source types if they are not relevant for certain template categories.
Implementing and registering your script include ensures the AI Response Assist uses your customized data sources, improving the relevance and accuracy of suggested answers during assessments.
Next Steps
- Create a script include extending
snsmartaiassist.SmartAsmtResponseAssistExtensionPointand override the necessary methods. - Register your script include implementation with the ServiceNow extension point framework.
- Test customized behavior to verify that the AI Response Assist pulls from your intended data sources.
The Smart Assessment Response Assist skill refers to previous assessments and documents to generate suggestions. By default, the skill uses scope-based matching for previous assessments and the files attached to the assessment instance for documents. To use different sources for a specific template category, implement the Smart Assessment Response Assist scripted extension point.
What a scripted extension point is
A scripted extension point is a ServiceNow platform mechanism that lets you extend the functionality of an application without modifying the application's core code.
For background on how scripted extension points work and how to implement them, see Using extension points to extend application functionality.
Why SAE exposes this extension point
Smart Assessment Response Assist generates draft answers from two source types.
- Previous assessments
- Past smart and classic assessments whose responses the skill can semantically match against the current questions.
- Documents
- Files the skill can analyze for answer content (SOC 2 reports, security policies, DPAs, vendor documentation, and so on).
The Smart Assessment Engine exposes the Smart Assessment Response Assist scripted extension point so that upstream applications and customer developers can provide that selection logic per template category.
Default behavior when no implementation is registered
- Previous smart assessments
- The skill considers a prior smart assessment only if its scope items are an exact match or a superset of the current assessment's scope items. The prior assessment must cover every scope item on the current assessment; it may include additional scope items, but it can't be missing any. Only completed assessments are considered.
- Previous classic assessments
- The skill matches on the individual scope item. A classic assessment that targets one of the current assessment's scope item records is considered.
- Documents
- The document picker is populated from the files attached directly to the assessment instance.
The Smart Assessment Response Assist scripted extension point
To customize the sources for a template category, create a script include that extends the following extension point:
sn_smart_ai_assist.SmartAsmtResponseAssistExtensionPoint
The extension point exposes four methods. Implement handles plus any method whose default you want to override; you don't have to override every method.
handles(templateCategoryId)- Returns a boolean. Use the supplied
templateCategoryId(sys ID of thesn_smart_asmt_template_categoryrecord) to decide whether this implementation should be applied to assessments in that category. Returntrueonly for the categories your implementation owns so that other implementations or the defaults handle the rest. getPreviousSmartAssessmentIdsForResponseAssist(assessmentId)- Returns a comma-separated string of smart assessment instance sys IDs that should be considered when fetching responses to previous questions. The default implementation returns the IDs filtered by the scope-item rule described earlier. Override this method to designate a different set of prior smart assessments.
getPreviousClassicAssessmentIdsForResponseAssist(assessmentId)- Returns an object with two properties:
recordIds— a comma-separated string of record sys IDs.recordRefField— the reference field onasmt_assessment_instance_questionto use for filtering. The value must be either'source_id'or'instance'.
recordRefField: 'source_id'. getDocumentIdsForResponseAssist(assessmentId)- Returns an array of document descriptor objects. Each descriptor identifies one attachment to add to the document picker and the source record the attachment belongs to. Each object has these properties:
attachmentId— sys ID of thesys_attachmentrecord.documentName— file name of the attachment.sourceTableName— name of the table the source record belongs to. Used withsourceIdto look up the source record's display value throughGlideRecordSecure, so the running user's ACLs gate the lookup. The resolved display value is then used as the source name shown to the user.sourceId— sys ID of the source record to display.
Override behavior
- Previous assessments (smart and classic)
- Replace. When your implementation's
handlesreturnstruefor a category, the IDs returned by the previous-assessment methods replace the default scope-item filtering for that category. If a method returns an empty result, that source produces no suggestions for the category — the default isn't applied as a fallback. This is intentional, so that a customer who wants to suppress a source can do so by returning an empty result. - Documents
- Additive. The files attached directly to the assessment instance are always offered in the document picker. The documents returned by
getDocumentIdsForResponseAssistare added on top of those attachments. Your implementation supplements the attached files; it doesn't replace them.
Example skeleton
The following script include is a starting point for an implementation. It returns the default values; replace the bodies of the methods you want to customize.
var SmartAsmtResponseAssistExtensionPoint = Class.create();
SmartAsmtResponseAssistExtensionPoint.prototype = {
initialize: function() {},
/**
* Function to check whether current implementation should be used for the given template category sysId.
* @param templateCategoryId - sysId of the template category (sn_smart_asmt_template_category).
* @returns {boolean}
*/
handles: function(templateCategoryId) {},
/**
* Returns comma-separated smart assessment instance sys_ids that should be considered
* while fetching response of previous questions for the given assessmentId.
* Default implementation filters by scope items matching the target assessment.
* @param {string} assessmentId - Assessment instance sys_id.
* @returns {string} Comma-separated smart assessment sys_ids.
*/
getPreviousSmartAssessmentIdsForResponseAssist: function(assessmentId) {
return new sn_smart_ai_assist.SmartAsmtResponseAssistUtils().getScopeItemFilteredIdsForAssessment(assessmentId);
},
/**
* Returns an object containing comma-separated sys_ids and the reference field
* to use for filtering previous question responses for the given assessmentId.
* Default implementation filters by scope item records matching the target assessment.
* @param {string} assessmentId - Assessment instance sys_id.
* @returns {Object} Object with the following properties:
* - {string} recordIds - Comma-separated record sys_ids.
* - {string} recordRefField - Reference field on asmt_assessment_instance_question
* used for filtering. Must be one of 'source_id' or 'instance'.
*/
getPreviousClassicAssessmentIdsForResponseAssist: function(assessmentId) {
return {
recordIds: new sn_smart_ai_assist.SmartAsmtResponseAssistUtils().getScopeRecordsFilteredIdsForClassicAssessment(assessmentId).join(','),
recordRefField: 'source_id'
};
},
/**
* Returns an array of document descriptors for response assist.
* Each descriptor identifies an attachment and the source record it belongs to.
* @param {string} assessmentId - Sys ID of the current Smart assessment instance (sn_smart_asmt_instance).
* @returns {Array<Object>} Array of document descriptor objects with the following properties:
* - {string} attachmentId - Sys ID of the sys_attachment record.
* - {string} documentName - File name of the attachment.
* - {string} sourceTableName - Name of the table the source record belongs to.
* - {string} sourceId - Sys ID of the source record to display to the user.
*/
getDocumentIdsForResponseAssist: function(assessmentId) {
return [];
},
type: 'SmartAsmtResponseAssistExtensionPoint'
};
After you create the script include, register it as an implementation of sn_smart_ai_assist.SmartAsmtResponseAssistExtensionPoint. For end-to-end steps on registering an implementation, see Using extension points to extend application functionality.