How to build an agent presence report via API

Christina Dechent
Christina Dechent
  • Updated

The endpoint metrics/agents/presence/total?timeRange=YESTERDAY provides metrics about agents' presence over
a specified time range. From the given response below:

  • We have data for an agent named "Test agent".

  • It tells us about the agent's presence states during the given timespan: "busy" and "available".

  • Each state has its duration (totalTime), the number of times the state has been triggered (totalTransitions), and
    the last timestamp it was recorded.

Response:

{ "id": "agents.presence.total",
   "type": "total",
   "metric": {
        "values": [ {
           "id": "7c7f884721fa43ec92418f8c793baf60",
           "name": "Test agent",
           "presence": {
                  "name": "busy",
                   "available": false,
                   "label": "Busy",
                   "totalTransitions": 0,
                   "totalTime": 29372,
                   "lastTimestamp": 1691734163000
            },
        "states": {
           "busy": {
                   "name": "busy",
                   "available": false,
                    "label": "Busy",
                    "totalTransitions": 0,
                    "totalTime": 29372,
                    "lastTimestamp": 1691734163000
                   },
           "available": {
                   "label": "Available",
                   "available": true,
                   "totalTime": 153332,
                   "totalTransitions": 1,
                   "lastTimestamp": 1691734163494
                   }
                 }
               }
            ]
         },
   "request": {
         "id": "agents.presence.total",
         "runtime": 235, "timeRange": {
                    "from": "2023-08-11T00:00:00.000Z",
                    "to": "2023-08-11T14:18:54.999Z",
                    "value": "TODAY",
                    "duration": 51534999
                    }
                  },
   "success": true
}

 

In this example, we see that the agent Test agent is currently on the status busy for a total time of "totalTime": 29372

Based on the information, our report can be structured as:

values/name

Date

busy/totalTime

busy/totalTransitions

available/totalTime

available/totalTransitions

Test agent 1

10/08/2023

1,830.37

1

237.97

8

Test agent 2

10/08/2023

1,469.68

1

49.43

4

Test agent 3

10/08/2023

0.02

1

264.02

8

For regular reporting, consider automating the process:

  1. Scheduled Calls: Automate API calls to the endpoint at regular intervals, e.g., daily.

  2. Data Processing: Process the response data automatically, converting seconds to hours, minutes, and seconds.

  3. Generate Report: Use reporting tools or custom scripts to generate a formatted report.

  4. Distribute: Automatically send the report to stakeholders via email or integrate into a dashboard.

Was this article helpful?

/

Comments

0 comments

Please sign in to leave a comment.