Can I force a Virtual Agent to use a specific topic on a certain portal? Yes.
Today our Servicenow group was required to quickly create a "COVID Knowledge" Virtual Agent topic, and make it display on a portal page. This had to be done for a demo, and we could not tamper with the existing topic being used on our main Service Portal. So the requirement sounded something like this: 1) while having an existing virtual agent running on a certain portal with one topic, implement a second Virtual Agent on a different portal with a different topic, 2) without touching the "main" virtual agent topic configuration.
You could also restate it something like, "Can I put a Virtual Agent widget on a new portal and force it to run only a certain topic?"
Believe it or not, for someone new to Virtual Agent it was very hard to find the answer to this. I was forwarded links to terrific pages in this Community, with lots of links and a ton of information, but this just created a bewildering sea of information and I struggled to not be swept away. My technical support Rep showed me a functioning widget on a page, but he said he had customized the widget and he neither remembered how he did it, nor had time today to give me his code.
After seeing an elusive "sample" my first thought was to put an instance of Virtual Agent Service Portal Widget on a portal page and hard code the topic= into the instance options variable:
"va_url_params": {
"value": "sysparm_topic=f3a2ccb31b39ac907d48cbbe034bcb3a&sysparm_skip_load_history=true",
"displayValue": ""
}
After all, this va_url_params was already in the instance options, and it seemed like the simple way. But it didn't work. It was ignored by the widget. I asked questions in several places online today and searched the main Servicenow Community but was only faced with the question, "...If there are hundreds of VA articles about everything under the sun, why does no one mention a working model of how to do this?" Usually when find yourself in that situation, it means you are doing it wrong--asking the wrong question. But there is no one smart enough or available to tell you. So maybe I *AM* doing it wrong. I have the feeling maybe the recommended way is to have a single VA and start with a topic and then branch to other topics depending on some kind of answer from customer. But I was not allowed to do that today, I just needed to FORCE a new portal immediately to a specific topic, while leaving the existing VA completely untouched.
The solution I found was this: set the property for the topic directly in a new Agent Chat configuration which contains only the desired portal.
We had an existing Agent Chat configuration, "Service Portal Login Chat". It was being forced onto our existing site by being set as a Setup Topic, and configured as the greeting. So technically the person who configured our existing portal didn't know how to specify a topic either. But the need had not arisen and they just "hit it with a hammer."
I added a new Agent Chat configuration, "Web Center Agent Chat," set for only the new portal. Then I configured the properties for topic and skip_load_history:
(function($sp) {
var portalGr = $sp.getPortalRecord();
return {
live_agent_queue: $sp.getDisplayValue('sp_chat_queue'),
skip_load_history: true,
topic: 'f3a2ccb31b39ac907d48cbbe034bcb3a' //mine, use your own!
};
})($sp);
I got this idea when watching a Virtual Agent Academy video from Mark Roethof, when I saw him put the skip_load_history property here. Since I had previously found articles suggesting topic and skip_load_history could be passed as URL params but I failed to make them work via widget instance options, my heart leapt when I came to 08:48 in the video.
Since I had spent all day trying to find someone who knew how to force a topic on the widget like this, I had to share this article and hopefully it will help someone else. Hats off to you Mark Roethof.
(Note: of course I did slightly touch the existing Service Portal VA configuration, once I understood the solution. I set the topic on its Agent Chat configuration the same way I did for the new portal. Then I removed it from being the General Settings greeting. BOOM. Both portals using their separate topics.)
https://www.servicenow.com/community/virtual-agent-nlu-articles/can-i-force-a-virtual-agent-to-use-a-specific-topic-on-a-certain/ta-p/2307022