Let's Chat?

Sample Code

Visitor-Side Sample Code

// Instantiate a Visitor presence object
  var presencevisitor = new GLANCE.Presence.Visitor({
  groupid : 123, // optional, defaults to GLANCE_COBROWSE.groupid
  visitorid : "111111111" // optional, defaults to GLANCE_COBROWSE.visitorid

// Start sending regular presence updates (by default, every 60 seconds)


// Send a presence update (now) with some custom data
presencevisitor.presence({ data : { wizardpage : 3} })

// Listen for agent messages.  
presencevisitor.onsignal = function (msg) { console.log("Received", msg); }

Agent-Side Sample Code

// Authenticate the agent
  service: "presence",
  credentials: {
  		username: [Glance account username],
  		password: [Glance account password],
  		gssnid: [Glance website session id],
  		partnerid: [Partner id, usually same as groupid],
  		partneruserid: [Partner user id],
  		loginkey: [Login key signed with secret api key],
  		g4scredentials : [Glance for Salesforce credentials]
// Not all credentials fields are required.  
// See the page on Authorization Token for requirements.
  groupid: "1234",
  duration: [duration of the authorization token in minutes 1-120],
  onsuccess: showpresence,
  onfail: function(reason) {
      // display error ...

function showpresence() {
  // Construct a new Presence Agent object
  presenceagent = new GLANCE.Presence.Agent({
      visitorid: "111111111"

  // Setup event handlers
  presenceagent.onvisitorconn = function(e) {
    // visitor is connecting via websocket and can be signaled
    // display a "connected" status, e.g. light up a cobrowse button

    // Optional, lookup the visitor to find any associated data
            onsuccess: function(visitordata) {
            onfail: function(reason) {};

// Invoke a visitor side api.  Put this code behind a "cobrowse" button
  func: "GLANCE.Cobrowse.VisitorUI.showTerms",
  args: {
    sessionKey: "111111111"

// Send a custom signal.  onsignal will be called on the GLANCE.Presence.Visitor instance.
// For example, put this code behind a "start chat" button
  chatid: "123456",
  command: "startchat"

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