Retrieve only chat or message media type interactions

Hi there-

I've been wrestling with something all morning now.

I'm trying to pull message and chat interactions only over a date range.

I've been using the ConversationQuery class in the Python SDK. I can set the interval just fine and get results for all media types.

Can anyone help with how to apply filters to get only the chat and message media types? Maybe I'm using the wrong class/endpoint?

My ultimate goal is to get a list of conversation ids from a given date range so I can then look at the participant data for the customer.

Thanks,
Dan

Hello,

This should look like this:

    analytics_api = PureCloudPlatformClientV2.AnalyticsApi(apiClient)
    conv_query = PureCloudPlatformClientV2.ConversationQuery()
    conv_query.interval = '2025-02-06T00:00:00Z/2025-03-06T00:00:00Z'

    conf_segment_filter = PureCloudPlatformClientV2.SegmentDetailQueryFilter()
    conf_segment_filter.type = 'or'

    conf_segment_chat_filter = PureCloudPlatformClientV2.SegmentDetailQueryPredicate()
    conf_segment_chat_filter.type = 'dimension'
    conf_segment_chat_filter.dimension = 'mediaType'
    conf_segment_chat_filter.operator = 'matches'
    conf_segment_chat_filter.value = 'chat'

    conf_segment_message_filter = PureCloudPlatformClientV2.SegmentDetailQueryPredicate()
    conf_segment_message_filter.type = 'dimension'
    conf_segment_message_filter.dimension = 'mediaType'
    conf_segment_message_filter.operator = 'matches'
    conf_segment_message_filter.value = 'message'

    conf_segment_filter.predicates = [ conf_segment_chat_filter, conf_segment_message_filter ]
    
    conv_query.segment_filters = [ conf_segment_filter ]
    api_response = analytics_api.post_analytics_conversations_details_query(conv_query)

Regards,

Oooooh. Thank you so much. That helps a lot.

If I wanted my interval to be for America/Chicago, am I correct that I would need to edit the interval string itself rather than provide the time zone?

Yes, you would need to adapt the time in the interval.
2025-02-06T00:00:00Z/2025-03-06T00:00:00Z - the Z at the end means UTC time.

Regards,