// Instantiate a Visitor presence object
varpresencevisitor=newGLANCE.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)
presencevisitor.presence();// 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);}presencevisitor.connect();
Agent-Side Sample Code
// Authenticate the agent
GLANCE.Authorization.authorize({service:"presence",credentials:{username:[Glanceaccountusername],password:[Glanceaccountpassword],gssnid:[Glancewebsitesessionid],partnerid:[Partnerid,usuallysameasgroupid],partneruserid:[Partneruserid],loginkey:[Loginkeysignedwithsecretapikey],g4scredentials:[GlanceforSalesforcecredentials]},// Not all credentials fields are required.
// See the page on Authorization Token for requirements.
groupid:"1234",duration:[durationoftheauthorizationtokeninminutes1-120],onsuccess:showpresence,onfail:function(reason){// display error ...
}});functionshowpresence(){// Construct a new Presence Agent object
presenceagent=newGLANCE.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
myhandlevisitor();// Optional, lookup the visitor to find any associated data
presenceagent.lookupVisitor({onsuccess:function(visitordata){myhandlevisitor(visitordata);},onfail:function(reason){};});};// Invoke a visitor side api. Put this code behind a "cobrowse" button
presenceagent.invokeVisitor({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
presenceagent.signalVisitor({chatid:"123456",command:"startchat"});
By continuing to use the site, you agree to the use of cookies. Learn More