andygunther | 2017-08-10 01:51:31 UTC | #1
I'm working on a query to try and fetch currently active calls for a particular user.
I've found that the analytics/conversations/details/query requires an interval (even though the docs say it's optional).
If I debug the actual PureCloud UI, I see that the API call being made when pulling up an agent's connected interactions is:
https://apps.mypurecloud.com/platform/api/v1/conversations/query/
The body for this API call allows a filter that doesn't require an interval (example):
{"pageSize":100,"filters":[{"target":"agentId","operator":"=","values":["df2c4619-d217-4a02-bba6-69faa4572481" ]},{"target":"active","operator":"=","values":[true]}]}
What is the best way to fetch a list of active calls for a user? Should I be using this older v1 API call, or is there an interval value that would represent "Now"? Or, do I need to just set an interval with the same start/stop time representing now?
tim.smith | 2017-08-10 15:58:11 UTC | #2
The v1 API is deprecated and shouldn't be used; it will be shut down without warning in the future. There are some lingering usages in the UI, which is why it hasn't been deactivated yet.
Using POST /api/v2/analytics/conversations/details/query, the query below will filter for conversations that haven't ended, that a given user was involved in, and are voice calls. However, note that this returns active calls that the user was involved in at any point. So even if the user completed the call by transferring it to a user/queue and completed wrap up, this query will still return that conversation as long as the call is still active somewhere in PureCloud. I'm not aware of a way to filter those calls out, but I'll update if I find any more information.
{
"interval": "2017-08-10T06:00:00.000Z/2017-08-11T06:00:00.000Z",
"order": "asc",
"orderBy": "conversationStart",
"paging": {
"pageSize": 25,
"pageNumber": 1
},
"segmentFilters": [
{
"type": "and",
"predicates": [
{
"type": "dimension",
"dimension": "userId",
"operator": "matches",
"value": "9ed7d9f6-0c59-4360-ac54-40dd35eb9c2f"
},
{
"type": "dimension",
"dimension": "mediaType",
"operator": "matches",
"value": "voice"
}
]
}
],
"conversationFilters": [
{
"type": "or",
"predicates": [
{
"type": "dimension",
"dimension": "conversationEnd",
"operator": "notExists",
"value": null
}
]
}
]
}
andygunther | 2017-08-10 17:44:04 UTC | #3
Would there be a way to modify this to only match if the user id matches a segment without a "disconnectType" ?
andygunther | 2017-08-10 17:46:36 UTC | #4
Like so? Would this mean only calls that the user id is still on?
{ "interval": "2017-08-10T06:00:00.000Z/2017-08-11T06:00:00.000Z", "order": "asc", "orderBy": "conversationStart", "paging": { "pageSize": 25, "pageNumber": 1 }, "segmentFilters": [ { "type": "and", "predicates": [ { "type": "dimension", "dimension": "userId", "operator": "matches", "value": "6d61871f-2faf-4a32-bad5-2728c3161eb9" }, { "type": "dimension", "dimension": "mediaType", "operator": "matches", "value": "voice" }, { "type": "dimension", "dimension": "disconnectType", "operator": "notExists", "value": null } ] } ], "conversationFilters": [ { "type": "or", "predicates": [ { "type": "dimension", "dimension": "conversationEnd", "operator": "notExists", "value": null } ] } ] }
tim.smith | 2017-08-10 18:43:21 UTC | #5
It turns out there's an undocumented dimension segmentEnd that you should be able to add a filter for notExists in the segment filters (where the user id filter is). Make sure the segment filters are set to type=and.
andygunther | 2017-08-10 19:36:30 UTC | #6
Awesome, thanks! That looks to work like I'd hoped.
system | 2017-09-10 19:36:33 UTC | #7
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: 1664