Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Data Action guidance required for passing past of JSON result as String to Architect

    Posted 08-18-2025 04:14

    Hello Community,

    I need some guidance to help me understand how I can setup Data Action such that I receive a set of JSON result as String in Architect, which I can then convert back to JSON and use.

    My results look something like this;

    {
      "result": {
        "resultSummary": {
          "totalMatches": 2,
          "complateMatches": 2,
          "incompleteMatches": 0
        },
        "persons": [
          {
            "firstName": "xyz",
            "lastName": "abc",
            "contactDetails": [
              {
                "phoneNumber": "1234567890",
                "countryCode": "44",
                "phoneType": "mobile",
                "contactState": "primary"
              },
              {
                "phoneNumber": "9876543210",
                "countryCode": "44",
                "phoneType": "mobile",
                "contactState": "secondary"
              }
            ]
          }
        ]
      }
    }

    Based on the above I am not able to setup Data Action contact or successTemplate to return the whole of "persons" array structure as an string output. I tried various options but can't seem to get it working. Maybe as there are nested arrays in the results, it has an issue, not sure.

    Any guidance would be really appreciated.

    Regards


    #Unsure/Other

    ------------------------------
    Vineet Kakroo
    Senior Technical Consultant
    ------------------------------


  • 2.  RE: Data Action guidance required for passing past of JSON result as String to Architect

    Posted 08-18-2025 10:58

    Hi Vineet,

    I am going to move this over to Genesys Cloud - Developer Community as the experts there will be better placed to answer this.



    ------------------------------
    Sam Jillard
    Online Community Manager/Moderator
    Genesys - Employees
    ------------------------------



  • 3.  RE: Data Action guidance required for passing past of JSON result as String to Architect

    Posted 08-19-2025 10:42

    Take a look at the Resource Center article on Velocity Macros  and read up on esc.jsonEncode

    You can escape the JSON response output from the data action then unescape the JSON in Architect and use it there



    ------------------------------
    George Ganahl GCCX-AI, GCP, GCSME, ICCE, ICHD, etc.
    Technical Adoption Champion
    Genesys
    2024 Community Member of the Year
    ------------------------------



  • 4.  RE: Data Action guidance required for passing past of JSON result as String to Architect

    Posted 08-19-2025 11:04

    Thanks George. Yes I had already check the resource and tried esc.jsonEncode but does not work. Maybe I am missing something.

    My output contract looks like;

    {
      "title": "Output",
      "type": "object",
      "properties": {
        "Result_Information": {
          "type": "string"
        }
      }
    }
    My response looks like this;
    {
      "translationMap": {
        "Result_Information": "$.results"
      },
      "translationMapDefaults": {
        "Result_Information": ""
      },
      "successTemplate": "\"Result_Information\": $esc.jsonEncode(${Result_Information})"
    }
    And based on this I get the error;
    Validate output against schema: JSON failed output schema validation because it was malformed JSON. reason: 'Unrecognized token 'Result_Information': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 19]'


    ------------------------------
    Vineet Kakroo
    Senior Technical Consultant
    ------------------------------



  • 5.  RE: Data Action guidance required for passing past of JSON result as String to Architect

    Posted 08-19-2025 13:57

    Probably because the $.results contains an array, it's not just a string



    ------------------------------
    George Ganahl GCCX-AI, GCP, GCSME, ICCE, ICHD, etc.
    Technical Adoption Champion
    Genesys
    2024 Community Member of the Year
    ------------------------------



  • 6.  RE: Data Action guidance required for passing past of JSON result as String to Architect

    Posted 08-19-2025 14:22

    @Jason Mathison thoughts?



    ------------------------------
    George Ganahl GCCX-AI, GCP, GCSME, ICCE, ICHD, etc.
    Technical Adoption Champion
    Genesys
    2024 Community Member of the Year
    ------------------------------



  • 7.  RE: Data Action guidance required for passing past of JSON result as String to Architect

    Posted 08-20-2025 02:01

    Hello,

    According to the response example you have posted, $.results is not the right path. Your structure is named "result".

    And as you are trying to retrieve the persons array, you could use this path: $.result.persons

    Your response contract should be something like this:

    {
      "translationMap": {
        "personsArray": "$.result.persons"
      },
      "translationMapDefaults": {
        "personsArray": "[]"
      },
      "successTemplate": "{ \"Result_Information\": \"$esc.jsonEncode(${personsArray})\" }"
    }

    Regards,



    ------------------------------
    Jerome Saint-Marc
    Senior Development Support Engineer
    ------------------------------



  • 8.  RE: Data Action guidance required for passing past of JSON result as String to Architect

    Posted 08-20-2025 03:59

    Thank you Jerome. Yes this worked, and the only difference I had on my various attempts was that I had not enclosed the $esc.jsonEncode in \". Once I did this, it worked.

    Regards



    ------------------------------
    Vineet Kakroo
    Senior Technical Consultant
    ------------------------------



  • 9.  RE: Data Action guidance required for passing past of JSON result as String to Architect

    Posted 08-20-2025 08:29

    Thanks, Jerome! I missed that detail.



    ------------------------------
    George Ganahl GCCX-AI, GCP, GCSME, ICCE, ICHD, etc.
    Technical Adoption Champion
    Genesys
    2024 Community Member of the Year
    ------------------------------