- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 11-13-2018 02:38 PM
In preparation for TechNow Episode 58 - Go from Conversation to Resolution with Virtual Agent, I spent quite a bit of time exploring Virtual Agent in the London release. During my explorations, I stumbled several times and learned quite a few lessons along the way. While I'll summarize those tomorrow during the TechNow episode, I wanted to post something a bit more detailed as well.
Lessons Learned from CreatorCon 18 Labs
I started my explorations by re-doing the fantastic K18 CreatorCon labs, A Walkthrough on Building and Deploying a ChatBot Across Multiple Channels and Advanced Techniques for Creating High Usability Chatbot Conversations. These guides are available ONLY to people who attended K18 CreatorCon. If you try to do the same, keep the following points in mind:
- Referencing Variables
The K18 CreatorCon labs were based on a very early build of VA. The methods for referencing variables has changed since then.
|
Variable Type |
K18 Lab Guide Convention |
London Release Convention |
|
User Input Variables |
Vars. |
vaInputs. |
|
Script Variables |
QVars. |
vaVars. |
- Information about the current user
The labs use a convention in the Start node to welcome the user by name. This is not documented yet, but very handy. In here, {{user}} is actually a glide object that can be dot-walked. So, if you want to refer to the user by their first name, you can use {{user.first_name}}. If you want to display the user's department head, you can use {{user.department.dept_head}}.
Select Multiple
When creating a delegate record in ServiceNow, there are several options to determine the delegate's authority. In VA, I wanted to be able to have the user select multiple options in a single interaction. It doesn't look like that's supported yet. Based on the documentation I found and examining the existing conversations for ITSM, the way to handle this is to create a loop asking the user if they want to select another until they say that they do not want to select another.
Decisions
In the current release, you need to write code to control decision branches. I found a few different conventions used in various places. I found that some required a lot of mental effort to keep straight in my head. The most straightforward, though, is to write a condition that sets a variable to say whether the branch applies (and should be followed). This required the least amount of cognitive load.
For example, which one of these is easiest to glance at to know if the decision branch should be followed?
|
Option 1 |
Option 2 |
|
return parseInt(vaVars.incident_count) == 0 && parseInt(vaVars.requested_item_count) == 0; |
var applies = (parseInt(vaVars.incident_count) == 0 && parseInt(vaVars.requested_item_count) == 0) ? true : false; return applies; |
For me, Option 2 is the clear winner and the pattern I try to follow every time. For bonus points, a comment would be nice. Option 1 makes my brain hurt a bit when trying to debug.
Sample Code
The sample code provided in VA is fantastic! HOWEVER, If you do decide to use it as a basis for your custom code, make sure to not only uncomment the sample code, but also delete the redundant code! I wasted hours trying to find my error. My query was fine and returned the correct data when I tested it in background scripts, but I had forgotten to remove the two tiny little lines of code that emptied out the data I was returning and the redundant 'return' statement.
Reference Choice fields - the easy way!
The sample code above is related to the Reference Choice field node that queries data from a ServiceNow table. In there, you should see line: gr.addEncodedQuery('<query>');
I'm sure this is old news to many in this forum, but, for those of you who do not have coding backgrounds, this is one to save for future use.
- Navigate to the table.
- Set the filter to show the data you wish to return in your query.
- Right-click on the LAST node in the filter and select Copy query.
- Paste that between the single quotes in the gr.addEncodedQuery(' ') method.
This way, you've already validated that the data set is correct.
THEN (and very importantly):
- Find the line in the sample code that pushes options to the control. (Line 10 in the screenshot above.)
- Replace short_description with a field that makes sense given the table you're querying. (For querying the users table, 'name' is a field that exists and would make sense to display.)
Debugging
A few times, I encountered unrecoverable errors and had a tough time finding out which node was the cause. In such cases, I would typically use the process of elimination to isolate the error. However, there is not currently a way to set nodes as active or inactive. The only way to do this is to delete nodes. In those situations, I found that the best way to both isolate the issue and avoid re-work is to duplicate the topic and use a process of elimination in the copy. Then, once I've found and fixed the error, I can replicate the fix in my master topic and delete the copy.
I have also found myself re-ordering nodes to put the one I'm troubleshooting as close to the Start as possible to speed up the testing when working with a long conversation.
_______________
I hope some of you find this helpful as you explore Virtual Agent. If you do, please leave a comment to let me know. I'd love to hear some of your tips and tricks as well!
- 1,480 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Stacey,
I get an error message "An unrecoverable error message occured.".After providing the short description to check the Open IT Status. I get an option to create an incident using "Did any of these articles resolve your queries". i choose 'No' for that query. and I have chosen the urgency for creating an incidnet. I do get the acknowledgement message "Alright, I've opened your incident and a technician will be assigned." which is present in the designer for 'pen IT Status' But after that i receive a message "An unrecoverable error has occurred.". Please let me know how to solve this issue. I need to avoid the error message which appears after the acknowledgement.