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.
- List: used for drop-down selections.
- Date: used for dates, stored in ISO 8601 format (yyyy-mm-dd).
Note: if an admin 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
Using Drop-Downs in Workflow Builder
The List type context variable allows a user to create a dropdown in workflow builder. You can name the context variable and then add a list of possible values for that variable. This list of values will be the dropdown options.
Setting Variables in the Embed Script/Code Snippet
If you want to set the value of a context variable before the widget conversation begins, you can do this using workflow context and the code snippet.
- Set the variables you want to add to the code snippet as "Workflow Context" in the Context variables page
- After saving your changes, the Code snippet page will show you how to set the value of those variables, as well as the rest of the embed script
You can either set these dynamically for variables that are user-dependent, such as email, or leave them constant for variables that are domain specific or user-independent.
Comments
0 comments
Please sign in to leave a comment.