Automating extracts of performance data

I'm trying to automate the download of the standard Performance queries so they can be sent to another system. Once a month, we trigger an export of Queue Performance and Agent Performance to csv, but I'd like to avoid this step. I could schedule an export for once a month (and handle the resulting email), but scheduled exports expire after 100 days, so I'd still have to keep remembering to log in and renew them, otherwise my ETL would break.

So, I'm trying the API with Client Credentials. I'm currently using the .NET SDK, but I'm willing to use any interface at this point.

First, I used POST /api/v2/analytics/reporting/exports, and this did successfully create an export. Then I used the Download API to d/l the file (using the d/l ID which I pulled from the DownloadUrl from GET exports).

This worked fine, but I noticed that the exports I used for testing stuck around, and I don't see any way to delete them. So are these just going to be there forever? Do they disappear after a set amount of time? Can I just update them each month with a new Interval (I didn't see any option for updating existing exports). I'm not too hip in creating an infinite amount of exports, so I looked into better options.

I did note that the reporting/exports API says that it recommends you use the Analytics Query APIs (instead of using the reporting/exports APIs). But I haven't the slightest idea how to reproduce the Queue/Agent Performance views using those query APIs.

I tried POST /api/v2/analytics/queues/observations/query, but the sample in the documentation shows no examples of how to use the parameters. The sample as-is doesn't run at all. Basically, I'm not seeing anything that would tell me how to mimic the Performance Views using the Query APIs.

So, should I just keep creating exports on the fly, or can someone point me in the right direction on how to use the query APIs to do this?

I found it fairly trivial to recreate the various reports using the conversation aggregates, have you seen the more detailed explanation of them?

Thanks, that helps. I put together a simple query with a few random dimensions/metrics, but it's returning Nothing. The query runs successfully, but the rsp contains no results. Does it matter which user runs the query? Could it be the fact that my program is using Client Credentials is causing this? Or does the OAuth Client not have the right permissions? Or...?

                Dim qry As New ConversationAggregationQuery() With {
                    .Interval = "2024-03-01/2024-03-31",
                    .Granularity = "P1D",
                    .GroupBy = {ConversationAggregationQuery.GroupByEnum.Mediatype, ConversationAggregationQuery.GroupByEnum.Queueid}.ToList,
                    .Metrics = {ConversationAggregationQuery.MetricsEnum.Theld, ConversationAggregationQuery.MetricsEnum.Ntransferred}.ToList}
                Dim rsp = api.PostAnalyticsConversationsAggregatesQuery(qry)

So, this may be due to my using Client Credentials as I suspected. When I run the same Conversation query in the API Explorer (while logged in as my user), I get results, but if I run it using the Client Credentials auth (even as a simple webclient containing the same JSON), it returns nothing.

Does anyone know how to get an app using Client Credentials to work with these types of queries?

Client credentials is how I do all my imports, you most likely need to check your permissions.

Analytics > Conversation Aggregate is Division Aware. It sounds like you have access to the API but not authorization to pull from the divisions you're targeting and therefore get no error but no data.

Thanks. This did it. I specified which Division would be used by this Client and finally started getting the expected data.

The next problem is finding all of the same fields that are in the standard reports. I'm not seeing them all as options. For example, the Queue Name is in the Queue Performance report, but I don't see a Group option for Queue Name.

Anything that is a dimension unto itself will only have it's ID in that API (most APIs, in fact).
You're responsible for traversing the dimension through it's own native API for any additional properties you want.

True for QueueId, UserId, LanguageId, SkillId, etc.

Also if you're using skills you may want to consider using the flatten option, otherwise any metric that's offered to multiple skills simultaneously will also manifest as a separate copy of itself in each of those skills. If you tell it to flatten multi dimension attributes you'll only get the metric once per time it occurs, but it will be to a comma separated list of all the skills involved instead of a single id you can easily look up.

OK thanks. I only have one dim shown in the output, so getting the Name is no problem.

The only thing I haven't figured out is how to get the averages. All of the standard reports that I use include "Avg Talk", "Avg Hold", etc. But I don't see that as a stat in the metrics of the conversations query. I'm only getting max/min/count/sum. Is there a way to add Average to the stats?

Refer to example here

Some metrics require you to sum the number of times they occurred and use that as the denominator, some expect you to use tHandle or tAnswered for that.

Thanks. You've been a huge help.