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:
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
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.