Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Return error Message on output contracts

    Posted 04-02-2025 11:27

    I need to return the error message or status code to an output contract so I can flag the type of error on Architecht for future reports.

    For example: I send the get request with a ID that exists and the data action returns the fields I need. But when I send an ID that does ot have any register, the data action fails to execute instead of returning the error message as I configured, so I can know if was a 404, 500...

    Here's how I expecting to treat return the errorMessage on the successTemplate:

    {
      "translationMap": {
        "errorMessage": "$.message",
        "lineOfBusinessNames": "concat($[*].lineOfBusinessName)"
      },
      "translationMapDefaults": {
        "errorMessage": ""
      },
      "successTemplate": "{ \"lineOfBusinessNames\": ${lineOfBusinessNames}, \"errorMessage\": \"${errorMessage}\" }"
    }
    Is this a normal behavior of Data Actions and I can't do what i'm expecting, or is there a way to solve this?

    #DataActions

    ------------------------------
    Samara Silva
    ------------------------------


  • 2.  RE: Return error Message on output contracts

    Posted 04-02-2025 20:01

    This is the normal behaviour. HTTP status are not returned to the data action. So this error will always result in a data action failure but does not tells us the reason

    Mike



    ------------------------------
    Mike Hardie
    Developer
    ------------------------------



  • 3.  RE: Return error Message on output contracts

    Posted 04-08-2025 14:22

    The situation is a bit more complicated.  Data Actions do return a variety of information when they get a non 2xx response from the remote endpoint (or timeout waiting for a response).  However in voice flows the underlying voice xml engine is not making it available to the rest of the flow.  Other kinds of flows like Digital flows and workflows should provide the error response data.

    You can vote and add comments for an idea to add better data action error handling to flows:  https://genesyscloud.ideas.aha.io/ideas/OPCFDA-I-1



    ------------------------------
    Jason Mathison
    Lead Software Engineer
    Genesys
    ------------------------------



  • 4.  RE: Return error Message on output contracts

    Posted 04-02-2025 23:52

    What you'll want to do is have your developer that looks after that API return a 200 ok for every query and include the response/error in an actual JSON object/string.



    ------------------------------
    Vaun McCarthy
    ------------------------------



  • 5.  RE: Return error Message on output contracts

    Posted 04-03-2025 16:00
    Edited by Paul McGurn 04-03-2025 16:01

    Agree here.  While I have a love/hate relationship with API's that use this pattern, Slack is a prime example of that.

    All their API calls have a node like "ok": false when a call is successful but the actual activity fails.  This won't get you HTTP errors, though.  Voice interactions have never supported passing the error messaging from the data action to the Architect flow.  It's been a feature request for years.  Feel free to up-vote.  We can't ask every company with an API to handle this pattern this way, because we'd STILL want to be able to process HTTP response errors in addition to "request was received but fails because you didn't format it properly" scenarios that don't throw a HTTP 400 on API's like Slack's.
    ------------------------------
    Paul McGurn
    Senior Manager, Telecom & DevOps
    Persistent Systems
    ------------------------------



  • 6.  RE: Return error Message on output contracts

    Posted 04-03-2025 17:09

    Another way around it is to create a Function Data Action that executes the required data actions using fetch. You can then catch the http and repackage the response back to the DA caller. 

    Not exactly straight forward but it does work. The DA is executed under the credentials of the original integration so will work.

    Mike



    ------------------------------
    Mike Hardie
    Developer
    ------------------------------



  • 7.  RE: Return error Message on output contracts

    Posted 04-04-2025 08:24

    Hi Mike,

    Thanks for the reply.  Samara if you have not written a Genesys Cloud Function, I would take a look at the following:

    Genesys Cloud Functions Devdrop Series
    Genesys Cloud Functions Blog 



    ------------------------------
    John Carnell
    Director, Developer Engagement
    ------------------------------



  • 8.  RE: Return error Message on output contracts

    Posted 04-08-2025 14:31

    Hello.

    In my case, maybe we will have to develop a second API to communicate with the client API and return the status code to the data action.

    Thank you all for the explanations, it was very enlightening!



    ------------------------------
    Samara Silva
    ------------------------------