Embedded services used to setup Chat window for community or external website. When Customer want to hang with Agents, Embedded services helps to redirect customers. Once it is redirected it will create Chat transcript, Contact and case records.
The Agent connecting happening using Chat button. This chat button is adding to embedded service to redirect customer to agents available in Chat Button. So every time it will redirect to same Chat button with added Queue.
How to redirect to different Chat buttons based on scenario ?
Coming to the point, we can achieve using Snippet code which is generated from Embedded service. Really?? How ??
We have method called “directToButtonRouting” – This helps to redirect customers to different Queues based on values added in prechatform.
embedded_svc.settings.directToButtonRouting = function(prechatFormData) {
// Discuss prechatFormData in detail below
var chatbuttonId = ‘573********’;
var chatbuttonId_1 = ‘573********’;
for (var i = 1; i < prechatFormData.length; i++) {
if(prechatFormData[i].label === “Email”){
if (prechatFormData[i].value === “info@learnown.com”){
return chatbuttonId;
}else{
return chatbuttonId_1;
}
}
}
}
prechatFormData – prechatFormData will return the fileds data which is added in Embeddedservices Chat settings section. Above script identify the Email field from Json and retrieve Value if it match the value it will redirect to the chatbuttonId Queue else if it is not matched then it redirect to the chatbuttonId_1.
[
{
“label”: “First Name”,
“value”: “Learn”,
“name”: “FirstName”,
“transcriptFields”: [
“FirstName”
]
},{
“label”: “Last Name”,
“value”: “own”,
“name”: “LastName”,
“transcriptFields”: [
“LastName”
]
},{
“label”: “Email”,
“value”: “info@learnown.com”,
“name”: “Email”,
“transcriptFields”: [
“Email”
]
},{
“label”: “Account Name”,
“value”: “001****”,
“name”: “AccountName__c”,
“transcriptFields”: [
“Account”
],
“displayToAgent”: false
},{
“label”: “Contact Name”,
“value”: “003*******”,
“name”: “ContactName__c”,
“transcriptFields”: [
“Contact”
],
“displayToAgent”: false
}
]
Note : Use”embedded_svc.snippetSettingsFile.directToButtonRouting” instead of “embedded_svc.settings.directToButtonRouting” to apply to communities in snippet file.
