Virtual Agent - Exit carousel option
Hi there,
When using a Carrousel in the Virtual Agent, the user has to select one of the options. Would it possible to exit the carousel? Exit without selecting any of the options? If I understand the ServiceNow Support video, then this should be possible! On about minute 3 and 0 seconds in the video, it's mentioned: "If none of those are correct, the user can select none of the above".
Unfortunately though, achieving this is not an out-of-the-box feature of Virtual Agent. There is an enhancement request open to exit the carousel, but until then, maybe this could help you.
Out-of-the-box usage
The Carousel is set through scripting Carousel Item Expression within the User Input Carousel. The return value expects a JSON formatted code containing "Name", "Value", and "Body". Name containing the message to display, value the value, body the URL to the image. Ideally, this JSON is generated dynamically, through a GlideRecord query, etc..
For example, below the code used within out-of-the-box topic "Order an Item".
(function execute() {
var results = JSON.parse(vaVars.results);
var baseURL = gs.getProperty('glide.servlet.uri');
var options = [];
for (var i=0; i< results.length; i++) {
options.push(
{
'Name': results[i].title,
'Value': i + '',
'Body': baseURL + '/' + results[i].image
}
);
}
return options;
})()
Adding an exit option
So how to extend this with an option to exit the carousel? Well actually, this is pretty easy to achieve! Just add an additional option, JSON formatted. Looking at above example, just through options.push.
options.push(
{
'Name': gs.getMessage('Oops, this is not I was after'),
'Value': 'stop',
'Body': baseURL + '/' + 'qt-va-core-carousel-stop.jpg'
}
);
The result
---
And that's basically it!
Note: The image we used: https://sanquindev.service-now.com/sqn-va-core-carousel-stop.jpg
| 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-exit-carousel-option/ta-p/2319827
