Glance Cobrowse gives agents the ability to instantly join customers in viewing your app or website. Agents can guide customer navigation, answer questions, and assist with completing transactions. You can launch a Glance Cobrowse session from the Twilio Flex platform with the click of a button — no need for the customer to download or install a screen sharing app.
Through the Glance 1-Click Connect capability, agents receive alerts when customers are present on your website and can connect with just one click. You can also enable one-way agent video to personalize the Glance Cobrowse experience.
To integrate the Glance Cobrowse Component with Flex, you need the following:
Twilio Account and Flex Project
Glance Account that has the Flex domain added to the allowlist.
To add the Flex domain to the allowlist:
flex.twilio.com
to the domain and select Add.Site that is configured with the Glance Cobrowse script tag.
Ensure that you:
data-presence
to api
.data-cookiedomain
to the URL for your website domain.Example of the Glance Cobrowse script tag:
1<script id="glance-cobrowse" type="text/javascript"2src="https://[cdnname].glancecdn.net/cobrowse/CobrowseJS.ashx?group=[groupid]&site=[production|staging]"3data-groupid="[groupid]"4data-site="[production|staging]"5data-inputevents='{...}'6data-termsurl="[terms and conditions url]"7data-cookiedomain="[session cookie domain]"8data-cookietype="[normal|ls|dual|secure]"9charset="UTF-8"10data-presence="api">11</script>
To integrate the Glance Cobrowse Component with Flex, you must:
In order to connect to Glance from Flex, you need to set up authentication. Glance uses the same user ID from the identity provider to call a Twilio Function to authenticate into Glance.
Log in to your Glance account.
Go to Portal > Edit Users.
For Parter UID, enter the user ID from your identity provider.
Select Update User.
To set up authentication:
From the Twilio Console > Functions > Services, select Create Service.
Enter a Service Name then select Next.
For example: yourcompanyname-glance
. Note: Remember this Service Name to use it later when adding the Glance Cobrowse Component to Flex.
Select Add+ > Add Function.
A new field appears.
Remove the default name /path_1
and input getloginkey
. Click enter to generate the function.
Click the drop-down next to Protected to set the visibility to Public.
In the text editor on the right, paste the code below then select Save.
1const TokenValidator = require('twilio-flex-token-validator').functionValidator;23exports.handler = TokenValidator(function(context, event, callback) {4const response = new Twilio.Response();56response.appendHeader('Access-Control-Allow-Origin', '*');7response.appendHeader('Access-Control-Allow-Methods', 'GET', 'POST');8response.appendHeader('Access-Control-Allow-Headers', 'Content-Type');9response.appendHeader('Content-Type', 'application/json');1011try {12const version = 1;13const expires = (Math.round((new Date()).valueOf() / 1000)) + parseInt(context.GLANCE_EXPIRATION, 10);14const keystring = context.GLANCE_GROUP_ID + event.partneruserid + version + expires;15const CryptoJS = require('crypto-js');16const hmac = CryptoJS.HmacSHA256(keystring, context.GLANCE_API_KEY);17const hmacb64 = hmac.toString(CryptoJS.enc.Base64)18const loginkey = "$" + version + "$" + expires + "$" + hmacb64.substr(0, 43).replace(/\+/g, '-').replace(/\//g, '_');1920response.setBody({21'loginKey': loginkey,22'groupId': context.GLANCE_GROUP_ID,23'expiration': expires,24'apiKey': context.GLANCE_API_KEY25});2627response.setStatusCode(200);28callback(null, response);29} catch(error) {30response.setStatusCode(404);31callback(null, response);32}3334});
In Settings > Environment Variables, add the following Environment Variables:
GLANCE_API_KEY
and set the value to your Glance API Key. To find your Glance API Key, log in to your Glance account. Go to Settings > API Key.GLANCE_EXPIRATION
and set the value to a length of time (in seconds) when you want the session to expire. We recommend 3600
GLANCE_GROUP_ID
and set the value to the Glance group ID for your company. Note: The Glance group ID is a unique ID assigned to your company by Glance. You can find this in the Glance portal in the top-right corner of every page.In Settings > Dependencies, add the following dependencies without a version number:
twilio-flex-token-validator
crypto-js
Select Deploy All.
You must add the Glance Cobrowse Component to either an existing or a new Flex Plugin. In your terminal, run:
npm install @glance-networks/twilio-flex-component
If you are using Yarn, run the following instead:
yarn add @glance-networks/twilio-flex-component
For more information, see the ReadMe.
After installing the Glance Cobrowse Component, choose where you want the button to display inside Flex. Learn how to customize Flex UI Components.
Import the component inside your Flex project. In glanceplugin.js (note: the name of the plugin is autocreated when you make the file) or .jtx file, add the following to the first line:
import {TwilioFlexGlance} from @glance-networks/twilio-flex-component
Example of the Glance Cobrowse Component inside the task canvas header:
1flex.TaskCanvasHeader.Content.add(2<TwilioFlexGlance3key={[yourkey]}4groupid={[yourgroupid]}5authurl={[yourauthurl]}6authtoken={flex.Manager.getInstance().user.token}7openlocation={'tab|window|flex'}8presence={true}9glancebaseurl={'beta|staging|production'}10puid={flex.Manager.getInstance().user.identity}11debugmode={true|false}12/>, {options}13);
Example of the Glance Component inside the CRM Container:
Note: If you are opening sessions inside the iframe, you must use the CRM Container. You should not use this option if you need this panel for other content, as it will fill the contents of the entire panel with the Glance Cobrowse session.
1flex.CRMContainer.Content.replace(2<TwilioFlexGlance3key={[yourkey]}4groupid={[yourgroupid]}5authurl={[yourauthurl]}6authtoken={flex.Manager.getInstance().user.token}7openlocation={'tab|window|flex'}8presence={true}9glancebaseurl={'beta|staging|production'}10puid={flex.Manager.getInstance().user.identity}11debugmode={true|false}12/>, {options}13);
Important: In the cases above, AgentDesktopView.Panel2 is open or closed depending on how you set the default properties.
The following table describes the properties inside the component:
Property | Type | Definition |
---|---|---|
key | string | Required. React component key. User-defined unique string. |
groupid | integer | Required. Enter your Glance Group ID (unique ID assigned to your company by Glance). |
authurl | string | Required. Enter the URL to your login key function. This is the function you created above in the "Set Up Authentication" section: https://YOURCOMPANYNAME-glance-####/getloginkey |
opentype | string | Optional. If undefined, defaults to flex. Accepted values are:
Note: Selecting flex or leaving undefined takes over AgentDesktopView.Panel2. If you are already customizing this component in your Flex implementation, it is suggested that you set opentype to window or tab. |
presence | Boolean | Optional. Determines if presence is enabled. If undefined, presence is set to off. If you are implementing Glance with Flex WebChat, you must set presence to true.
|
glancebaseurl | string | Required. Determines which Glance environment servers the session points to. Set to production unless explicitly directed otherwise by Glance Customer Success.
|
puid | Required. Set to: {flex.Manager.getInstance().user.identity} |
You must consume Flex WebChat from the CDN. Glance does not have a NPM package, which is necessary if deploying in a React application.
Install Flex WebChat.
The following code example contains Flex WebChat and Glance Presence functionality. Update the code with your Account SID and Flex Flow SID:
1<script>2const appConfig = {3accountSid: "[YOUR_TWILIO_ACCOUNT_SID]",4flexFlowSid: "[YOUR_FLEX_FLOW_SID]",5context: {6friendlyName: "[YOUR_FIRENDLY_NAME]",7},8startEngagementOnInit: true9};10let sessionid = undefined;1112Twilio.FlexWebChat.createWebChat(appConfig)13.then(webchat => {14const { manager } = webchat;1516Twilio.FlexWebChat.Actions.on("afterSendMessage", () => {17const {channelSid} = manager.store.getState().flex.session;18if (!sessionid || sessionid !== channelSid) {19manager20.chatClient.getChannelBySid(channelSid)21.then(channel => {22let visitor = new GLANCE.Presence.Visitor({23groupid: document.getElementById("glance-cobrowse").getAttribute("data-groupid"),24visitorid: channel.sid25});26visitor.onerror = function (e) {27console.log("presence error:", e);28};29visitor.presence({30onsuccess: function () {31console.log("presence success");32}33});34visitor.onsignal = function (msg) {35console.log("received signal:", msg);36};37visitor.connect();3839});40sessionid = channelSid;41}42});4344webchat.init();4546});47</script>
Set up a Flow for Flex WebChat:
From the Twilio Console > Studio > Manage Flows, select Webchat Flow.
In the Widget Library > Flow Control, select and drag Set Variables onto the canvas. Click the widget to edit.
Click the plus sign on the right side of Variables.
For Key, input glance_visitor_id
.
For Value, input {{trigger.message.ChannelSid}}
.
Save the variable.
Save the widget.
Wire the widget to the Incoming Message Trigger.
In the Widget Library > Connect Other Products, select and drag Send to Flex onto the canvas. Click the widget to edit.
For Workflow, select Assign to Anyone.
For Channel, select Programmable Chat.
For Attributes, input {"name": "{{trigger.message.ChannelAttributes.from}}", "channelType": "{{trigger.message.ChannelAttributes.channel_type}}", "channelSid": "{{trigger.message.ChannelSid}}", "glance_visitor_id": "{{flow.variables.glance_visitor_id}}"}
Save the widget.
Wire the widget to the Set Variable Widget that you just created.
Select Publish.
Personalizing a Glance Cobrowse session with Glance Video lets your agents build trust, confidence, and credibility with customers. You can enable either one-way agent video, or multi-way video where the customer will be prompted to optionally share their video during the session.
Log in to your Glance account.
From Settings, select one of the following options depending on the video experience you want:
Once enabled, Glance Video starts with the Glance Cobrowse session. To pause Glance Video, click the Video button in the agent viewer.
For more information on Glance Cobrowse sessions, see the Glance Cobrowse Guide.