Maurice_Ford1 | 2022-11-01 20:28:09 UTC | #1
Hi,
I'm creating a data action using the POST /api/v2/analytics/conversations/aggregates/query to retrieve the service level for a specific queue and media type. I'm looking for help with either the output contract or response map, I'm not sure which one is incorrect but when I test, the value's returned in the JSON data but not in the output from the test. Any help would be greatly appreciated!
Here are the details:
Input:
{ "title": "Get Service Level", "description": "Service level for a specific queue.", "type": "object", "$schema": "http://json-schema.org/draft-04/schema#", "required": [ "INTERVAL", "QUEUEID" ], "properties": { "INTERVAL": { "description": "Interval", "type": "string" }, "QUEUEID": { "description": "The queue ID.", "type": "string" } }, "additionalProperties": true }
Output:
{ "type": "object", "properties": { "serviceLevel": { "type": "integer" } }, "additionalProperties": false }
Request:
{ "interval": "${input.INTERVAL}", "groupBy": [ "queueId", "mediaType" ], "filter": { "type": "and", "predicates": [ { "type": "dimension", "dimension": "queueId", "operator": "matches", "value": "${input.QUEUE_ID}" }, { "type": "dimension", "dimension": "mediaType", "operator": "matches", "value": "voice" } ] }, "views": [], "metrics": [ "oServiceLevel" ] }
Response Map:
{ "translationMap": { "serviceLevel": "$..results.data.metrics.stats.ratio[0][0][0]" }, "translationMapDefaults": {}, "successTemplate": "${rawResult}" }
API Response:
{ "results.data.metrics.stats.numerator": [ [ [ 66 ] ] ], "results.group.mediaType": [ "voice" ], "results.data.metrics.stats.target": [ [ [ 0.8 ] ] ], "results.data.metrics.stats.ratio": [ [ [ 1 ] ] ], "results.data.metrics.stats.denominator": [ [ [ 66 ] ] ], "results.data.interval": [ [ "2022-10-26T16:00:00.000Z/2022-10-26T16:30:00.000Z" ] ], "results.group.queueId": [ "[queueId]" ], "results.data.metrics.metric": [ [ [ "oServiceLevel" ] ] ] }
Jason_Mathison | 2022-11-01 20:35:39 UTC | #2
Hi Maurice,
Can you post the (redacted if needed) results of the "Execute" step of testing your data action? It looks like you posted the "flattened" output.
--Jason
Maurice_Ford1 | 2022-11-02 13:43:24 UTC | #3
Hi Jason,
Sure thing, see below.
{ "results": [ { "group": { "mediaType": "voice", "queueId": "54793840-2446-4c1f-a86b-f1ab69fc7e5b" }, "data": [ { "interval": "2022-10-26T16:00:00.000Z/2022-10-26T16:30:00.000Z", "metrics": [ { "metric": "oServiceLevel", "stats": { "ratio": 1, "numerator": 66, "denominator": 66, "target": 0.8 } } ] } ] } ] }
Jerome.Saint-Marc | 2022-11-02 17:07:55 UTC | #4
Hello,
As you seem to be trying to retrieve the ratio value, you should change your Output Contract and define serviceLevel output parameter as a number (the ratio attribute is of type number).
{ "type": "object", "properties": { "serviceLevel": { "type": "number" } }, "additionalProperties": false }
Regarding the Response Configuration, you could use this:
{ "translationMap": { "vServiceLevel": "$.results[0].data[0].metrics[0].stats.ratio" }, "translationMapDefaults": { }, "successTemplate": "{\"serviceLevel\":${vServiceLevel}}" }
Regards,
Maurice_Ford1 | 2022-11-02 17:08:13 UTC | #5
That worked, thank you @Jerome.Saint-Marc .
system | 2022-12-03 17:08:17 UTC | #6
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 16989