Matthew_Raleigh2 | 2023-01-03 19:37:36 UTC | #1
Hello,
Is there a way to output the list of an array? For example, want to get all the DNIS items from a conversation. I was able to get the first item using 'successTemplateUtils.firstFromArray' and I tried 'successTemplateUtils.moveKeysIntoArrayOfObjects' but keep getting error using this response:
{ "translationMap": { "value": "$..participants..dnis" }, "translationMapDefaults": {}, "successTemplate": "{\"value\": ${successTemplateUtils.moveKeysIntoArrayOfObjects(${value})},\"valueId\")}}" }
Thanks
Jerome.Saint-Marc | 2023-01-04 09:29:05 UTC | #2
Hello,
You can define your Data Action so that a list/array/collection of strings is returned in an output attribute/variable. You can then leverage that list of strings in your Architect flow or in a Script (defining a variable of type collection/list of strings in your Architect flow or Script and using it to collect the output of your Data Action).
Your output contract can be defined to return a dnisList attribute - array of strings - as described here:
{ "type": "object", "properties": { "dnisList": { "type": "array", "items": { "title": "Item 1", "type": "string" } } }, "additionalProperties": true }
And your response configuration can extract the conversation's dnis and set them in this dnisList.
{ "translationMap": { "values": "$..participants..dnis" }, "translationMapDefaults": { "values": "[]" }, "successTemplate": "{ \"dnisList\": ${values} }" }
Regards,
Matthew_Raleigh2 | 2023-01-04 12:10:59 UTC | #3
Hi Jerome,
Thanks for your reply. This is very helpful.
system | 2023-02-04 12:11:04 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 17828