Legacy Dev Forum Posts

 View Only

Sign Up

Assistance with ConversationDetailQueryFilter and SegmentDetailQueryFilter to specifically filter

  • 1.  Assistance with ConversationDetailQueryFilter and SegmentDetailQueryFilter to specifically filter

    Posted 06-05-2025 18:08

    trevorburke | 2019-12-11 22:10:39 UTC | #1

    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)

    tim.smith | 2019-12-11 23:04:38 UTC | #2

    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
        }
       ]
      }
     ]
    }

    trevorburke | 2019-12-11 23:27:10 UTC | #3

    trevorburke, post:1, topic:6699
    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.

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


    tim.smith | 2019-12-12 22:32:35 UTC | #4

    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.


    system | 2020-01-12 22:32:39 UTC | #5

    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: 6699