Restrict a Virtual Agent Topic based on User Criteria
Import
·
Apr 05, 2022
·
article
A request was received to create a Virtual agent topic that only specific users could see based on User Criteria. This is the same user criteria used in the Knowledge base and Service Catalog to restrict items there.
After building my Virtual Agent Conversation I navigated to the Properties tab of the conversation, selected 'Script' next to the Condition label and clicked the Add Script box.
In the box that pops up I added the following script (updating the with the sys_id from the [user_criteria] table.
(function execute() {
var UCSysid = '<insertSysID>'; //sysid of the user criteria required
//Get all user criteria sys_ids
var userCriteria = SNC.UserCriteriaLoader.getAllUserCriteria();
//If user is added to UCSysid variable User Criteria, set to true
if (userCriteria.indexOf(UCSysid) > -1) {
return true;
}
else{
return false;
}
})()
After clicking Publish, the topic will only be displayed to the logged in users with that User criteria.
View original source
https://www.servicenow.com/community/virtual-agent-nlu-articles/restrict-a-virtual-agent-topic-based-on-user-criteria/ta-p/2305835