function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
regidsitesregidsites 

embedded_svc.menu.settings.directToButtonRouting Possible?

I have used the following code before for Live Chat and it's working fine to direct to a button ID based on the Pre chat question customer answers. Now, this code seems to be not working when I started using the new 'Channel Menu'. Has anyone found a solution to direct to button routing if use a channel menu?

embedded_svc.settings.directToButtonRouting = function(prechatFormData) { if (prechatFormData[3].value === 'English') return 'XXXX000000XYYY'; if (prechatFormData[3].value === 'Spanish') return 'XXXXX000000XAAA'; if (prechatFormData[3].value === 'French') return 'XXXX000000XBBB'; };

I was getting "Uncaught TypeError: Cannot set properties of undefined (setting 'directToButtonRouting') at initESW". And I was getting this only for Channel Menu code
Best Answer chosen by regidsites
SwethaSwetha (Salesforce Developers) 
HI Regidsites,
>> Please check if the code used in the static resource is formatted correctly. You need to use the format mentioned here
https://help.salesforce.com/articleView?id=sf.embedded_menu_static_examples.htm&type=5

Experience site: Example code
window._snapinsSnippetSettingsFile = (function() {
console.log("Snippet settings file loaded."); // Logs that the snippet settings file was loaded successfully

embedded_svc.menu.snippetSettingsFile = {
//"chat"=Menu Item Name
chat: {
settings: {
directToButtonRouting : function(prechatFormData) {
if (prechatFormData[0].value === "ale"){
console.log("direct to button");
return "573B0000000PteA";
}else{
console.log("direct")
return "573B0000000Tl2S";
}
}

}
}
};

})();
>>At the moment this functionality is not available for VF pages. Please consider logging an Idea with Salesforce IdeaExchange(https://trailblazer.salesforce.com/ideaSearch ) so that the salesforce product development team can consider implementing this feature based on number of upvotes.

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you

All Answers

SwethaSwetha (Salesforce Developers) 
HI Regidsites,
>> Please check if the code used in the static resource is formatted correctly. You need to use the format mentioned here
https://help.salesforce.com/articleView?id=sf.embedded_menu_static_examples.htm&type=5

Experience site: Example code
window._snapinsSnippetSettingsFile = (function() {
console.log("Snippet settings file loaded."); // Logs that the snippet settings file was loaded successfully

embedded_svc.menu.snippetSettingsFile = {
//"chat"=Menu Item Name
chat: {
settings: {
directToButtonRouting : function(prechatFormData) {
if (prechatFormData[0].value === "ale"){
console.log("direct to button");
return "573B0000000PteA";
}else{
console.log("direct")
return "573B0000000Tl2S";
}
}

}
}
};

})();
>>At the moment this functionality is not available for VF pages. Please consider logging an Idea with Salesforce IdeaExchange(https://trailblazer.salesforce.com/ideaSearch ) so that the salesforce product development team can consider implementing this feature based on number of upvotes.

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
This was selected as the best answer
regidsitesregidsites
@swetha Thanks. At the moment this functionality is not available for VF pages seems to be the answer. But, is there a way we can pass the pre chat data to Transcript object when using "Channel Menu"'s Live Chat?
SwethaSwetha (Salesforce Developers) 
Checking...