Rate this page:

Set Variables

Set Variables Widget


Set Variables allows you to save key/value pairs in the global context of the flow execution. Variables set via the widget are accessible throughout your flow via other widgets under the key {{flow.variables.<key>}}. This allows you to enable use cases such as counters that are dynamically updated as your flow executes.

Optional Configuration:

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

Example that sets a variable called count to 0 if not set and increments it if it exists.

Tip: Be sure to use the hyphen in your Liquid tags to remove extra whitespace generated by the template. Any tag without a hyphen in it creates a blank line; for example, the below code snippet outputs a single line, but without hyphens it would have three blank lines plus the expected output, which would cause the integer to be treated as a string.

{%- if flow.variables.count -%}
  {{flow.variables.count | plus: 1}}
{%- else -%}
{%- endif -%}





The name of this variable, once set, will be accessible in Liquid via {{flow.variables.<key>}}.


  • Variable names are case sensitive. Foo is a different variable than foo.
  • The same key may be set in different widgets. This allows you to update a value.
  • The key itself cannot be a Liquid variable


The variable value to set. This can be a number or string value, or a Liquid expression like the example above.


There is only one transition from this widget, "Next" which fires once any variables specified are set.

Example Flow

In the call flow screenshot below, the count variable is set to 0 when the flow starts, and the flow will loop until the count variable is equal to 3 and then exit (The set variable widget uses the sample Liquid template code from above).

Screen Shot 2018-12-11 at 10.11.23 AM.png

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Community Forums or browsing the Twilio tag on Stack Overflow.


        Thank you for your feedback!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. Please select the reason(s) for your feedback or provide additional information about how we can improve:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more