Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Defining Output Contracts

    Posted 06-03-2025 08:37

    Dear Team,

    I am getting the below Raw output for an API execution. I need to know how to define output contract, so it just retrieves the message array as a single object.

    Raw Output

    {
        "isSuccess": true,
        "conversationId": "123",
        "conversationType": "abc",
        "messages": [
            {
                "messageId": "2121",
                "message": "help me with resume building",
                "messages": null,
                "additionalAnswerAttributes": {},
                "messageType": "message",
                "messageSubType": "Question",
                "parentId": null,
                "isLiked": null,
                "files": null,
                "metadata": null,
                "createdDate": "2025-06-03",
                "purgeDate": "2025-09-01",
                "skill": {
                    "id": "01448",
                    "versionId": "9c5",
                    "name": ""
                }
            },
            {
                "messageId": "2f41",
                "message": "To build a resume follow 5 steps",
                "messages": null,
                "additionalAnswerAttributes": null,
                "messageType": "Message",
                "messageSubType": "Answer",
                "parentId": "195e",
                "isLiked": null,
                "files": null,
                "metadata": "abcd",
                "createdDate": "2025-06-03",
                "purgeDate": "2025-09-01",
                "skill": {
                    "id": "0144",
                    "versionId": "9c5",
                    "name": "Resume Builder"
                }
            }
        ]
    }
    Expected Output Format store it in messages variable
    Expected Output
    messages array
    [
            {
                "messageId": "2121",
                "message": "help me with resume building",
                "messages": null,
                "additionalAnswerAttributes": {},
                "messageType": "message",
                "messageSubType": "Question",
                "parentId": null,
                "isLiked": null,
                "files": null,
                "metadata": null,
                "createdDate": "2025-06-03",
                "purgeDate": "2025-09-01",
                "skill": {
                    "id": "01448",
                    "versionId": "9c5",
                    "name": ""
                }
            },
            {
                "messageId": "2f41",
                "message": "To build a resume follow 5 steps",
                "messages": null,
                "additionalAnswerAttributes": null,
                "messageType": "Message",
                "messageSubType": "Answer",
                "parentId": "195e",
                "isLiked": null,
                "files": null,
                "metadata": "abcd",
                "createdDate": "2025-06-03",
                "purgeDate": "2025-09-01",
                "skill": {
                    "id": "0144",
                    "versionId": "9c5",
                    "name": "Resume Builder"
                }
            }
        ]

    #DataActions

    ------------------------------
    Avinash C V
    ------------------------------


  • 2.  RE: Defining Output Contracts

    Posted 06-03-2025 13:05
    Edited by Jacob Shaw 06-03-2025 14:08

    Hi Avinash,

    Data actions aren't able to return arrays of objects at the top level of the response. However, you can use translationMap and successTemplate to return an object with one attribute, like this:

    {

        "messages": []

    }
    I tested this in my own data action that does something similar. Response config:

    Response:
    When testing, do not flatten the output.



    ------------------------------
    Jacob Shaw
    Sr. Software Engineer
    ------------------------------



  • 3.  RE: Defining Output Contracts

    Posted 06-04-2025 10:42

    Hi Jacob,

    Thank you for the update and for the prompt solution. I'm currently receiving the output as a raw JSON response. How can I establish the output contract so that all the data within the message array can be consolidated into a single array variable? I will need to utilize this array response in future API calls.

    The requirement is i need to define messages as array variable object and get all details. 



    ------------------------------
    Avinash C V
    ------------------------------