Genesys Cloud - Developer Community!

 View Only

Sign Up

Expand all | Collapse all

Data Action Failure on Integer Collection

  • 1.  Data Action Failure on Integer Collection

    Posted 21 days ago

    Hi,

    Has anyone had issues with using a POST API (/api/v2/analytics/flows/observations/query/) from within a inbound call flow. I'm attempting to understand flow metrics and based on the result route differently.

    I've used the above API and in my data action is works perfectly, but seeing a failure when running the data action in a architect flow. If I remove the variable assigned to the 'oflow' 'count' then the data action does not fail, but if used it fails all the time and I'm thinking it's to do with the output being a integer collection.

    Any ideas ?

    Regards, 


    #Architect
    #DataActions

    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------


  • 2.  RE: Data Action Failure on Integer Collection

    Posted 21 days ago

    Hi Neil,

    From what I can see and understand from the screenshots, it doesn't look like the integer value itself is the issue. The Data Action test succeeds, and the count value for the oFlow metric is valid.

    It looks more like a response structure / collection issue. The Analytics API response includes nested arrays under results and data, so fields like metric and stats.count are part of a collection. If Architect is trying to map those directly into single-value variables, that can fail even though the API response itself is fine.

    If you keep the current response structure, you may need to use GetAt() or similar collection handling in Architect to access the first item in those arrays. The cleaner option, though, would be to flatten the Data Action response in the success template and only return the exact fields you need.

    For example, instead of returning the full nested response structure, the success template could return something like:

    {
      "flowId": "${rawResult.results[0].group.flowId}",
      "mediaType": "${rawResult.results[0].group.mediaType}",
      "metric": "${rawResult.results[0].data[0].metric}",
      "count": ${rawResult.results[0].data[0].stats.count}
    }

    If you go that route, I would also update the output contract to match the flattened response, for example

    • flowId = string
    • mediaType = string
    • metric = string
    • count = integer

    That should make the Architect mapping much cleaner and more reliable.

    Hope this helps and hopefully someone from community might add more to this.

     



    ------------------------------
    Phaneendra
    Technical Solutions Consultant
    ------------------------------



  • 3.  RE: Data Action Failure on Integer Collection

    Posted 18 days ago

    Hi,

    Thank you for responding. Most likely my syntax but the response map json is giving an error ?

    Regards,



    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------



  • 4.  RE: Data Action Failure on Integer Collection

    Posted 18 days ago
    Edited by Kaio Oliveira 18 days ago

    Hi Neil 

    I Believe your count needs to be in quotation marks even if it's an integer.

    "translationMap": {
      "flowId": "${rawResult.results[0].group.flowId}",
      "mediaType": "${rawResult.results[0].group.mediaType}",
      "metric": "${rawResult.results[0].data[0].metric}",
      "count": "${rawResult.results[0].data[0].stats.count}"   <<<<<<<<<<<< HERE
    },
    "translationMapDefaults": {}



    ------------------------------
    Kaio Oliveira
    GCP - GCQM - GCS - GCA - GCD - GCO - GPE & GPR - GCWM

    PS.: I apologize if there are any mistakes in my English; my primary language is Portuguese-Br.
    ------------------------------



  • 5.  RE: Data Action Failure on Integer Collection

    Posted 18 days ago

    Thanks Kaio that may help with the immediate JSON syntax error around count.

    If it still does not work after that, another option to try may be using the nested paths in the translationMap and then flattening the response in the successTemplate, for example:

    {
      "translationMap": {
        "flowId": "$.results[0].group.flowId",
        "mediaType": "$.results[0].group.mediaType",
        "metric": "$.results[0].data[0].metric",
        "count": "$.results[0].data[0].stats.count"
      },
      "translationMapDefaults": {},
      "successTemplate": "{\"flowId\":\"${flowId}\",\"mediaType\":\"${mediaType}\",\"metric\":\"${metric}\",\"count\":${count}}"
    }

    My thinking is that quoting count may resolve the JSON validation issue first, and if the action still has trouble in Architect after that, flattening the response may be the next thing to try.



    ------------------------------
    Phaneendra
    Technical Solutions Consultant
    ------------------------------



  • 6.  RE: Data Action Failure on Integer Collection

    Posted 17 days ago

    Morning,

    You are correct and I've dropped in the map suggestion, but for some reason I'm seeing a different failure - see attached. I've even taken out the mapping for mediaType, metric and count so just using flowId but I see the same error.

    You can see in the error that it's picking up the mapping correctly, but for some reason need a comma - just not sure where & why.

    Regards,



    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------



  • 7.  RE: Data Action Failure on Integer Collection

    Posted 17 days ago

    Thank you Kaio.

    Did fix the immediate json error, but sadly the data action still fails.

    Regards,



    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------



  • 8.  RE: Data Action Failure on Integer Collection

    Posted 17 days ago

    Hi Neil, can you try below

    {
      "translationMap": {
        "flowId": "$.results[0].group.flowId",
        "mediaType": "$.results[0].group.mediaType",
        "metric": "$.results[0].data[0].metric",
        "count": "$.results[0].data[0].stats.count"
      },
      "translationMapDefaults": {},
      "successTemplate": "{\"flowId\":\"${flowId}\",\"mediaType\":\"${mediaType}\",\"metric\":\"${metric}\",\"count\":${count}}"
    }



    ------------------------------
    Phaneendra
    Technical Solutions Consultant
    ------------------------------



  • 9.  RE: Data Action Failure on Integer Collection

    Posted 17 days ago

    Hi,

    Thanks for all your help...

    I've adjusted the success template to "successTemplate": "{\"flowId\":${flowId},\"mediaType\":${mediaType},\"metric\":${metric},\"count\":${count}}" and no errors and response is correct. TBH I think if I use this new data action in my architect flow it will still fail as when running with the 'flatten output' field selected I receive an nested array error.

    Full response is:

    {
      "translationMap": {
        "flowId": "$.results[0].group.flowId",
        "mediaType": "$.results[0].group.mediaType",
        "metric": "$.results[0].data[0].metric",
        "count": "$.results[0].data[0].stats.count"
      },
      "translationMapDefaults": {},
      "successTemplate": "{\"flowId\":${flowId},\"mediaType\":${mediaType},\"metric\":${metric},\"count\":${count}}"
    }
    Regards,


    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------



  • 10.  RE: Data Action Failure on Integer Collection
    Best Answer

    Posted 17 days ago
    Edited by Neil Jones 17 days ago

    Hi Neil,

    This screenshot is helpful. The response itself now looks flat and valid, so I don't think the problem is the successTemplate anymore.

    The remaining Flatten Output error looks more like the output contract/schema still contains the earlier nested array structure. Even though the returned JSON is now just flowId, mediaType, metric, and count, the action tester seems to still be validating a schema with nested arrays when Flatten Output is selected.

    So the next thing I would check is the output contract and make sure it has been simplified to only these fields:

    • flowId = string
    • mediaType = string
    • metric = string
    • count = integer

    If the contract still contains the old results / data / stats array structure anywhere, I think that would explain the flatten error.

    Hope this helps and hopefully someone from community might add more to this.



    ------------------------------
    Phaneendra
    Technical Solutions Consultant
    ------------------------------



  • 11.  RE: Data Action Failure on Integer Collection

    Posted 17 days ago

    Thank you so much for you help - all working as expected both data action in isolation & via architect flow.

    As you said just needed to update the output contracts once the comma error was rectified - see below...

    Appreciate all your help.

    Regards,



    ------------------------------
    Neil Jones
    Voice Comms Lead
    Awaze Uk
    neil.jones@awaze.com
    ------------------------------



  • 12.  RE: Data Action Failure on Integer Collection

    Posted 17 days ago
    Edited by Phaneendra Avatapalli 17 days ago

    Good to know it's all working thank you  for confirming.



    ------------------------------
    Phaneendra
    Technical Solutions Consultant
    ------------------------------