- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎04-30-2019 10:27 AM
Hi All,
So I was tasked with building a default topic for virtual agent, we set it as default, however when it ended it always kicked us to the default servicenow "choose your topic" flow... I needed to find a way around this. Digging through ServiceNows _handler workflow I found the following command:
(function execute() {
var options = [];
var gr = new GlideRecord('sys_cs_topic')
gr.addEncodedQuery('active=true^is_system_topic=false^nameNOT LIKE_PRVW')
gr.query();
while (gr.next()) {
options.push({ 'value': gr.name.getDisplayValue(), 'label': gs.getMessage(gr.name) });
}
return options;
})()
This allows the user to choose the topic which then gets handled by a Script action to perform the redirect running the following code:
(function execute() {
vaSystem.switchTopic(vaInputs.topic_list)
})()
I had seen a few people ask this question, so just wanted to provide what I had found as a work around.
**** THIS WAS DISCOVERED IN MADRID, PER COMMENTS BELOW IT DOES NOT APPEAR TO FUNCTION IN LONDON****
- 17,558 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This is really awesome, great finding! Also very easy to apply with your description, got it up and running within 2 minutes.
Though, curious about how you found this? How was your search about this? You do mention something with ServiceNow _handler?
Asking this because I would like to know what possibilities their would be with using vaInput, vaUser, vaSystem, etc.. The documentation on this is very limited. I did raise a Hi ticket about this, but they just ditched me off 😞
Again, great finding!
Kind regards,
Mark
---
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Another question. When you are saying "default start topic". Do you mean you actually have a custom topic which the bot just starts with? So did you find a way to not having the bot start with the default sentences and the Show Me Everything button?
Kind regards,
Mark
---
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Is there a way either to hide the 'Show Me Everything' button or change the label of it?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Mark,
You are exactly correct, in setting this is how I found out about the _handler topic, and allows you to bypass the "show me everything". The docs site has some missing information but I found a hi article KB0714728 that specified which specific table to obtain the sys_id from (sys_cs_topic), this is where I found the _handler topic and was able to browse it and find the specific command.
I know it's in the KB but a picture makes for 1000 words, on the widget instance you specify "sysparm_topic=sys_id" URL params, I've also added sysparm_skip_load_history=true, which makes it so when someone re-navigates to SP or refreshes and accesses the VA it doesn't show their previous conversation. I felt it just made the interaction tidier.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Rasmita,
I did this by setting a default topic, in doing so it completely bypasses that initial un-editable interaction. I explain how I did this in my reply above to Mark Ragavan.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
O this is absolutely brilliant. I knew you could go directly to a topic, but I only used this so far for testing purposes... but now with the switchTopic, really nice!!!
Thanks again!
Kind regards,
Mark
---
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
No problem, I found this greatly increased our usability, the only thing I would love to find now is a way to pass variables between topics.
I think the one thing I haven't tested yet is use of the scratchpad to see if that will function with VA.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Simon, this is a great find. Thanks for sharing.
I am curious though, does your lookup on the sys_cs_topic table take into consideration any roles based or scripted topic restrictions? The OOB topic selector makes it very easy to show/hide topics based on roles or a scripted condition.
I will test this as well, but how does the system respond if you try to switch topics but the user doesn't meet the criteria for the new topic.
Thanks again.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi there,
No the roles are not considered. You will see all the topics. Though, if you don't have the role, the topic can't be opened. Probably queriyng on something with hasRoles would do. Also you can select the "New conversation", which will not return to your custom start topic.
So some flaws to overcome. But this gives possibilities.
Kind regards,
Mark
---
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This is great finding Simon. SNOW HI is not able to provide these kind of solutions.Thanks for sharing this.
However, I am not able to switch to another topic. I did implement as above.
With the above code, I could get the list of active topics.
But , after selecting the topic , it is not triggering the flow. The chat abruptly ends there. It seems to me that the switchTopic function is not working as expected? Or, is there any other way to achieve this?Am I missing something?
Also, with the below link, I could set the default topic but when I start a new conversation , it shows the 'Show Me Everything' button again. Is there a way to permanently get rid of the button when the chat starts?
I want
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Rasmita - I had the same issues when trying to implement Simon's findings and I believe this functionality may only be available in Madrid (i am not sure which version you are on, but it did not work for me in London).
When you navigate to sys_cs_topic do you see a topic named "_handler"? If no, then this feature will not work.
I requested a developer instance on Madrid and that handler topic was available, and the scripts Simon provided worked.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
After testing this I wanted to document one finding, just as an FYI. The sys_cs_conversation table stores an entry for each user interaction with VA; tracking the status of the interaction and the topic they interacted with. From a reporting standpoint, this can be very helpful to see which topics are being used the most, by which users, etc.. However, it appears that when you use this SwitchTopic() script, it doesn't log those transitions the same way.
When you switch from one topic to another, all the activity in the second topic is stored within the first session (if that makes sense). Using the approach Simon mentioned (creating a new default topic), all the interactions will only show that default topic. It is possible to report at the individual message level to extract which topic someone selected, but it does make that part a little more difficult.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Eric - Thank you for your response .
I am using London and as you mentioned I am not able to see the _handler topic in my version.
I will try this out in Madrid very soon.
And the finding related to the conversation table is truly helpful for reporting!!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
He Eric,
Mark is correct this does not take roles in to consideration at this time. I was building this out for a POC for basic incident and knowledge base handling. Again I believe as Mark suggested with hasRoles on the glide record you should be able to resolve this.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Simon,
Does vaSystem.switchTopic work in london release?
I'm using something like this vaSystem.switchTopic('Topic Name');
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Hardit,
Unfortunately that I'm not sure of myself, I discovered and tested this in Madrid. However in looking at the replies above it looks like this doesn't exist in London.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Simon,
Thank you for your reply. I guess it's not in London. The documentation on Virtual Agent is really limited.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Simon, your advice is brilliant and easy to follow, thanks!
I'm wondering if you've made any progress on passing variables between topics? Would certainly make a lot of lives easier 🙂
Cheers!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Great advise 🙂 I was able to easily make sure that user starts with My topic and not the default!
However, when they click on "New Conversation" it doesn't point them back to my flow (which is hardcoded in the VA widget now) but to the "Show everything" default one 😞 any idea how to change this?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi there,
Unfortunately, that's one of the bugs we have also. Haven't found a solution for this. Do know that this is changing completely with New York!
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks Mark!
This song comes to mind "New York... there's nothing you can't do" ;)!
Is this particular issue logged/a known bug by any chance? Or maybe the fix is documented for the new release? I wasn't able to find a # on this.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Well it's not an actual ServiceNow bug in my opinion, it's just because we want to have the behavior different. Though with New York there are several System Topics, which with the flow of topics also changes.
For example with New York you can start with a Greetings topic, which is followed by a selected topic, then Anything else topic, Survey topic, etc..
If no Anything else topic, Survey topic will automatically follow. If no Survey topic, the chat will just end, etc..
For all these 'Setup Topics', there are out-of-the-box topics. Though you can still modify it. For example, the Greetings topic is not personal, though you could change it (or make your own) which starts with "Hi " + vaInputs.user.first_name;
Nice to know, the out-of-the-box Anything Else Topic uses the vaSystem.switchTopic which Simon described in this article 🙂
Kind regards,
Mark
---
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This worked perfect, Though i found a problem if any body has figured out already, i can't seem to end the conversation in the middle of it, the end conversation button stays disable? any solution for this?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Is it possible to switch topic and send parameter to newly opened topic?
My use case: in the end of "Open Ticket" topic I want to ask user if he want's to do something else with created ticket - Escalate Ticket or Add a Comment, etc.
Once selected, the new topic for "Escalation" should start but it should take the parameter - sys_id of record created in previous "Open Ticket" topic. Is that possible?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi there,
Using switchTopic or topicDiscovery: No there's no option for a second parameter to pass something like an "input parameter". What you might do: using GlideSession. This works fine within Virtual Agent.
Only thing to be aware of: when using the topic picker, the GlideSession ID changes. In all other cases, haven't experienced any issues.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello, nowadays there is any method to have a "back to previous topic" button in chat?
For example if I entered in a topic under "HR" topic block, for example "Bonuses", and realize that I should be entered in "Goals". I have to get back to menu, there is no way to get back to "HR" topic block, and choose "Goals" menu?
PS: I'm in Paris release
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi all,
I'm using Utah release and I have a question about this subject:
Does anyone know if when we use this command: vaSystem.switchTopic('Topic Name'); are we able to access another topic not entering from the top but accessing for example in the middle directly referring a variable?
Thank you