Setting different variable values based on incoming webhook
In this tutorial, we will show how you can use the 'Switch' function in Power Automate to dynamically switch and set different variable values in TBP.
- A bot
- A power automate flow (Paid)
- Starbucks iced White mocha OR Your favorite beverage
Step 1: Choosing a variable for switching
For this example, let's say we are collecting multiple email addresses of users through a variable in the bot. After collecting the email address, we want to store the email address values against different variables on the platform such as 'First colleague', 'Second colleague' etc.
In a standard flow, we will only be able to set one variable but using the 'Switch' function in Power Automate we can dynamically switch the variable name based on inputs received through the webhook.
Look at the outputs from the webhook and find a variable value that changes dynamically based on inputs from the bot user.
In the above examples, we can see that the 'variable_name' is producing the values $First colleague and $Second colleague which can be used perfectly to switch our power automate flow.
Step 2: Configuring the Switch module in Power Automate
In this step we are going to configure our 'Switch' module in Power Automate. To begin, click on 'Add a new step' at a relevant point within your flow and search for 'Switch'.
Now it's time to begin the configuration of our switch. In the examples above, we chose values coming through 'variable_name'.
In our use case, we want to set the values of our variables as follows:
- $First colleague = $firstconfirmedcolleague
- $Second colleague = $secondconfirmedcolleague
- $Third colleague = $thirdconfirmedcolleague
Now let's set these in the 'Switch' flow so that when $First colleague variable comes through the webhook, the flow is directed to set value for $firstconfirmedcolleague and so on.
Depending on the number of variables you would like to use - configure each case accordingly and set the values in a variable within Power Automate.
In our use case, we set three variable values based on three variables coming through the webhook.
Once all done, please make sure to save your flow and execute your flow. If everything works as expected, your flow execution will show filtered execution based on incoming variable value through the webhook
You can see in the example above, as the value was $First colleague, the flow only executed the first 'Switch' configuration.
Updated 8 months ago