My goal is to create a data action that retrieves the on-queue users for multiple queues, to allow using them for queue limitation caluclations in architect flows. The purpose is to allow incoming interactions to a queue depending on the amount of users currently available for that queue - in a project where usually all agents serve all queues.
So the final value needed would normally be the maximum of all on-queue users for all queues I pass to the data action - used to calculate the maximum allowable interactions in the queue based on a percentage of the available users. I am aware that there may be other approaches to achieve something similar, but this is also q question of "tradition" and experience in the operations team that has been monitoring this project on other telephony systems (allowing this approach) in the past.
The general approach works fine:
- I'm using endpoint /api/v2/analytics/queues/observations/query to get the oOnQueueUsers metric
- Filtering for mutliple queues works fine (the number of queues needs to be fixed, but the API can be tricked about that by just passing the same queue multiple times, allowing a variable amount of queues to be queried.
- The problem is the structure of the result, where on- as well as off-queue users are always parted into separate results by their "qualifier" aka the current presence routing status the are in.
- Also the result is an array in which the status information is not a child of the queue ID (or such). Instead the queue ID is on the same level.
I have tried to get this parsed via JSON path, but always end up having separate arrays returned - one with the queue IDs, one with the agents counts, one with the qualifiers. Aggregation functions do not seem to be work on this in JSON path - and as there is no guarantee to have all status qualifiers appearing for all queues, I don't see a way to get the output structured in a way that would allow me to parse the output accordingly in the flow to actually determine how many users are on-queue for which of the queues. Naturally I could call the data action separately for each queue - but this definitely doesn't seem an appropriate approach considering system ressources.
As I'm a rather a noob considering JSON path and velocity macros, I wonder if there may be any tricks to get what I am looking for.
Here's the request body I have been using:
{
"filter": {
"type": "and",
"clauses": [
{
"type": "or",
"predicates": [
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId1}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId2}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId3}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId4}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId5}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId6}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId7}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId8}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId9}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId10}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId11}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId12}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId13}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId14}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId15}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId16}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId17}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId18}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId19}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId20}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId21}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId22}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId23}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId24}"
},
{
"type": "dimension",
"dimension": "queueid",
"operator": "matches",
"value": "${input.queueId25}"
}
]
}
]
},
"metrics": [
"oOnQueueUsers"
]
}
And this is the best I could do considering the response:
{
"translationMap": {
"queueId": "$.results[].group.queueId",
"count": "$.results[].data[?(@.metric=='oOnQueueUsers')].stats.count",
"metric": "$.results[*].data[?(@.metric=='oOnQueueUsers')].qualifier"
},
"translationMapDefaults": {},
"successTemplate": "{"queueId": ${queueId}, "metric": ${metric}, "count": ${count}}"
}
Any help would be appreciated...