Hello,
Using Conversation Details Query:
POST /api/v2/analytics/conversations/details/query
If you are looking for the oldest conversations (when conversation started), which are currently in queue, you have to use an:
"order": "asc",
"orderBy": "conversationStart",
If you only need to retrieve the oldest conversation, which is currently in queue, you could limit the results to 1 with:
"paging": {
"pageSize": "1",
"pageNumber": 1
},
I would also recommend to use a filter on mediaType (as you mention "calls") - so that it only looks at the oldest voice conversations (if your Queueu manages multiple media types).
Conversation Details Query example for the 25 oldest conversations, currently in queue:
{
"interval": "YOUR_INTERVAL",
"order": "asc",
"orderBy": "conversationStart",
"paging": {
"pageSize": "25",
"pageNumber": 1
},
"segmentFilters": [
{
"type": "and",
"predicates": [
{
"type": "dimension",
"dimension": "queueId",
"operator": "matches",
"value": "YOUR_QUEUE_ID"
},
{
"type": "dimension",
"dimension": "purpose",
"operator": "matches",
"value": "acd"
},
{
"type": "dimension",
"dimension": "segmentEnd",
"operator": "notExists",
"value": null
},
{
"type": "dimension",
"dimension": "mediaType",
"operator": "matches",
"value": "voice"
}
]
}
],
"conversationFilters": [
{
"type": "or",
"predicates": [
{
"type": "dimension",
"dimension": "conversationEnd",
"operator": "notExists",
"value": null
}
]
}
]
}
Data Action Contract and Configuration - oldestTimes and oldestConversations output parameter as arrays:
{
"config": {
"request": {
"requestUrlTemplate": "/api/v2/analytics/conversations/details/query",
"requestType": "POST",
"headers": {
"Content-Type": "application/json"
},
"requestTemplate": "{\n \"interval\": \"${input.interval}\",\n \"order\": \"asc\",\n \"orderBy\": \"conversationStart\",\n \"paging\": {\n \"pageSize\": \"25\",\n \"pageNumber\": 1\n },\n \"segmentFilters\": [\n {\n \"type\": \"and\",\n \"predicates\": [\n {\n \"type\": \"dimension\",\n \"dimension\": \"queueId\",\n \"operator\": \"matches\",\n \"value\": \"${input.queueId}\"\n },\n {\n \"type\": \"dimension\",\n \"dimension\": \"purpose\",\n \"operator\": \"matches\",\n \"value\": \"acd\"\n },\n {\n \"type\": \"dimension\",\n \"dimension\": \"segmentEnd\",\n \"operator\": \"notExists\",\n \"value\": null\n },\n {\n \"type\": \"dimension\",\n \"dimension\": \"mediaType\",\n \"operator\": \"matches\",\n \"value\": \"voice\"\n }\n ]\n }\n ],\n \"conversationFilters\": [\n {\n \"type\": \"or\",\n \"predicates\": [\n {\n \"type\": \"dimension\",\n \"dimension\": \"conversationEnd\",\n \"operator\": \"notExists\",\n \"value\": null\n }\n ]\n }\n ]\n}"
},
"response": {
"translationMap": {
"nbHits": "$.totalHits",
"timeStartArray": "$.conversations[*].conversationStart",
"convIdArray": "$.conversations[*].conversationId"
},
"translationMapDefaults": {
"nbHits": "0",
"timeStartArray": "[]",
"convIdArray": "[]"
},
"successTemplate": "{ \"nbWaiting\": ${nbHits}, \"oldestTimes\": ${timeStartArray}, \"oldestConversations\": ${convIdArray} }"
}
},
"contract": {
"input": {
"inputSchema": {
"type": "object",
"properties": {
"interval": {
"type": "string"
},
"queueId": {
"type": "string"
}
},
"additionalProperties": true
}
},
"output": {
"successSchema": {
"type": "object",
"properties": {
"nbWaiting": {
"type": "integer"
},
"oldestTimes": {
"type": "array",
"items": {
"title": "Item 1",
"type": "string"
}
},
"oldestConversations": {
"type": "array",
"items": {
"title": "Item 1",
"type": "string"
}
}
},
"additionalProperties": true
}
}
}
}
Conversation Details Query for the oldest conversation, currently in queue (only one returned)
Data Action Contract and Configuration - oldestTime and oldestConversation output parameter as strings:
{
"config": {
"request": {
"requestUrlTemplate": "/api/v2/analytics/conversations/details/query",
"requestType": "POST",
"headers": {
"Content-Type": "application/json"
},
"requestTemplate": "{\n \"interval\": \"${input.interval}\",\n \"order\": \"asc\",\n \"orderBy\": \"conversationStart\",\n \"paging\": {\n \"pageSize\": \"1\",\n \"pageNumber\": 1\n },\n \"segmentFilters\": [\n {\n \"type\": \"and\",\n \"predicates\": [\n {\n \"type\": \"dimension\",\n \"dimension\": \"queueId\",\n \"operator\": \"matches\",\n \"value\": \"${input.queueId}\"\n },\n {\n \"type\": \"dimension\",\n \"dimension\": \"purpose\",\n \"operator\": \"matches\",\n \"value\": \"acd\"\n },\n {\n \"type\": \"dimension\",\n \"dimension\": \"segmentEnd\",\n \"operator\": \"notExists\",\n \"value\": null\n },\n {\n \"type\": \"dimension\",\n \"dimension\": \"mediaType\",\n \"operator\": \"matches\",\n \"value\": \"voice\"\n }\n ]\n }\n ],\n \"conversationFilters\": [\n {\n \"type\": \"or\",\n \"predicates\": [\n {\n \"type\": \"dimension\",\n \"dimension\": \"conversationEnd\",\n \"operator\": \"notExists\",\n \"value\": null\n }\n ]\n }\n ]\n}"
},
"response": {
"translationMap": {
"nbHits": "$.totalHits",
"timeStart": "$.conversations[0].conversationStart",
"convId": "$.conversations[0].conversationId"
},
"translationMapDefaults": {
"nbHits": "0",
"timeStart": "\"\"",
"convId": "\"\""
},
"successTemplate": "{ \"nbWaiting\": ${nbHits}, \"oldestTime\": ${timeStart}, \"oldestConversation\": ${convId} }"
}
},
"contract": {
"input": {
"inputSchema": {
"type": "object",
"properties": {
"interval": {
"type": "string"
},
"queueId": {
"type": "string"
}
},
"additionalProperties": true
}
},
"output": {
"successSchema": {
"type": "object",
"properties": {
"nbWaiting": {
"type": "integer"
},
"oldestTime": {
"type": "string"
},
"oldestConversation": {
"type": "string"
}
},
"additionalProperties": true
}
}
}
}
Using Queue Observation Query:
POST /api/v2/analytics/queues/observations/query
You could also use a Queue Observation Query, if you are interested in the longest time in Queue.
What I mean is that:
A customer (Customer 1) calls; the call is put into a Queue for 3 mn; the customer is connected to an Agent.
A second customer (Customer 2) calls; the call is put into a Queue.
While Customer 2 is waiting in the Queue, the Agent transfers Customer 1 back to the Queue.
With the Conversation Details Query from above, you would capture Customer 1 as the oldest call.
With the Queue Observation Query, you can capture Customer 2 as the oldest call in this Queue.
Note that the query response will include a list of ongoing observations with up to 50 oldest and up to 50 newest observations.
Here is an example of Data Action only getting the oldest observation.
To retrieve multiples, the approach may be different than the one I have used for Conversation Details Query above. In theory, the Observation Query could retrieve up to 100 values. I have never tried in Architect if that would be a problem for a Collection of Strings.
Queue Observation Query example:
{
"filter": {
"type": "and",
"predicates": [
{
"type": "dimension",
"dimension": "queueId",
"operator": "matches",
"value": "YOUR_QUEUE_ID"
},
{
"type": "dimension",
"dimension": "mediaType",
"operator": "matches",
"value": "chat"
}
]
},
"metrics": ["oWaiting"],
"detailMetrics": ["oWaiting"]
}
Data Action Contract and Configuration:
{
"config": {
"request": {
"requestUrlTemplate": "/api/v2/analytics/queues/observations/query",
"requestType": "POST",
"headers": {
"Content-Type": "application/json"
},
"requestTemplate": "{\n \"filter\": {\n \"type\": \"and\",\n \"predicates\": [\n {\n \"type\": \"dimension\",\n \"dimension\": \"queueId\",\n \"operator\": \"matches\",\n \"value\": \"${input.queueId}\"\n },\n {\n \"type\": \"dimension\",\n \"dimension\": \"mediaType\",\n \"operator\": \"matches\",\n \"value\": \"voice\"\n }\n ]\n },\n \"metrics\": [\n \"oWaiting\"\n ],\n \"detailMetrics\": [\n \"oWaiting\"\n ]\n}"
},
"response": {
"translationMap": {
"nbHits": "$.results[0].data[0].stats.count",
"timeQueued": "$.results[0].data[0].observations[0].observationDate",
"convId": "$.results[0].data[0].observations[0].conversationId"
},
"translationMapDefaults": {
"nbHits": "0",
"timeQueued": "\"\"",
"convId": "\"\""
},
"successTemplate": "{ \"nbWaiting\": ${nbHits}, \"oldestTime\": ${timeQueued}, \"oldestConversation\": ${convId} }"
}
},
"contract": {
"input": {
"inputSchema": {
"type": "object",
"properties": {
"queueId": {
"type": "string"
}
},
"additionalProperties": true
}
},
"output": {
"successSchema": {
"type": "object",
"properties": {
"nbWaiting": {
"type": "integer"
},
"oldestTime": {
"type": "string"
},
"oldestConversation": {
"type": "string"
}
},
"additionalProperties": true
}
}
}
}
Regards,