usuresh | 2023-06-06 19:45:27 UTC | #1
Hi,
I would like to contact Strings in data action and response as one field output. Is there a way to do it ?
{ "translationMap": { "text": "$.transcripts[1].phrases[6].text", "text1": "$.transcripts[1].phrases[7].text" }, "translationMapDefaults": { "text": "", "text1": "" }, "successTemplate": "{\n\"text\": ${text}}" }
In the above script I would like to send "text" field response as "text"+"text1".
Jerome.Saint-Marc | 2023-06-08 15:13:16 UTC | #2
Hello,
There is maybe an easier way to do this - but here is one way using Velocity macros for data actions in successTemplate.
The macro leverages String concat method. The text and text1 must first be parsed - to replace/remove quotes (success template receives text and text1 as \"something\").
{
"translationMap": {
"text": "$.transcripts[1].phrases[6].text",
"text1": "$.transcripts[1].phrases[7].text"
},
"translationMapDefaults": {
"text": "\"\"",
"text1": "\"\""
},
"successTemplate": "#set($a = $text.replace($esc.quote, \"\")) #set($b = $text1.replace($esc.quote, \"\")) #set($resultString = $a.concat(\" \").concat($b)) {\n\"fromUser\": \"${resultString}\"}"
}
Regards,
system | 2023-07-09 15:13:57 UTC | #3
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: 20285