Hello,
I've managed to get it working. I'll post my config, in case someone has the same question:
Scenario: provide the number of calls waiting in a certain queue:
Input Contract
queueId= the id of the queue
mediaType= the type of media (callback, chat, cobrowse, email, screenshare, voice)
metric= oWaiting
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"queueId": {
"type": "string"
},
"mediaType": {
"type": "string"
},
"metric": {
"type": "string"
}
}
}
Output Contract
queueId = returned same as request
mediatype= returned same as request
metric = returned same as request
count = number of calls waiting in the queue.{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"queueId": {
"type": "string"
},
"mediaType": {
"type": "string"
},
"count": {
"type": "number"
},
"metric": {
"type": "string"
}
}
}
Request Configuration
{
"requestUrlTemplate": "https://api.mypurecloud.ie/api/v2/analytics/queues/observations/query",
"requestType": "POST",
"headers": {
"Transfer-Encoding": "buffered",
"Authorization": "bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"content-type": "application/json"
},
"requestTemplate":
"{\"filter\":{\"type\": \"and\", \"clauses\": [{ \"type\": \"and\", \"predicates\": [{ \"type\":
\"dimension\", \"dimension\": \"queueId\", \"operator\": \"matches\", \"value\": \"${input.queueID}\"}]}], \"predicates\": [{ \"type\": \"dimension\", \"dimension\": \"mediaType\", \"operator\":
\"matches\", \"value\": \"${input.mediaType}\"}]}, \"metrics\":[ \"${input.metric}\"]}"}
Response Configuration
{
"translationMap": {
"count": "$.results[0].data[0].stats.count",
"queueId": "$.results[0].group.queueId",
"mediaType": "$.results[0].group.mediaType",
"metric": "$.results[0].data[0].metric"
},
"translationMapDefaults": {},
"successTemplate": "{\"mediaType\": ${mediaType},\"queueId\": ${queueId},\"metric\": ${metric},\"count\": ${count}}"
}
------------------------------
Steven Deferme
Quant ICT
------------------------------
Original Message:
Sent: 09-27-2018 04:57
From: Steven Deferme
Subject: Web Service Data Actions - Analytics Query Builder
I managed to get a raw response, but the translation fails.
I get response:
{
"results": [
{
"group": {
"mediaType": "voice",
"queueId": "637a6cb2-ad14-4213-a354-988015a21e7a"
},
"data": [
{
"metric": "oWaiting",
"stats": {
"count": 0
}
}
]
}
]
}
But the translation fails:
{
"status": 400,
"code": "bad.request",
"message": "Failed while processing the translation map. Could not resolve value for the key: 'count' and no default value was configured. Additional details: No results for path: $['count']",
"messageParams": {},
"contextId": "4c195cd6-2b05-4ca7-af1d-f332bc15db3e",
"details": [],
"errors": []
}
I use this response configuration:
{
"translationMap": {
"count": "$.count",
"mediaType": "$.mediaType",
"queueId": "$.queueId"
},
"translationMapDefaults": {},
"successTemplate": "{\"results\": [{\"group\": {\"mediaType\": ${mediaType},\"queueId\": ${queueId}},\"data\": [{\"metric\": \"oWaiting\",\"stats\": {\"count\": ${count}}}]}]}"
}
------------------------------
Steven Deferme
Quant ICT
Original Message:
Sent: 09-26-2018 19:09
From: Steven Deferme
Subject: Web Service Data Actions - Analytics Query Builder
Hello,
I would like to know if it is possible to transform a Queue Observation Query (created with Developer Tools) into an Integration Action (Web Services Data Actions).
I have a json request body, and response body, but I can't seem to map them into the required Input/output contracts and request/response configurations.
I would like to use a Web Service Data Action to be able to get the waiting callers in a Queue, for displaying in a script.
Generated Query:
{ "filter": { "type": "and", "predicates": [ { "type": "dimension", "dimension": "queueId", "operator": "matches", "value": "97e24b6b-1692-4aef-81db-573aa90de81a" }, { "type": "dimension", "dimension": "mediaType", "operator": "matches", "value": "voice" } ] }, "metrics": [ "oWaiting" ]}
Query Result:
{ "results": [ { "group": { "mediaType": "voice", "queueId": "97e24b6b-1692-4aef-81db-573aa90de81a" }, "data": [ { "metric": "oWaiting", "stats": { "count": 0 } } ] } ]}
Thx in advance
------------------------------
Steven Deferme
Quant ICT
------------------------------