Custom Error Topic returns to main menu causes menu to be missing (Utah)

us44200
Tera Contributor

I am trying to create a custom error topic within the Virtual Agent that does not send the user to the Live Agent. Instead, what I would like to do is have the error topic generate an e-mail that details what topic the occurred and redirects the user back to the virtual agent main menu. The e-mail generation works perfectly and the error topic does redirect the user back to the main menu. However, if the user selects any topic from the menu, the topic will either not display a menu (if applicable) or it will prematurely end the conversation.

 

Error Topic Below:

us44200_0-1696875491486.png

The e-mail topic sends an e-mail after displaying an error message (removed email information below):

 

(function execute() {
    var topicName = JSON.parse(vaVars._topic_current).name;
    var getTranscriptLog = vaSystem.getTranscript();
    var sessionId = gs.getSession().getSessionID();

    var email = new GlideRecord('sys_email');

    email.type = 'send-ready';
    email.recipients = 'nameofbox@email.com';
    email.subject = "The Virtual Agent Triggered an Error: Topic " + topicName;
    email.body = 'An error occurred within the ' +'<b>' + topicName + '</b>' + ' <br> <br> Please review the conversation transcript below: <br> ' + getTranscriptLog;
    email.insert();

    var emailSender = new GlideEmailOutbound();

    emailSender.setSubject('Error Notification');
    emailSender.addRecipient('nameofbox@email.com');
    emailSender.setBody('An error occurred within the ' +'<b>' + topicName + '</b>' + ' <br> <br> Please review the conversation transcript below: <br> ' + getTranscriptLog);
    emailSender.send(); 
})()

 

next, we reset the topic:

 

(function execute() {
vaVars._topic_current = null;
})()

 

Last we send the user back to the main menu and a gs.debug check to ensure topic is null:

 

(function execute() {
vaSystem.switchTopic(vaVars._setup_explore_help_topic);
gs.debug(vaVars._topic_current);
})()

 

If a user selects yes to return back to the main menu, the VA menu is displayed appropriately. The issue is within a selected topic. For example: When testing out this error topic, I created a custom topic named Test Topic For Errors. This topic contains only 1 line of code which is test = test so it throws the custom error topic I created. When the custom error topic is hit, it will generate an email (confirmed in email logs), resets the vaVars._topic_current to null and redirects user back to the main menu. If lets say a user wants to check the status of one of their tickets, it allows the user to select their ticket. Once the ticket information is displayed, the menu of options should be as follows:

us44200_1-1696877065975.png

If the error topic is triggered and user wants to check the status of their ticket after being redirected back to the menu, this is what is happening instead (when ticket details are displayed):

us44200_2-1696877209512.png

The menu is not displayed and the topic immediately finishes and directs to the Anything Else topic.

 

I tested the error topic by removing the vaSystem.switchTopic(vaVars._setup_explore_help_topic);. If I do this, it will immediately hit the Anything Else topic once exiting the Error Topic. If the user checks the status of their ticket (in this example), instead of the bot asking for Anything Else after displaying the ticket information, it will display the ticket information and end the conversation:

us44200_3-1696877472788.png

I have also tried gs.getSession().terminate(); and  gs.getSession().start(); and the behavior still is the same.

 

I'm not sure what to do at this point. the OOB Error Handling Topic. was designed to send the user to the Live Agent. What I'm starting to wonder is if the Error Setup Topic in the default chat experience (in Conversational Interfaces) is supposed to just end the conversation rather than it going back to the main menu?

 

 

0 REPLIES 0