Return entire JSON object with data action

We are attempting to gather all participant data (from the external participant specifically) in a single JSON object. The data action seems to work and the raw JSON looks like what we want. However, we are having trouble getting the output contract to show the return object and allow us to use it. The reason for doing so is that we will be sharing the participant data with an external service and we need all the keys and values to pass along to this service.

We are calling this api:
/api/v2/conversations/${input.conversationId}

Using this response template:
{
"translationMap": {
"attributes": "$.participants[0].attributes"
},
"translationMapDefaults": {},
"successTemplate": "{\n "attributes": ${attributes}\n}"
}

Because our list of participant data be different from time to time, we want to be able to gather ALL existing properties, regardless of how many there are. I think this may be where we are getting into trouble as it seems that output contracts want you to go to an individual property and return the value - whereas we want keys and values of everything. Does anyone know of a way to do this? Here is the return JSON we're getting:

{
"attributes": {
"customerIntentPreRuleLoop": "2024-02-14T23:54:40.434Z",
"customerPersonId": "",
"zipCode": "84088",
"printCustomerPersonId": "",
"callbackForce": "true",
"callbackEnable": "true",
not all keys shown
}
}

This action publishes just fine, but doesn't show any output available when calling it in an architect flow. We'd like to be able to drop this direct into a JSON object. Here is the current output contract (which doesn't work)

{
"type": "object",
"properties": {
"attributes": {
"type": "object",
"properties": {},
"additionalProperties": true
}
},
"additionalProperties": true
}

Hi Mike,

Here is an approach you can try out:
Change your output contract to have attributes be a string instead of an object.

Use the jsonString velocity macro in order to escape the participant data

You may need to add some surrounding quotes to get it to work.

In the architect flow use jsonParse to convert the escaped JSON into the architect JSON data type.

--Jason

Jason,

This worked great! Thanks for your quick response. We were able to get the object into a string without an issue.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.