Let's Chat?

Presence Agent REST API

The Glance Presence Agent REST API offers the same functionality as the JavaScript GLANCE.Presence.Agent API, with the exception of connect() which relies on WebSockets. The REST API is useful for implementing server side agent console functionality.

REST API URLs

The Presence service consists of a load balancer at presence.glance.net as well as multiple named Presence Servers at presence0001.glance.net, presence0002.glance.net, etc. Presence data can be queried by invoking the JSON REST API on the Presence Service at presence.glance.net. Signaling specific visitors must be done by finding the instance that the visitor is currently connected to (via /findvisitor), then invoking the REST API on that server.

Authorization

All Presence Agent REST API entry points expect an authorization token to be sent in an Authorization header as follows:
Authorization : Bearer [authorization token]

The Authorization Token can be obtained using the Authorization API.

REST API Endpoints

The Presence service supports the following REST endpoints:

/lookupvisitor

GET https://presence.glance.net/lookupvisitor?groupid=[groupid]&visitorid=[visitorid]

Returns the Presence information for a particular visitor.

{
    "direct": "pr0016.glance.net:443",
    "visitorpresent": "1583953702.0",
    "timestamp": "1583953702.0",
    "visitorid": "example",
    "groupid": "12345",
    "ds": "pr0016.glance.net/0",
    "directserver": "pr0016.glance.net",
    "tlsport": 5501,
    "httpsport": 443
}

/findvisitor

GET https://presence.glance.net/findvisitor?groupid=[groupid]&visitorid=[visitorid]

Returns the specific named Presence server that the visitor is currently connected to:

{
    "ds": "pr0016.glance.net/0",
    "direct": "pr0016.glance.net:443",
    "directserver": "pr0016.glance.net",
    "tlsport": 5501,
    "httpsport": 443,
    "visitorfound": true
}

If the visitor is not present on the website, the server returns:

{
  visitorfound : false
}

/signalvisitor

Signals the specified visitor, passing a JSON message. There must be a connected GLANCE.Presence.Visitor instance on the visitor side to receive the signal.

POST https://[directserver]/signalvisitor?groupid=[groupid]&visitorid=[visitorid]

The body of the request is the JSON message to send. The message should have the following format:

{
   "mtype":"[message type]",
   "data":"[message payload]"
}

The message type can be "invoke", to invoke a GLANCE JavaScript function on the visitor:

{
   "mtype":"invoke",
   "data": {"func":"GLANCE.Cobrowse.Visitor.startSession"}
}

Alternatively, message type "signal" can be specified to send a custom message. When the visitor side receives the message, the event handler onsignal(), if defined, will be called on the Visitor instance.

For example:

{
   "mtype":"signal",
   "data":{
      "command":"startchat",
      "chatid":"56789"
   }
}

will result in onsignal ({ command : "startchat", chatid: "56789"}) being called on the GLANCE.Presence.Visitor instance.

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