Flow Builder - Building Conditional Logics
Last updated
Last updated
In many scenarios, you need to execute specific instructions based on certain conditions. This is where If/Else nodes become crucial in Cosmocloud's flow builder.
Imagine you are building an API that determines user eligibility for a promotional offer based on their age. Here’s how you can implement this using If/Else node:
Select the If Else node.
Click on the node to go to the properties panel of the node and click on edit condition to add the condition criteria for our If Else node. In our case, the criteria is to check whether the age of the user is greater than or equal to 18 or not.
For creating more complex conditions, you can check building conditions.
Now, we can see a True branch and a False branch coming out of the node.
TRUE Path: If age is greater than 18, proceed to offer eligibility logic.
FALSE Path:If age is 18 or less, send a response indicating the user is not eligible for the offer.
To learn more about the If/else node click here.
In many scenarios, you need to execute different sets of instructions based on the value of a specific variable. This is where SWITCH/CASE nodes become crucial in Cosmocloud's flow builder.
Imagine you are building an API that processes different types of customer service requests. Here’s how you can implement this using SWITCH/CASE nodes:
Let's assume you are sending a type
field through the query parameters and you want to execute different flows depending on the type
.
First, select the switch case node and add it to your flow.
Now, configure the node as follows:
You now have 4 branches labelled as billing
, technical
, account_management
and default
. Here's how the flow looks now:
Now let's return a unique response for each type of request i.e., if the type in the query parameters is billing
we execute the billing branch and return You are in the billing branch
as the response.
Similarly , add a unique response for other branches as well. This is how the flow looks like:
Now let's test this API.
To learn more about the Switch Case node click here