When you need to know what is the current or last interaction for the agent, you can use this method to check that information.
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Request Uri
GET v{v#}/{accountKey}/agents/{agentId}/latestInteractions
Authorization (required)
This header requires an OAuth bearer token. For information on the bearer token, see Using the bearer access token.
Accept (required)
application/json;version=1
Indicates that the media type required from the server is JavaScript Object Notation (JSON)
Parameters (plans for versions > 1)
size: 1-n - limits the number returned; optional default is 1
type: optional; permitted values currently All|Phone|Chat|Email - filters out other types of interaction
activeLiveFirst: optional true|false - sorts any Active Live Interaction (e.g. Phone vs. Chat/Email/etc. non/semi-live interaction types) first for compatibility with Task Refresh/Dialler queries.
Response (version 1)
{
"interactions" : [
{
"start": "2017-03-30T22:40:15Z",
"guid": "015b212c-1487-46ba-bbb7-d78d6b1412a5",
"hasEnded": true
}
]
}
Result contains current or the most recent interaction for an agent. If there is more than one active interaction the first return is interaction with type 'Phone". The interaction are ordered descending by InteractionStateChangedAt.
Response (plans for version > 1)
{
"interactions" : [
{
"type": "Phone",
"start": "2017-03-30T22:40:15Z",
"guid": "015b212c-1487-46ba-bbb7-d78d6b1412a5",
"duration": 972,
"direction": "Inbound",
"channelGuid": "015b212c-1487-46ba-bbb7-d78d6b1412a5"
},
...
]
}
Results are in order of the most recently started Channel first, followed by the one started before that, etc.
start is the time the agent's Channel started in UTC
guid is the Interaction GUID
type denotes the medium the agent used, e.g. Phone, Chat, Email, as per Vonage Contact Center type enumeration.
duration is null if the agent is still connected, otherwise it is the duration of their channel in seconds
direction - nice to have - direction of the Interaction not of the Channel
Examples
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Current interaction is active
curl -X GET
"https://***.newvoicemedia.com/v0/a1b2c3d4e5/agents/recentinteraction" -H "Authorization: Bearer <ACCESS_TOKEN>" -H "Accept: application/json;version=1"
Returns HTTP status code of 200, containing the following message.
{
"interactions" : [
{
"start": "2017-03-30T22:40:15Z",
"guid": "015b212c-1487-46ba-bbb7-d78d6b1412a5",
"hasEnded": false
}
]
}
Current interaction is not active
curl -X GET
"https://***.newvoicemedia.com/v0/a1b2c3d4e5/agents/recentinteraction" -H "Authorization: Bearer <ACCESS_TOKEN>" -H "Accept: application/json;version=1"
Returns HTTP status code of 200, containing the following message.
{
"interactions" : [
{
"start": "2017-03-30T22:40:15Z",
"guid": "015b212c-1487-46ba-bbb7-d78d6b1412a5",
"hasEnded": true
}
]
}
Invalid Request
Returns an HTTP response code of 400
{
"message": "The InteractionType field is required."
}
Agent Not Found
Returns an HTTP response code of 404
{
"message": "The requested resource was not found."
}