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 specific server.
Authorization
All Presence Agent REST API entry points expect an authorization token to be sent in an HTTP Authorization header as follows:
Authorization: Bearer [authorization_token]
The Authorization Token can be obtained using the Glance Authorization API.
REST API Endpoints
The Presence service supports the following REST endpoints:
/lookupvisitor
Returns the Presence information for a particular visitor.
GET [https://presence.glance.net/lookupvisitor?groupid=](https://presence.glance.net/lookupvisitor?groupid=)[groupid]&visitorid=[visitorid]
Response:
{
"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
Returns the specific named Presence server that the visitor is currently connected to.
GET [https://presence.glance.net/findvisitor?groupid=](https://presence.glance.net/findvisitor?groupid=)[groupid]&visitorid=[visitorid]
Response (Visitor Found):
{
"ds": "pr0016.glance.net/0",
"direct": "pr0016.glance.net:443",
"directserver": "pr0016.glance.net",
"tlsport": 5501,
"httpsport": 443,
"visitorfound": true
}
Response (Visitor Not Found):
{
"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"
}
}
This will result in onsignal({ "command": "startchat", "chatid": "56789" }) being called on the GLANCE.Presence.Visitor instance.