Agent API

The Agent API allows you to customize agent side behavior and integrate Cobrowse with the agent's console or CRM.

Viewer URL

Use the following URL format to view a session that was started with a specific Visitor ID or a random Session Code:

https://www.glance.net/agentjoin/AgentView.aspx?VisitorId=[visitorid|ssncode]&wait=1

NOTE: SessionKey is a synonym for the VisitorId parameter.

To maximize the viewing area, this URL should be opened in a separate browser window with no address bar or menu:

window.open("https://www.glance.net/agentjoin/AgentView.aspx?VisitorId=" + visitorid, "_blank", "location=no,menubar=0,titlebar=0,status=0,toolbar=0");

If an agent is not already logged into their Glance account, they will be prompted to log in. Alternatively, single sign-on credentials can also be passed on the Agent Viewer URL:

SessionKey=ssnkey&partnerid=pid&partneruserid=puid&loginkey=loginkey

The optional query string parameter Wait controls handling of the case when the session has not started yet. If Wait=1 is specified, the viewer window will poll waiting for the session to start. Otherwise, the viewer will redirect to an error page.

Include the API

To include the Agent API on a page, add a Cobrowse script tag following the format of the script tag used on the visitor side, but add script=Agent (case sensitive) to the src attribute.

Agent side script tag example

<script id="cobrowsescript" type="text/javascript"
src="https://www.glancecdn.net/cobrowse/CobrowseJS.ashx?group=[groupid]&
site=[production|staging]&script=Agent"
data-groupid="[groupid]"
data-site="[production|staging]"
charset="UTF-8">
</script>

Parameters

GLANCE.Cobrowse.Agent

The GLANCE.Cobrowse.Agent object implements the Agent API. A typical use case for the Agent API is a page that embeds the Cobrowse viewer in an iframe.

Methods and Properties

When the enclosing page includes the Agent API JavaScript, the page then has access to the following methods on the GLANCE.Cobrowse.Agent object:

Property/Method Description
init(viewerFrame) init(viewerFrame) initializes the Agent Side API viewerFrame. This is the iframe containing the agent view.
enableAccessibility(enable) enableAccessibility(enable) enables or disables accessibility features. When accessibility features are enabled, any screen reader in use will read the element that an agent gestures on.
accessibilityEnabled() accessibilityEnabled() returns true if accessibility features are enabled, false otherwise.
addEventListener(eventName, listener) addEventListener(eventName, listener) adds a listener function to be called when the event specified by eventNameoccurs.
removeEventListener(eventName, listener) removeEventListener(eventName, listener) removes the specified event listener.
addSessionMessageListener(msgName, listener) addSessionMessageListener(msgName, listener) adds a handler function which is called when a message with the name msgName is received from a visitor.

The listener function takes two parameters:

  • msgName: the message name.
  • msg: the message payload object that was sent from the visitor side in sendSessionMessage.
sendSessionMessage(msgName, msg) sendSessionMessage(msgName, msg) sends the message to the visitor side.
navigate(params) navigate() redirects the visitor's browser to the specified URL.

The params object includes the following properties:

{url: [url to navigate to],confirm: { ... },open: { target: ["_self"|"_blank"], features:[features as defined by window.open] },link: { target : ["_self"|"_blank"] }}

The URL may be:

  • A relative URL. Visitor will be redirected to the specified URL, relative to the current page.
  • An absolute URL. The hostname must be in the list of trusted domains for Cross Domain Cobrowse as specified on the Cobrowse Settings page.
  • One of the following keywords: forward, back, refresh.


confirm is optional. If specified, the visitor side will fire a confirm event before navigating. The object passed to the confirm event handler will include the params passed to navigate(), as well as an accept() method to call if the visitor accepts.

If navigating to a page URL (as opposed to forward, back, or refresh) then either open or link should be specified.

If open is specified, window.open() is used to open the specified page.

If link is specified, then an anchor tag is added to the page and programmatically clicked.
leaveSession(url) leaveSession(url) ends the agent’s connection to the session and redirects the Agent Viewer to the specified URL.
addScreenshare(params) addScreenshare(params) adds an already-started Screen Share session to the Cobrowse session. Once a Screen Share session has been added, it will automatically persist even if the visitor navigates to a new page.

The params object includes the following properties:

{screenshareView: (string) ID of the iframe on the visitor side where the screen share viewer should appear. Use "glance_agentvideo" or "glance_screenshare" for agent video and screen share respectively, if using the standard visitor side user interface.

key, sessionKey: (string) The session key. In version 3.7.4, this parameter was renamed sessionKey.

ssnParams: The parameters that were passed to GLANCE.Client.InvokeGlance() used to start the session or the query string parameters that were passed to the Glance protocol handler to start the session. ssnParamsmay be an empty object, but supplying the session parameters can assist in rendering the screen share view. For example, ssnParams for a video session may be shown as follows: {type: "forward",video: 1, size: "240x320"}

agentparams: Parameters indicating agent side behavior.

{preview: true|false. Set this to true to display the built-in video preview on the agent side. Set this to false to suppress the built-in agent preview. Defaults to false.}}
pauseScreeenshare(params)resumeScreenshare(params) Pause or resume the visitor side Screen Share by triggering a screensharepause or screenshareresumeevent on the visitor side.

The params object must include the following properties:

{screenshareView: The screen share view that was specified in addScreenshare()}

Typical usage would be to call these methods before invoking ActionPause or ActionUnpause on the Screen Share session using the Glance Client Library.

The default user interface behavior on the visitor side is to hide the Screen Share or video view while the session is paused.
closeScreenshare(params) The params object includes the following properties:

{screenshareView: The screen share view that was specified in addScreenshare()}
requestRC(true|false) requestRC(true) sends a request to the visitor to enable remote control. The default visitor side UI prompts the visitor to allow or decline the request.

requestRC(false) stops remote control.
getSessionState(eventname) getSessionState() retrieves information about the session as reported by the specified event. For example, getSessionState("rc") returns the event data reported in the most recent rc event.
getUserState(name) getUserState() retrieves the user state that was stored on the session by a call to GLANCE.Cobrowse.Visitor.setUserState()

By continuing to use the site, you agree to the use of cookies. Learn More