Context variables are an important part of Workflow Builder, allowing you to define, store, and pass different values throughout your workflows and even add them into your Zendesk tickets. In this article, we will discuss how to set-up and use pre-built and custom context variables within Workflow Builder.
Creating Custom Context Variables
To create a custom variable, first navigate to the Customization tab. This can be found by going to the main Workflow Builder page and clicking the Settings wheel button in the top right.
Once in the Customization tab, click on the Context Variables tab.
This tab is your location for creating, deleting, and managing the various parameters and variables you'll use in your workflows.
You'll notice there quite a few prebuilt variables, all with different variable types and predetermined names. These default variables will always be available, and you do not have the option to edit them.
If you'd like to create your own variables you can do so by scrolling to the bottom of the list and clicking Add Context on the bottom left. Once here, choose a display name for the variable and the variable's data type. Each data type has its own unique purpose, so make sure to select the correct type for each variable. The different options for the data types are:
- Short Text: used for smaller text inputs, such as names.
- Long Text: used for longer text inputs, such as descriptions.
- Checkbox: a simple checkbox that is used for values such as True/False.
- Number: any number, whether an integer or a decimal value.
- Email: used for email domain inputs.
- Phone: used for phone number inputs.
Note: if a user tries to add the wrong input into a variable, for example a name into an email field, the system will block them from proceeding until the input is corrected.
Using Context Variables in Workflows
Once you have your custom variables created, you are now ready to define and use the values in a workflow! To do so, simply reference any variable by typing out the name of the variable prefixed by a dollar sign ($). You can also assign a value to a context variable through the widget snippet dynamically or statically.
You can use context variables in a few ways within Workflow Builder including:
- Adding variables to most text fields
- Using forms to collect user-inputs and store them
- Adding variables to Zendesk Handoffs for passing to Zendesk