0

I'm building an SMS bot using Twilio Studio flows. I've added a Set Variables widget with the following liquid code in the variable value:

{% capture address %}{{widgets.request_address.inbound.Body | lower | strip}}{% endcapture %}
{% if address == "yes" %}{{ flow.data.address }}{% else %}{{ widgets.request_address.inbound.Body }}{% endif %} 

The documentation suggests this should work:

Variables can have static values like a single number or string, or dynamic values set via the Liquid templating language.

However the code isn't being parsed and instead it's being saved as a string into the variable.

Am I missing something? Does Twilio studio just not support this despite what the documentation says?

Update:

I think the widget might only allow a single Liquid block. Later in the docs it says:

This can be a number or string value, or a liquid template block like the example above.

The following code works (but is obviously not as flexible about the input)

{% if widgets.request_address.inbound.Body == "yes" or widgets.request_address.inbound.Body == "Yes" %}{{ flow.data.address }}{% else %}{{ widgets.request_address.inbound.Body }}{% endif %}
rjmackay
  • 144
  • 8

1 Answers1

2

Heyooo, Twilio developer evangelist here.

I just checked this question with our Studio team and indeed you are right. The widget accepts only a single liquid block.

In your case, what you can still do is to chain widgets together and perform formatting and logic in two steps. :)

Twilio Studio flow with two chained resolve variable widgets

What you see there is that the first widget strips whitespace and formats the input and the second one then performs the logic.


Hope that helps. :)

stefan judis
  • 3,416
  • 14
  • 22