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
Tena Wolver 39Tena Wolver 39 

snap-in chat community route to different agents based on pre-chat form

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.
Kristen PatzKristen Patz
Have you found any resolution to this? We are facing the same problem where the documentation shows direct to button routing, but we are unable to determine how to use that with the snap-ins component in the Napili Community.
Tena Wolver 39Tena Wolver 39
not for communities only for when using a vfp with snap.  
Jha RishikeshJha Rishikesh
Hello,

Is there any way to use the routing using vfp and snap-in? I have set up as per the developer guide. but seems routing in not working properly. Any help would be greatly appreciated.
Nirdesh Kumar SystemNirdesh Kumar System
Hello,
I am also looking for the solution to route the chat based on pre-chat form. Did you find any solution?
 
Jha RishikeshJha Rishikesh
@nirdesh Are you using Snap-in or standard chat button routing?
Nirdesh Kumar SystemNirdesh Kumar System
@Jha-  I am using the Snap-In. I thing we can not route the chat to button dynamically by standard chat functionality.
Jha RishikeshJha Rishikesh
@Nirdesh, the snap-in does the routing automatically. All you need to do is, modify your code something like below


embedded_svc.settings.directToButtonRouting = function(prechatFormData) {
if (prechatFormData[4].value === "xxx")
    return "youbuttonid";
else if (prechatFormData[4].value === "yyyy")
    return "youbuttonid";
else if (prechatFormData[4].value === "zzzz")
    return "yourbuttonid";
};

prechatFormData is the array of the fields that you want to display. In the above example, I'm taking the 5th element of the pre-chat form. You can change accordingly. 

Hope this helps you.
Nirdesh Kumar SystemNirdesh Kumar System
Thanks Jha. But how can i do in salesforce lightning community? In community ,salesforce provide the standard snap-in component and we cannot modify that. 
Jha RishikeshJha Rishikesh
@Nirdesh, Create a VF page. Put the Snap-in Deployment code in the VF page. Do the changes that I have suggested. Finally, use VF page on the community. Hope this helps you.
IRealm42IRealm42
@Jha - I have the direct to button setup and that part seems to be working.. as far as I can tell.. but my issue is that the members of the queue (that is related to the other button) do not seem to be online.. even if they select online.. seems to be a disconnent somewhere.

And I say it seems to be working because it says no agents available when I choose the product value that changes the button id. If I logout and leave those members of the queue logged in, the chat button (from snap ins) says contact us as if no one is online. if I log back in, it shows me online. I am the member of the queue related to the button that the snap in references initially.

so what am I missing here? how are you members/users setup?
Bhavesh Jain 41Bhavesh Jain 41
@Jha: I had tried adding the code snippet to VF page and added the VF page to salesforce community however when I click on the chat nothing happens have the domains/URLs to CORS still no luck
 
mcarrillomcarrillo
As Jha Rishikesh mentioned you can edit the code snippet that Salesforce provides.
...
                    // 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.
                        if (prechatFormData[2].value === "Option1")
                            return "...buttonId1...";
                        else {
                            return "...buttonId2...";
                        }
                    };
...
for this, you have to have created both buttons with their owns queues/skills/etc.