REST Example - Agent Times
This page gives an example to fetch agent times from REST API. There are two ways to fetch times of the agent.
- List
- Aggregation
List of agent online/loggedin times
This API call returns a list of the online times of the agent. https://developers.chatvisor.com/#operation/getAgentLoggedInTimesUsingPOST
POST https://api.chatvisor.com/rest/v1/report/agent/times/online?access_token=<TOKEN>
BODY:
{
"grouping": "LAST_7_DAYS"
}
[
{
"userId": "agent1@example.com",
"timeRanges": [
{
"start": "2020-10-31T23:00:00.794Z",
"end": "2020-10-31T23:03:25.794Z"
},
{
"start": "2020-11-01T23:00:00.794Z",
"end": "2020-11-01T23:00:25.794Z"
},
{
"start": "2020-10-29T23:00:00.794Z",
"end": "2020-10-29T23:03:25.794Z"
}
],
"sumMinutes": 6
},
{
"userId": "agent2@example.com",
"timeRanges": [
{
"start": "2020-10-29T23:00:00.794Z",
"end": "2020-10-29T23:06:50.794Z"
}
],
"sumMinutes": 6
}
]
Aggregation of agent online/loggedin times
This API call returns a aggregated statistic of the agent times in seconds. https://developers.chatvisor.com/#operation/getUsingPOST
POST https://api.chatvisor.com/rest/v1/report/agent?access_token=<TOKEN>
BODY:
{
"metrics": [
{
"metricName": "ONLINE_TIME", # or LOGGED_IN_TIME
"groupBy": "AGENT" # optional group by agent
}
],
"dateFilter": {
"grouping": "LAST_7_DAYS"
}
}
{
"results": {
"2020/10/30": {
"agent1@example.com": "205",
"agent2@example.com": "411"
},
"2020/11/01": {
"agent1@example.com": "205"
},
"2020/11/02": {
"agent1@example.com": "25"
}
}
}