• Jha Rishikesh
  • NEWBIE
  • 25 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I have a pre-chat form that contains a drop-down list. On the basis of drop-down list value, I want to rout it to skill group assoicated with that. I have created a button and associated it with the skill group.

I created an SF page and used the snap-in deployment code. As per the user guide, I uncommented the embedded_svc.settings.directToButtonRouting function and wrote my logic to return buttonID. When I click on the form button, it goes to this function however, it is not routing to the correct button.
Script is as below

<apex:page>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"/>
<style type='text/css'>
    .embeddedServiceHelpButton .helpButton .uiButton { background-color: #005290; font-family: "Salesforce Sans", sans-serif; }
    .embeddedServiceHelpButton .helpButton .uiButton:focus { outline: 1px solid #005290; }
    @font-face {
    font-family: 'Salesforce Sans';
    src: url('https://www.sfdcstatic.com/system/shared/common/assets/fonts/SalesforceSans/SalesforceSans-Regular.woff') format('woff'),
    url('https://www.sfdcstatic.com/system/shared/common/assets/fonts/SalesforceSans/SalesforceSans-Regular.ttf') format('truetype');
    }
</style>

<script type='text/javascript' src='https://service.force.com/embeddedservice/5.0/esw.min.js'></script>
<script type='text/javascript'>
var initESW = function(gslbBaseURL) {
embedded_svc.settings.displayHelpButton = true; //Or false
embedded_svc.settings.language = ''; //For example, enter 'en' or 'en-US'

//embedded_svc.settings.defaultMinimizedText = '...'; //(Defaults to Chat with an Expert)
//embedded_svc.settings.disabledMinimizedText = '...'; //(Defaults to Agent Offline)

//embedded_svc.settings.loadingText = ''; //(Defaults to Loading)
//embedded_svc.settings.storageDomain = 'yourdomain.com'; //(Sets the domain for your deployment so that visitors can navigate subdomains during a chat session)

embedded_svc.settings.displayHelpButton = "true";

// Settings for Live Agent
embedded_svc.settings.directToButtonRouting = function(prechatFormData) {
// Dynamically changes the button ID based on what the visitor enters in the pre-chat form.
// Returns a valid button ID.
var btnID;
    alert(prechatFormData[3].value);
    if(prechatFormData[3].value =="xyz") btnID ="5730D0000008OIK";
    if(prechatFormData[3].value =="abc") btnID ="5730D0000008OIF";
    
   
};
//embedded_svc.settings.prepopulatedPrechatFields = {}; //Sets the auto-population of pre-chat form fields
//embedded_svc.settings.fallbackRouting = []; //An array of button IDs, user IDs, or userId_buttonId
//embedded_svc.settings.offlineSupportMinimizedText = '...'; //(Defaults to Contact Us)

embedded_svc.settings.enabledFeatures = ['LiveAgent'];
embedded_svc.settings.entryFeature = 'LiveAgent';

embedded_svc.init('https://xxx--RJDev.my.salesforce.com', 'https://rjdev-ems.cs106.force.com/xxx', gslbBaseURL, '00D0D0000008aJE', 'xxx', 
{ baseLiveAgentContentURL: 'https://c.la1-c1cs-cdg.salesforceliveagent.com/content', 
deploymentId: '5720D0000008OI5', 
buttonId: '5730D0000008OI5', 
baseLiveAgentURL: 'https://d.la1-c1cs-cdg.salesforceliveagent.com/chat', 
eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I0D0000000006UAA_164c6b6d5f2', isOfflineSupportEnabled: true}); };
if (!window.embedded_svc) { var s = document.createElement('script'); alert("rishi if");
s.setAttribute('src', 'https://xxx--RJDev.my.salesforce.com/embeddedservice/5.0/esw.min.js'); 
s.onload = function() { initESW(null); }; document.body.appendChild(s); } 
else { initESW('https://service.force.com'); alert("rishi else"); }</script>
</apex:page>
 
How can I route the chat to different group of agents based on a value entered in the pre-chat form on a Napli community? 

I have the snap in working and it does go to an agent but I don't see how I can route it.  I see where you can enter the values that users can paste on a web page to dynamical change the button.  I don't have that option in community.