
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
11-08-2020 10:00 PM - edited 08-18-2024 06:35 AM
Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
What is shared in this article, might not be best practice. Just sharing this to explore possibilities, find openings in ServiceNow, and have a mindset that your imagination is your limitation. |
Hi there,
With the Orlando release, ServiceNow introduced reusable Topic Blocks for Virtual Agent. Reusable components, which you could compare with Subflows or Actions. A really nice feature that helps build Topics smarter, faster, more consistent and manageable. Also less scripting knowledge is needed when working in Topics, because this logic has been set up in the Topic Block.
In a few short articles, I'll share some of the reusable Topic Blocks I've set up. These Topic Blocks can also be downloaded from Share.
Topic Blocks
A short recap:
Pre-Orlando
Basically pre-Orlando if we would have a repetitive group of steps for multiple Topics or even within a Topic, we simply had to duplicate them/build them over and over. There was no possibility to set up something like a Subflow. Well, maybe a small workaround would be doable for some situations, using vaSystem.switchTopic() or vaSystem.topicDiscovery().
Orlando
With the Orlando reusable a repetitive group of steps for multiple Topics or even within a Topic, can be placed within a "topic blocks". The short explanation of Topic Blocks according to the Docs site:
"A Topic block is basically a Subflow that performs certain actions or conversational tasks in a Topic."
Wait N Seconds
I don't use this though often, though do like the concept: Having a possibility to 'pause' the topic for a few seconds. There is no out-of-the-box utility for this, so we do need to script this. I also tried with simpler methods like gs.sleep(), though no luck there.
So are you going to script this in all of your Topics, maybe even several times in a Topic, or are you going to make this more generic? Using a Script Include or… reusable Topic Blocks!
If we would script a wait, we could use something like:
var seconds = 1;
var date_time = new Date();
date_time.setTime(date_time.getTime() + (1000 * parseInt(seconds)));
while(new Date().getTime() < date_time.getTime());
Translating this into Virtual Agent script:
(function execute() {
var date_time = new Date();
date_time.setTime(date_time.getTime() + (1000 * parseInt(vaInputs.seconds)));
while(new Date().getTime() < date_time.getTime());
})()
Added a vaInputs for the seconds. vaInputs because we could easily use this as a mandatory Input Parameter on the Topic Block.
Result
Above steps would result in a short Topic Block like:
Now we can simply use this Topic Block in Topics using the Topic Block utility.
The Topic Block Properties would ask you to supply seconds (mandatory). This would simply be the number of seconds the Wait should last.
The ultimate result would be that adding a wait for a specified number of seconds, now is just limited to a drag and droppable Utility on which you only have to select the Topic Block name and add an integer value for the number of seconds. Highly reusable, maintainable, no scripting anymore, etc..
Share
An Update Set with this Topic Block can be downloaded from Share:
- Virtual Agent Topic Block: Wait N Seconds
---
And that's it actually. Hope you like it. If any questions, remarks or other ideas for Topic Blocks, let me know!
C |
If this content helped you, I would appreciate it if you hit bookmark or mark it as helpful.
Interested in more Articles, Blogs, Videos, Podcasts, Share projects I shared/participated in? |
Kind regards,
Mark Roethof
ServiceNow Technical Consultant @ Quint Technology
1x ServiceNow Developer MVP
1x ServiceNow Community MVP
---
- 2,545 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Please don't do this. The servicenow instance has 2 dedicated server threads for VA chat. When a chat is inside a script, that dedicated thread is executing. This script block will eat up one of those threads and also the processor as it will cycle through the computation over and over. There is a future feature in the books to asynchronously wait. This is a synchronous blocking wait. gs.sleep would do the relatively same thing as well--so please do not use that either. 2 simultaneous executions of this chat would effectively take this node offline. Please ping/champion the VA Product team for more specifics as to delivery time of this feature. This is a common case task problem. Thanks and sorry to be the bearer of bad news.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi there,
Will look into this. Though do be aware, something similar like this is used in some out-of-the-box topics.
Kind regards,
Mark
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Please send me those topics if you find them, so I can track down those owners. Also please reach out to

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I have tried looking into custom controls. Though unfortunately, some parts concerning Virtual Agent don't look to be publicly available. Therefore using Virtual Agent Custom Control testbed as descripted on the Docs doesn't work.
Kind regards,
Mark
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This is a great thread.
Inserting an artificial pause into a virtual agent response is a fantastic visual queue for users that something is happening while not overloading them with text. If the virtual agent has a lot to say, break it up with these pauses (similar to the typing icon with Iphone) so the user can digest the text and not feel rushed or overwhelmed. Another technique is to insert one button titled "Go on" or something like that, so a user can control the speed of the response.