Legacy Dev Forum Posts

 View Only

Sign Up

Not able to find proper response data action config

  • 1.  Not able to find proper response data action config

    Posted 06-05-2025 18:41

    Daniel_Ondiviela | 2019-11-05 20:34:48 UTC | #1

    Hi, I'm calling Purecloud API from the architect (data action). I need to find count of OnQueue users (Idle) on a queue before making routing decisions to that queue. I have found the correct API call in Analytics API, and it's returning something like this:

    { "results": [ { "group": { "queueId": "e300000e-d5de-4ee6-ad9e-a14092aac028" }, "data": [ { "metric": "oOnQueueUsers", "qualifier": "INTERACTING", "stats": { "count": 0 } }, { "metric": "oOnQueueUsers", "qualifier": "IDLE", "stats": { "count": 1 } }, { "metric": "oOnQueueUsers", "qualifier": "NOT_RESPONDING", "stats": { "count": 0 } } ] } ] }

    That is the result of the "8.Execute" step in the data action when testing. Nevertheless, I always get error at step 9 ("Resolve translation map"). Question is, what do I have to configure in output contracts and configuration - response, to extract count for Onqueue - Idle users (1 on my example)?

    Only config that doesn't throw an error is

    { "translationMap": { "results": "$.results" }, "translationMapDefaults": {}, "successTemplate": "${rawResult}" }

    But that "results" is unusable. Any ideas? Thanks


    Jason_Mathison | 2019-11-05 20:42:47 UTC | #2

    Take a look at: https://developer.mypurecloud.com/forum/t/get-number-of-waiting-of-a-queue/2831

    It shows some examples of the what a translation map entry should look like in order to get the results where the qualifier is IDLE. I recommend copying the query results to jsonpath.com to refine your jsonpath expression.

    If you can't work it out post where you are stuck at for us to help you.

    --Jason


    Daniel_Ondiviela | 2019-11-05 20:55:09 UTC | #3

    I have just hit the correct key right now (after hours of trial & error)

    This config solved the problem:

    { "translationMap": { "OnQueueIddleCount": "$.results[0].data[1].stats.count" }, "translationMapDefaults": {}, "successTemplate": "{\n \"OnQueueIddleCount\": ${OnQueueIddleCount}\n}" }

    Thanks Jason


    Jason_Mathison | 2019-11-05 21:01:31 UTC | #4

    The data[1] in your translation map is somewhat risky, since the order of INTERACTING, IDLE, NOT_RESPONDING may not be fixed. I think that this data[?(@.qualifier=="IDLE")] would ensure you get the data that you are looking for.

    Also, I hate hearing "hours of trial & error". Do you have any suggestions for how to make this easier for the next person?


    Daniel_Ondiviela | 2019-11-05 22:20:18 UTC | #5

    I think documentation for this topic is scarce and not detailed enough when you expect complex output (mixed arrays + objects)

    https://help.mypurecloud.com/articles/response-configuration-data-actions/

    More complex examples there would help a lot


    Jason_Mathison | 2019-11-15 16:00:07 UTC | #6

    Got it, I have added this to my to-do list.


    system | 2019-12-16 16:00:11 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: 6412