1

I'm looking for the reverse of LIQUID TEMPLATE LANGUAGE Twilio Studio Variables. I'm fine setting liquid variables, and can check for them within the same widget using liquid. But they appear to be scoped to just the current widget, and are not included as part of the flow.

So I need either a way to reference an earlier liquid variable, or to assign a liquid variable to a widget/studio variable or something else which can be used further down the line.

I could kludge my way through using http request or run function widgets just to get that variable back, but that seems like a poor way to do it when I already know which value I want from within Studio.

An example of where this would come in handy would be for an IVR where you want to retry things on wrong answers, but after "n" wrong answers you want to break out of the flow with a "contact customer service" response. A simple increment for wrong answers would be trivial, if you could set and use variables.

Thanks

mike
  • 86
  • 5

2 Answers2

1

Twilio developer evangelist here.

The liquid tags are only run in the context of the widget, so you cannot set persistent variables within them.

It may sound like a kludge, but using a Twilio Function is the way to run code (which you need to do to increment a counter) and then store data that can be used by other widgets, so that is what I would recommend.

I wouldn't bother with an HTTP request, as that is overkill for this situation.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • As per answer, if I created a "set_variable" widget lets say widget name is "Var_Try" using the studio, and have created a variable here for eg "test" using the widget creation, and set it to some string such as "Test String". So great studio sets tests' value within the widget to the string. If I tried to access the variable later in the flow, such as the widget succeeding it, how could I access "test" in the widget succeeding it, say its a send message widget, whose value to display is the value of "test", would I use "{{flow.variables.test}}" in the latter widget? – user3483902 Oct 08 '19 at 20:21
  • You would use `{{flow.variables.test}}`, yes. – philnash Oct 08 '19 at 21:41
0

A new feature update.

Twilio Studio User Guide - Set Variables

Alan
  • 10,465
  • 2
  • 8
  • 9
  • Wow, that is exactly what I was looking for. I'm pretty sure it wasn't there the other day when I was working on this. Twilio keeps getting better. – mike Dec 12 '18 at 16:55