Glance Cobrowse for Lightning Communities
This document outlines the process to implement Glance Cobrowse features on the Salesforce Lightning Communities framework.
Prerequisites
Before you begin, ensure that:
- You have a Glance Account.
- You have set up a Salesforce Community, and the community is enabled in your org. To enable a community, go to Setup, enter Community in the search bar, and select Communities Settings.
Create a Cobrowse Button
First, you will create a button where you will initiate Cobrowse sessions.
- Log into the Salesforce Org as the system admin.
- Navigate to Setup and enter All Communities into the Quick Find bar.
- Select All Communities from the returned results on the left menu bar.
- Locate the Lightning Community where you want to add Glance Cobrowse, and select Builder.
- Create a new lightning component button where you will initiate cobrowse. Note you are creating a default button, not using a lightning button.
- Go to the gear icon (settings)>Developer and click the Developer Console button in the top-right corner.
- Select File> New > Lightning Component.
- Enter a name and description and click Submit.
- Open the .cmp file that was created, and paste in this code:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" access="global">
<button onclick="{! c.startCobrowse }"> Cobrowse </button>
</aura:component>
10.
11.
({
startCobrowse: function(cmp, event) {
window.postMessage("startCobrowse", "*");
}
})
12.
Tag the Lightning Community
Next, modify the security settings and add the Cobrowse script tag.
- Log in as the system Admin and open the Community Builder.
- Click the gear icon(Settings) from the left-side menu.
- Go to the Security tab, and complete the following steps:
- For Script Security Level, select Allow Inline Scripts and Script Access to Whitelisted Third-party Hosts.
- Under Trusted Sites for Scripts, add the following sites:
- https://s3.amazonaws.com/
- https://www.glancecdn.net
- https://*.glance.net
- Click the CSP Trusted Sites link in the descriptive text of the section.
- Click New Trusted Site to add the following sites:
- https://s3.amazonaws.com
- https://www.glancecdn.net
- https://*.glance.net
- If you are using 1-Click Connect from Chat or a button, wss://*.glance.net
- Select the Advanced tab and click Edit Head Markup.
- Add the Glance Cobrowse JavaScript Loader Tag in the Head Markup to allow the cobrowse session to happen on the lightning community. This is an example of the script tag and includes the cobrowse script tag and listener script; replace your group ID where specified:
<script
id="glance-cobrowse"
type="text/javascript"
src="https://www.glancecdn.net/cobrowse/CobrowseJS.ashx?group=<!--your id here->&site=production"
data-groupid="<!--your id here-->"
data-site="production"
data-presence="on"
charset="UTF-8"
></script>
<script>
window.onload = function() {
document.addEventListener("DOMContentLoaded", function(event) {
document.getElementById("glancestartbutton").onclick = function () {
GLANCE.Cobrowse.Visitor.startSession();
};
});
};
window.addEventListener("message", startGlanceSession, false);
function startGlanceSession(event) {
if (event.origin !== 'https://' + window.location.hostname) {
return;
}
if(event.data !== "startCobrowse") {
return;
}
GLANCE.Cobrowse.Visitor.startSession();
}
</script>
6.
7.