3 min read.
Sometimes, variable structuring can get complicated. It is difficult to remember references when using them in your Flows. As a solution, you can use variables to define easy-to-remember references inside your Flow. Once you have defined a custom variable, it will be used in the rest of the Flow. These variables can also be given to your end-user to use as tags in their integrations. Let's see how a variable can be used inside your Flows.
Create a new Flow
or use an existing one in which you want to use the variable.
For explanation, we will create a Flow with a MailChimp Subscriber
Trigger. Complete the Trigger addition and testing as explained here
Search and select Variable from the App Connector selection menu.
Next, you can create variables that can be used in Twig expressions in the Flow. You can add the variable by defining the Name and Value fields in this section.
- Name: This is the name given to the added Variable.
- Value: This field can be a constant, variable, or a twig expression.
Let's say you want to save the value of the email field of the subscriber of MailChimp in a variable to be used in a later step.
You can provide any name to the Variable and add the tag for the email field from MailChimp Trigger. Click on the '+' sign, move the cursor to the email field and click on '+Add to Field'.
Clicking the +Add Variable button will show a new Name and Value field for adding a second Variable and so on. Click on Done to collapse a Variable. Click on the bin icon on the right of the value field to delete a Variable.
Furthermore, you can apply conditions, or loops on the value stored in the Variable or use it in a code step.
As an example, we will compare the value coming out from the Variable step with a hard-coded value.
You are done creating and adding a variable to your Flow.