Virtual Agent - Available topics depending on different Service Portals
Hi there,
Most frequent usage of the Virtual Agent Service Portal widget will be on the default "sp" Service Portal. Though what if you are also using other Service Portals? And want to use the Virtual Agent Service Portal widget also on those Service Portals. Actually, no problemo! Works like a charm. Though, you might not want all Topics to be available on your "CAB Workbench" portal, or different Topics on your "Customer Support" portal. How to achieve this?!
Default behavior
By default, all Topics will be visible. For example, below a screenshot of the "Customer Support" portal.
Virtual Agent Designer - Condition
Looking at the previous screenshot, you might want to hide certain topics or show certain topics only on specific portals. The Virtual Agent Designer looks very limited on this, though actually you could utilize the Condition field for this. The Condition field is also described as: "The expression that must return true or false to display the topic to the user when searching from the client".
Virtual Agent scripts - Context variables
From the Docs:
"You can use variables in system parameters within the web client URL. These variables can be used anywhere in the conversation using the vaContext object. Use these options to create links to Virtual Agent with predefined variables.
https://.service-now.com/$sn-va-web-client-app.do?sysparm_city=rome
The example link contains a parameter, sysparm_city=rome. In addition to opening a Virtual Agent conversation, using this link creates a variable called city with a value of rome. This variable can be accessed in a script using vaContext.city."
Combining the Condition and Context variables
The Condition field and the Context variables should give us enough possibilities to make Topics portal specific. First, we should add a sysparm to the web client URL. For example: "sysparm_entity=csm". This sysparm would be available in the Condition field of the Virtual Agent Designer as "vaContext.entity".
The rest is almost common code, using an if condition to check the variable.
Condition (vaContext.entiry as example)
(function execute() {
if(!vaContext.entity) {
return true;
}
if(vaContext.entity != 'csm'
return true;
}
})()
Web client URL
https://.service-now.com/$sn-va-web-client-app.do?sysparm_entity=csm
The result should be that the Topic will not be visible for the user.
Obviously, you could change the condition to your logic. Maybe having a topic that should only be visible on the "Customer Support" portal for example. The code would just be:
Condition
(function execute() {
if(!vaContext.entity) {
return false;
}
if(vaContext.entity == 'csm'
return true;
}
})()
---
And that's it actually! A common question asked on the community summarized in this article.
| If this post helped you in any way, I would appreciate it if you hit bookmark or mark it as helpful.Interested in more articles, blogs, videos, and Share projects on Virtual Agent I published?- Virtual Agent |
|---|
Kind regards,
Mark
---
https://www.servicenow.com/community/virtual-agent-nlu-articles/virtual-agent-available-topics-depending-on-different-service/ta-p/2324998
