We are trying to implement Live Chat into our Salesforce environment using the sales use case rather than the service use case being the creation of leads.

For this we have set up a pre-chat form in which we have a pick-list value that users will select which will drive who the case is going to so if i pick the pick list value "Skill 1" i want the chat to route in Omni-Channel to an online user who has the skill "Skill 1". We have set up omni-channel in our org and I have created service resources for our users will skills assigned.

What i have read to do for this is to have different chat buttons for each skill

embedded_svc.settings.directToButtonRouting = function(prechatFormData) {
    if (prechatFormData[4].value === "Skill 1")
        return "2F5733F000000CgVZ";

if the user picks a specific value it will route to the correct person based upon the skill that they have assigned to them in their service resource. This to date has not been working and it seems to be just following the omni-channel queues routing that we have previously had working in our environment and connecting to the users in the queue we have set up rather than the skill based routing we are trying to implement.

Does anyone have any insight as to why this is not working as expected?

Below is the full chat deployment Code

<style type='text/css'>
    .embeddedServiceHelpButton .helpButton .uiButton {
        background-color: #005290;
        font-family: "Arial", sans-serif;
    .embeddedServiceHelpButton .helpButton .uiButton:focus {
        outline: 1px solid #005290;

<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.directToButtonRouting = function(prechatFormData) {
    if (prechatFormData[4].value === "Skill 1")
        return "2F5733F000000CgVZ";
        //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)

        // Settings for Chat
        //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.
        //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';

                baseLiveAgentContentURL: 'https://c.la2-c1cs-iad.salesforceliveagent.com/content',
                deploymentId: '5723F000000CfEw',
                buttonId: '5733F000000CgWr',
                baseLiveAgentURL: 'https://d.la2-c1cs-iad.salesforceliveagent.com/chat',
                eswLiveAgentDevName: 'Edel_Live_Chat_Demo',
                isOfflineSupportEnabled: false

    if (!window.embedded_svc) {
        var s = document.createElement('script');
        s.setAttribute('src', 'https://kerry--full.my.salesforce.com/embeddedservice/5.0/esw.min.js');
        s.onload = function() {
    } else {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.