Legacy Dev Forum Posts

 View Only

Sign Up

Data action filter or sort multiple outcomes by date. Help!

  • 1.  Data action filter or sort multiple outcomes by date. Help!

    Posted 06-05-2025 18:44

    Simon_McKenzie | 2023-11-11 19:48:22 UTC | #1

    I have a Data action that retrieves the Queue IDs from the interaction ID. I have the action working ok except i need to filter the outcomes based on the most recent date / time stamp - in other words the last Queue ID used prior to the call being transferred to my flow.

    Request URL Template used = /api/v2/conversations/${input.ConversationID} I have also tried /api/v2/analytics/conversations/details/query (Both give similar output) but couldn't get my code to work with

    "translationMap": { "queueId": "$.conversations.participants.sessions.segments[?(@.purpose=="acd")].queueId" },

    Action Contracts

    Response ========== { "translationMap": { "queueId": "$.participants[?(@.purpose == 'acd')].queueId" }, "translationMapDefaults": { "queueId": "[]" }, "successTemplate": "{\"queueId\" : ${queueId}}}" }

    Sample output =============

    OUTPUT ======== Here is some raw output showing the 3 different QUEUE IDs and their respective date/times

    "startTime": "2023-11-03T05:03:31.578Z", "connectedTime": "2023-11-03T05:03:31.588Z", "endTime": "2023-11-03T05:03:36.044Z",

    "queue": { "id": "f9db3793-7257-4fe8-afd0-d88db8b18c2a"

    "startTime": "2023-11-03T05:05:03.246Z", "connectedTime": "2023-11-03T05:05:03.254Z", "endTime": "2023-11-03T05:05:11.231Z",

    "queue": { "id": "0526460c-b7e7-46f8-a122-c6b8cc032672",

    "startTime": "2023-11-03T05:07:16.110Z", "connectedTime": "2023-11-03T05:07:16.119Z", "endTime": "2023-11-03T05:07:18.245Z",

    "queue": { "id": "a061dee5-4e1b-448d-81f9-a108d97a4401"

    NOTE - The interaction may go through NO Queues (a DDI call to an agent), 1 Queue, 2 or even 3 Queues prior to be transferred to my architect flow (on its way to a Survey), i

    Question ======== (1) is it possible to SORT the Queue ids retrieved based on most recent time at top? (2) if (1) is possible can i limit the outcome to show only the latest Queue ID? (3) is it possible to FILTER the outcome using the response code to only output the most recent Queue iD (based on its timestamp) I was thinking of using the successTemplateUtils.lastFromArray Macro ?


    Greg_Cunningham | 2023-11-13 15:09:07 UTC | #2

    Hi Simon,

    The /api/v2/analytics/conversations/details/query documents a sorting clause as "orderBy" which is conversationStart by default. That is the only sorting that is available with that API.

    orderBy

    (string) Specify which data element within the result set to use for sorting. The options to use as a basis for sorting the results: conversationStart, segmentStart, and segmentEnd. If not specified, the default is conversationStart. Valid values: conversationStart, conversationEnd, segmentStart, segmentEnd.

    For a worst case solution, you could return two arrays, the times and the queue ids, and use Architect to search for the index of the most recent time.


    system | 2023-12-14 15:09:25 UTC | #3

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