You need to sign in to do that
Don't have an account?

Integrating Live Agent Chat Into Communities
I have created the code via the Chat Button design, but am unable to add it to the current Communities page. Community Builder does not allow anything be added in, and Site.com does not allow the template to be edited (as it mentions the page is a Lightning template.) Lightning Components can be built, but do not allow for this sort of scripting. How does something scripted get added via Community Builder or Site.com Studio?
Community Builder is really limited with how you can customize it. Generally speaking if you can somehow get the code in your footer, then you should be good to go.
That being said, this SSE post from September declares that you can get Live Agent to work by including the script in a static resource, and then creating a lightning component that uses that static resource, then adding the lightning component to community builder.
http://salesforce.stackexchange.com/questions/94045/winter-16-community-builder-live-agent-and-content-security-policy-issues
James, thank you very much for your reply. I've completed most of those steps, but am again running into a snag.
When attempting to add the static resource to the component, I receive this error: 'Could not load Static Resource from Salesforce: sObject type 'StaticResource' is not supported'
A-ha. Then my follow-up to that would be, after I have saved the component and it is now a .cmp, how does it get added/included to the list of available components within Community Builder?
I apologize if I am coming off as a complete moron here.
Sorry I forgot to mention that. You'll need to implement the community interface. You can do that by adding the following to your aura:component tag:
Adding this to your aura:component element lets Community Builder know this component should work with communities.
To add the component to your template then, you would:
Hope that helps.
So essentially, if I were to create a static resource titled 'LiveAgentButton', the component should look like this, both to be available as a component and for it to allow Chat to be accessed:
<aura:component>
<ltng:require scripts="/resource/LiveAgentButton"
afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
implements="forceCommunity:availableForAllPageTypes"
</aura:component>
Bryan/James, have either of you gotten this working? I would appreciate any information you can give, I've been banging my head against this for the last month and I just can't get it to work right.
Now with the Spring '16 preview, I've even tried adding the scripts to the head section in the new Advanced options. That got me farther than I've ever gotten before, I got the scripts to load and if I manually display the "Live Chat Online" button on the page I am able to click it and get to my LC PreChat window, but now my problem appears to be that the scripts in the head section aren't able to see the IDs that i've assigned to the "LC Offline" and "LC Online" images, so the page ALWAYS display the "LC Offline" since it can't getElementById.
When I inspect the source of my page, and try to manually find the ID that I assigned to the element in my lightning component, I can't find it in the source either... In fact, I can't find ANY of the page data in the source. Now I'm even more confused than before.
You've made more progress than I have, Morgan. I am able to see that the button is available under Custom Components. However, once added to the page, I am not seeing anything actually being active within that space. You mention that that you're able to see the images that you integrated, which is where I'm hoping to get to next.
What James mentioned to me is all accurate, and was a great help. Unfortunately, I am hitting the same snags as you.
Ironically, I've also tried to use the custom lightning component mentioned above ^, which was created by Salesforce themselves, and it ALSO doesn't appear to work when lightning locker service for communities is enabled in our Sandbox. Honestly unbelievable. How are we supposed to implement Live Agent into our Salesforce Community if even Salesforce themselves cannot code a component that conforms to their own rules and functions without code manipulation?
I've now spent the better part of a day ripping apart their component through various console.log(); lines to find out where the break points are, and I find that a majority of their code returns undefined variables or no results at all.
Meanwhile, I'm able to spin up a basic HTML page and save it to my desktop (No Apex, No VisualForce, no Lightning), and I can get a Live Agent button working within 12 seconds.
THIS. SHOULDN'T. BE. THIS. HARD.
I'm in the same boat. Actually getting the error "No 'Access-Control-Allow-Origin' header is present on the requested resource."
Anyone see that yet?
I tried loading the js as a static resource, but evenHandling doesn't work now.
I've tried both the <head> and resource file approach - whilst the Online/Offline process is working for me - when the Online is clicked I get chrome reporting via the console:
Blocked opening '' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.
and also
Blocked form submission to '<<redacted>>' because the form's frame is sandboxed and the 'allow-forms' permission is not set.
Is this due to Locker or have I missed something?
This URL http://salesforce.stackexchange.com/questions/105455/spring16-community-builder-lightning-javascript-in-head-cant-find-elementbyi/105633 is what's got me this far.
Here is my lighting component with Live Chat code:
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >
<ltng:require scripts="{!$Resource.TrailChat}" />
<ltng:require scripts="{!$Resource.Deployment}" />
<img id="liveagent_button_online_57341000000CzRV" style="display: none; border: 0px none; cursor: pointer" onclick="liveagent.startChat('57341000000CzRV')" src="https://bala-trailhead1-developer-edition.na35.force.com/resource/1481731369000/OnlineButton" />
<img id="liveagent_button_offline_57341000000CzRV" style="display: none; border: 0px none; " src="https://bala-trailhead1-developer-edition.na35.force.com/resource/1481731401000/OfflineButton" />
</aura:component>
I removed all the <script> tags and made two .js files ( one contains deployment.js content and other contains all other javascripts ) like below:
liveagent.init('https://d.la2-c1-phx.salesforceliveagent.com/chat', '57241000000Cx1z', '00D41000001hJ6b');
if (!window._laq) { window._laq = []; }
window._laq.push(function(){liveagent.showWhenOnline('57341000000CzRV', document.getElementById('liveagent_button_online_57341000000CzRV'));
liveagent.showWhenOffline('57341000000CzRV', document.getElementById('liveagent_button_offline_57341000000CzRV'));
When I add this component in my Napili community home/custom page, I am getting "Uncaught SyntaxError: Unexpected end of input throws at https://playful-bear-281399-dev-ed--livepreview.na35.force.com/sfsites/c/resource/1481921103000/TrailChat:4:114" error. It comes either in line 3 or 4.
Any clue?
Thanks
Bala
Also, tried with document.getElementByName(..) or document.getElementByClassName(..). Bot are not working.
Also, if I give alert(..) statement in the onClick, it is not firing.
<img id="liveagent_button_online_57341000000CzRV" style="display: none; border: 0px none; cursor: pointer" onclick="alert('test');liveagent.startChat('57341000000CzRV')" src="https://bala-trailhead1-developer-edition.na35.force.com/resource/1481731369000/OnlineButton" />
When I place the lightning component in the Napili community home page, I can get the button image. But no action is happening when I click.
Thanks
Bala