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 ‘Next 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 ‘Next Action’ field of the ‘Default’ block. Select the action that you wish to execute if none of the condition is met. 

switch configuration

7. 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:

formstack-trigger

Next, Add ‘Switch’, ‘Zendesk - Create Ticket’, ‘Asana - Create Task’, ‘Intercom - Create Note’, and ‘Cisco Spark - 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. 

  Next 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. 

switch-condition

Define the conditions for ‘Operations’ and ‘Content’ in the same way, and select ‘Create Task’ and ‘Create Note’ actions respectively in the ‘Next Action’ field. 

Default: In this block we will specify the action to be executed if none of the specified condition is met.

  Next Action: Click on the drop down list and select ‘Post New Message’ action. 

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. 

switch-connections

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 Spark - Post new Message’ actions by selecting relevant authorizations/connections. In the ‘Body’ field of each action add ‘data’ key listed under ‘Trigger Data’ on the right hand side of the configuration window 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.