2

I am currently trying to implement Direct-to-Button routing for Snap-In chat. Implementing this in JavaScript is detailed here: https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_directtobutton_routing.htm.

It looks like this functionality/JS library is designed to be used in a 3rd-party website, given the Snap-In code snippet that imports this library:

<script type='text/javascript' src='https://service.force.com/embeddedservice/4.1/esw.min.js'></script>

How can I access this JavaScript in the community in order to implement Direct-to-Button routing? So far, I tried to download the code in the embeddedservice/4.1/esw.min.js library and uploaded it as a static resource in the Salesforce org.

I copied the remainder of the Snap-In code snippet into another JS file that I also uploaded as a static resource. I then created a Lightning component that calls <ltng:require scripts="$Resource.[JSlib]"> and <ltng:require scripts="$Resource.[snapinJS]">.

When I load put this Lightning component on the community home page in the Community Builder, the chat button appears as expected in the bottom of the screen, but I receive a No 'Access-Control-Allow-Origin' error:

Failed to load <...>/embeddedservice/4.1/client/liveagent.esw.min.js: No 'Access-Control-Allow-Origin'

This error (I presume) then prevents clicking on the chat button to start a Live Agent session.

If I can't use this JS in the community to configure the Snap-In, is there another way of implementing Direct-to-Button routing in a public community while still using Snap-In chat?


After speaking with Salesforce support, they have indicated that I should put the Snap-In code snippet from the "Get Code" button on the Snap-In in a Visualforce page. Putting that VF page on the Community layout then enables the custom JS to be used from the Community.

The "Chat with an Expert" Snap-In button sticks to the bottom of the VF page within the Community.

  • Have you found any solution? – Saurabh Mishra Apr 5 '18 at 14:06
  • Short answer - not really. I ultimately went with the regular Live Agent functionality instead of the Snap-In approach. The best I could do with Snap-In is get it working within a Visualforce page on the community, which didn't fit what I was trying to accomplish. It ended up being better for me to use the pop-out Live Agent functionality. – friendoflore Apr 6 '18 at 15:46

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.