Agent Chat and Pre Chat Survey - Queue sorting based on answers
Hi All!
In this article I will explain how you can create a Pre-Chat Survey and use the answers in a Queue filter.
Problem: Sort Agent Chat Queue by language choice of the user.
0. Make sure Agent Chat plugin is installed
1. Create a Survey and make sure to mark it as a Pre-Chat Survey in the options
2. In Survey Designer, create a Choice question for Language Choice
If Pre-Chat survey is set to true, then you will see the Context field here which will show all fields related to Interaction. From there select Language
In Choices you can type the display value. Keep in mind the display value is used later in script.
3. Link the Survey to the Agent Chat.
Conversational Interfaces -> Pre-Chat Survey -> New
Create a New Chat Survey and set the Survey you created as the reference
4. Create a Queue item
Advanced Work Assignment -> Queues
Make sure to set the Service Channel to Chat, Condition mode to Advanced. In the Advanced code we use the Display Value from the choice variable we created in the Survey in Step 2. Also make sure to have Assignment Eligibility set in order to ensure a group is set for the language.
(function executeCondition(/* glide record */ current) {
var contextTable = current.getValue('context_table');
var interactionBlobRecord = new GlideRecord(contextTable);
interactionBlobRecord.addQuery('sys_id',current.getValue('context_document'));
interactionBlobRecord.query();
if(interactionBlobRecord.next()){
var jsonBlob = JSON.parse(interactionBlobRecord.getValue('value'));
if(jsonBlob.liveagent_language == 'English')
return true;
}
return false;
})(current);
The field is called from a table that stores the interaction as json
/interaction_json_blob_list.do Use this for troubleshooting.
6. Impersonate someone from the group, in this case "IT Support". Make sure the user has awa_agent role and log into workspace to receive the chat. Other user from /sp can initiate the dialogue and voila
Oh, and Agent Chat has to be enabled on the Service Portal too of course
Let me know if any questions below
https://www.servicenow.com/community/agent-chat-routing-and-sidebar/agent-chat-and-pre-chat-survey-queue-sorting-based-on-answers/ta-p/2300442