Switch
Switch is a like a selection control statement. It lets you define a number of possible execution paths for your workflow.
In the Switch action, you can add one or more cases. Each case contains one or more conditions and a Next Step that will be performed if the defined conditions are met. The action also also includes a ‘Default’ block that specifies the action to be executed if none of the condition is met.
This not only makes it easier for you to add complex workflows, but also reduces the overall workflow execution time considerably.
How to configure Switch
Follow the steps given below to configure Switch in your workflow.
1. Add Switch and all other actions that you wish to connect to Switch on canvas.
2. Double click on the ‘Switch’ action and click on the ‘+CASE’ link in the window that appears.
3. Specify the condition for ‘Case 1’ using the conditional block. You can use ‘AND’ or ‘OR’ operator to specify multiple conditions under ‘Case 1’.
4. Click on the drop-down list for ‘Select Action’ field and select the action that you wish to execute if the specified condition under ‘Case 1’ is met.
5. Click on ‘ADD CASE’ link to add multiple cases.
6. Once you are done defining the conditions, click on drop-down list given under ‘Select Action’ field of the ‘Default’ block. Select the action that you wish to execute if none of the condition is met.
6. Once you are done defining the conditions, click on drop-down list given under ‘Select Action’ field of the ‘Default’ block. Select the action that you want to execute if none of the condition is met.
7. Click on ‘Next’. A new screen will appear on the screen where you can see the sample input data.
8. Click on ‘Done’. This will automatically create connections between Switch and its corresponding actions. Please note that you will not be able to make this connection manually.
Let’s understand more about Switch with the help of an example.
Example
Let’s say your organization has a support request form on its website where users can raise requests for different departments. You want to create a workflow that will execute each time a new support request is raised, will check the department (IT, Operations, Content, or Other) for which the request was raised, and will then send the details of the request to the specified department through a specific channel. To achieve this, follow the instructions given below:
1. Add and configure trigger
First we will setup a trigger that will fire off each time a new request is submitted through the request form.
Select ‘Formstack - New Submission’ trigger and configure it as shown below:
Click on ‘Save’ to save your trigger. This will create the specified trigger on Built.io Flow. After this, you will be redirected to the ‘Test Trigger’ window, where you can check if you have configured the trigger settings properly.
To test your trigger, click on 'Test'. If you have configured the trigger correctly, you will see the output data for the trigger. This output data will then be used to configure the rest of the workflow.
If you ‘Skip’ testing the trigger, Built.io Flow will use mock data for that trigger to configure the rest of the workflow.
Once this is done, click on 'Done'.
Next, Add ‘Switch’, ‘Zendesk - Create Ticket’, ‘Asana - Create Task’, ‘Intercom - Create Note’, and ‘Cisco Webex Teams - Post New Message’ actions to canvas.
2. Configure ‘Switch’ action
We will now define conditions to check for which department (IT, Operations, Content, or Other) the request has been raised and will specify the action to be executed for each condition.
To do this, double click on the ‘Switch’ action icon and click on the ‘+CASE’ link given in the Switch configuration window. A new ‘Case’ block will appear.
Case: In this block we will define the condition and will specify the action to be executed if the specified condition is met.
In the first case, we will check if the request has been raised for ‘IT’ department. Set up this condition as given below:
Input: Add ‘data’ parameter ({{$trigger.data) from trigger data given on the right hand side of the Switch configuration window in the ‘Input’ field. This will return all the data of the submitted form. Since we need only ‘department’ field from this data, append ‘.department’ to the input. So it will become ‘{{$trigger.data.department}}.
Condition: Select ‘(Text) Matches’ operator from the drop down list.
Expected: Enter ‘IT’ as an input for this field.
We will now specify the action to be executed if this condition is met.
Select Action: This field automatically fetches the names of all available actions on canvas and displays it in the drop down list. Click on the drop down list and select the ‘Create Ticket’ action.
To define next case, click on ‘ADD CASE’ link.
Define the conditions for ‘Operations’ and ‘Content’ in the same way, and select ‘Create Task’ and ‘Create Note’ actions respectively in the ‘Select Action’ field.
Default: In this block we will specify the action to be executed if none of the specified condition is met.
Select Action: Click on the drop down list and select ‘Post New Message’ action.
Once you have configured the ‘Switch’ action, click on ‘Next’. You will be redirected to the ‘Test Action’ window where you can see the input data provided by you to configure the ‘Switch’ action along with a ‘Test’ button.
When you click on the ‘Test’ button, Built.io Flow will actually perform the action. It will automatically use the ‘Formstack - New Submission’ trigger data to check all the conditions defined in the switch action and will show the output of this action in the window that appears. This output can then be used to configure the rest of the workflow.
Once the action is tested, click on ‘Done’. This will take you back to canvas. You can see that Built.io Flow has automatically connected ‘Switch’ action with other actions as specified in the switch configuration window; thereby creating different paths for each case.
Please note that you can not manually create, edit, or delete these connections. If you wish to make changes to these connections, you will need to change the settings from Switch configuration window.
3. Configure all actions
We will now configure the actions to retrieve and send form data if the condition they are associated with is met.
Configure ‘Zendesk - Create Ticket’, ‘Asana - Create Task’, ‘Intercom - New Note’ and ‘Cisco Webex Teams - Post new Message’ actions by selecting relevant authorizations. In the ‘Body’ field of each action add ‘data’ key listed under ‘Trigger Data’ on the right hand side of the configuration window, test the actions and click on ‘Done’.
Now when any user submits the request form, the ‘Formstack - New Submission’ trigger will fire off this workflow. The Switch action will then traverse through conditions to check for which department the request was raised and depending on that, will execute the relevant action, which will in turn send form data to the specified department.