Twilio studio messing up the json when sending an HTTP request

Viewed 135

using twilio studio we receive sms message to one of out twilio numbers and we send it to one of our services. we send it using the MAKE HTTP REQUEST widget with the CONTENT TYPE: json in there we have the following body:

{
  "Body":"{{trigger.message.Body}}",
  "From":"{{trigger.message.From}}"
}

but when an sms message with new lines is received for example somthing like

hello name
how are you

then the json twilio studio sends ends up looking like this

{
  "Body":"hello name
how are you",
  "From":"some number"
}

and we end up getting Unexpected token \n in JSON

2 Answers

ended up using the following:

{
“Body”: "{{ trigger.message.Body | newline_to_br | replace: "<br />", " " | strip_newlines }}",
“From”: "{{trigger.message.From}}"
}
Related