Assistance with ConversationDetailQueryFilter and SegmentDetailQueryFilter to specifically filter

I'd like to use both the post_analytics_conversations_details_query and the post_analytics_conversations_details_job endpoints to retrieve conversation data, but I would like to restrict the output to conversations and segments, which both contain a conversation_end. Here's a snippet of the code I'm playing around with, but it appears to still return conversations without a conversation_end date.

I would be very grateful for some guidance on how best to accomplish this or if it's possible.

In addition, is it possible to leverage NumericRange to filter conversations by conversationEnd and how would that be done? I tried inputting a float datetime value for "value", but it didn't appear to filter anything.

Thank you!

import PureCloudPlatformClientV2 as PureCloud

conversation_filters = PureCloud.ConversationDetailQueryFilter()
conversation_filters_predicates = PureCloud.ConversationDetailQueryPredicate()
conversation_filters_clause = PureCloud.ConversationDetailQueryClause()
segment_filters = PureCloud.SegmentDetailQueryFilter()
segment_filters_predicates = PureCloud.SegmentDetailQueryPredicate()
segment_filters_clause = PureCloud.SegmentDetailQueryClause()

conversation_filters_predicates.dimension = 'conversationEnd'
conversation_filters_predicates.operator = 'exists'

segment_filters_predicates.dimension = 'segmentEnd'
segment_filters_predicates.operator = 'exists'

conversation_filters_clause.type = 'and'
segment_filters_clause.type = 'and'

conversation_filters.type = 'and'
segment_filters.type = 'and'

conversation_filters.predicates = conversation_filters_predicates
conversation_filters.clauses = conversation_filters_clause
segment_filters.predicates = segment_filters_predicates
segment_filters.clauses = segment_filters_clause

body=dict(interval='2019-12-11T21:38:57.037419+00:00/2019-12-11T22:38:57.037419+00:00')
body['conversation_filters'] = conversation_filters
body['segment_filters'] = segment_filters

# ignore this method below
api = set_api_instance(PureCloud.AnalyticsApi())
job_resp = api.post_analytics_conversations_details_query(body=body)

The easiest thing to do is to use the Dev Tools Analytics Query Builder to design and test your query, then implement that query in code. You're looking for a query like this:

{
 "interval": "2019-12-05T07:00:00.000Z/2019-12-12T07:00:00.000Z",
 "order": "asc",
 "orderBy": "conversationStart",
 "paging": {
  "pageSize": 25,
  "pageNumber": 1
 },
 "conversationFilters": [
  {
   "type": "or",
   "predicates": [
    {
     "type": "dimension",
     "dimension": "conversationEnd",
     "operator": "exists",
     "value": null
    }
   ]
  }
 ]
}

Okay, thanks, that's helpful, but what about this ^?

NumericRange only applies to metrics, and you cannot constrain a dimension in any way (exists/not exists and matches only). To get end timestamps in a given range, use the interval or post-process the results in your app to filter them.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.