Legacy Dev Forum Posts

 View Only

Sign Up

PureCloud Data Action - Error 400 Get users on queue - need help

  • 1.  PureCloud Data Action - Error 400 Get users on queue - need help

    Posted 06-05-2025 18:40

    gvasagam | 2018-07-24 10:52:02 UTC | #1

    Hello, I am trying to use routing rule based on user availability in particular queue ( oOnQueueUsers ). After going through forum posts and resources pages, was able to create a custom data action to retrieve the count of 'on queue' users.

    However, The action fails with Error 400, when there are no users on queue, as the API doesn't return oOnQueueUsers metric when there is no value.

    Here is the data action config used :

    <a class="attachment" href="/forum/uploads/db6296/original/1X/3b5aba0fe20818e9a294d38e158d8baf094bdf18.json">GetOnQueueUsers1.json</a> (1.6 KB)

    Tried a slightly different version of the data action which returns the flattened output of all metrics and stats with count as an array. However, I am unable to use it in Architect call flow as I see "Success Outputs" as below :

    and the config of the modified data action :

    <a class="attachment" href="/forum/uploads/db6296/original/1X/3c9dc5070b680a2d7acecc8c420e6e7af2429d5a.json">GetOnQueueUsersModified.json</a> (2.1 KB)

    Appreciate any help in getting this right as I am just learning to handle APIs. I am not sure if I can just use the first version of the data action configuration and consider that there are no agents 'on queue' if the data action result takes Failure path.


    Jason_Mathison | 2018-07-24 13:34:23 UTC | #2

    I am not sure if I can just use the first version of the data action configuration and consider that there are no agents 'on queue' if the data action result takes Failure path.

    That is a completely reasonable approach. We have a task in our backlog for situations like this. It would allow you to set a default translation map value when the response we get back from the web service varies. Internally this is BPIVR-1537, I can't give you a timeline for if or when this will ever be done.

    Moving on to your second version of this. The 'No output value specified" is not an error. It is expecting you to hit the drop down arrow to the right of "No output value specified", choose variable, and pick or create a variable to assign the value to.

    Finally, in the second version of your action, you would need to remove the "results" and "data" levels from the object as you are stripping them out in your translation map.

    If you go down the second action path I think you would end up with a "Not Set" variable in architect if there are no agents. I'm not sure if that would be easier or harder to handle than the data action taking the error path, it would probably depend on your other logic.


    gvasagam | 2018-07-25 03:05:01 UTC | #3

    Hi Jason, Many thanks for the detailed response. I think I will go with the first version for now.

    p.s. I did try a few more iterations of the data action and was able to get the attached configuration <a class="attachment" href="/forum/uploads/db6296/original/1X/6bcf60d7299df256954c8269f993c5345fc25375.json">GetUsersinqueueVer-3-2018072583151.custom.json</a> (1.4 KB) work flawlessly when testing it via the test option in the data action. It returned exact users count on queue as,

    { "metrics": [ 1 ] }

    and the query returned just { } when there was no one on the queue. At least the result was successful in both cases and did not get any error.

    However, when I attempted to use this config in the call flow by capturing the result in a variable and use it in a decision box, after success path of the 'Call data action' node, the results were :

    Decision node expression: IsSet(Task.QueueStatus) - The decision was always failing no matter what the data action result was. Decision node expression: Task.QueueStatus>0 - Call was always failing at decision node and I hear 'Event-handling' audio - "Sorry, an error occurred..."

    It may be that I am trying to use incorrect operators wrt to the data type being returned, however not sure why IsSet() function was failing though.


    Jason_Mathison | 2018-07-25 12:07:11 UTC | #4

    Thank you for posting the export! I found a couple of problems with that version of your action.

    The first issue is that your output contract was returning a variable named "results.data.metrics.stats.count", however your success template was returning a variable named "metrics". In other words, results.data.metrics.stats.count was never being set, which is why it would always fail an isSet check in architect (or blow up your flow if you tried to access it).

    Once that was fixed, there was another issue. This output isn't quite what you want.

    gvasagam, post:3, topic:3232
    { "metrics": [ 1 ] }

    metrics is actually an an array, with one element in it, a 1. Based on your output contract you actually want to return only an integer. This calls for our old friend successTemplateUtils.firstFromArray. Here is a working success template:

    "successTemplate": "{\"metrics\": ${successTemplateUtils.firstFromArray(\"${metrics}\", \"0\")}}"

    Note that a second parameter of "0" is passed in. If the metrics array is empty (due to no agents being logged in) the action will return 0 instead of blowing up.

    Attached is my version of this action which passed my extensive "Does this work with 0 or 1 agents" test.<a class="attachment" href="/forum/uploads/db6296/original/1X/ed40972e5001ed483268f86c8f849bd4d60df070.json">GetUsersinqueueVer-3---Exported-2018-07-25--831-2018072580513.custom.json</a> (1.4 KB)


    gvasagam | 2018-07-25 13:57:34 UTC | #5

    Hi Jason,

    This is exactly what I was trying to arrive at. The success template modification to add zero for negative scenario made all the difference.

    I really appreciate your help in getting this right. Thank you ! :grinning:


    system | 2018-08-25 13:57:36 UTC | #6

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