Flow Builder - Building Conditional Logics

Utilising If/Else Node

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:

  1. Select the If Else node.

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

  1. Now, we can see a True branch and a False branch coming out of the node.

  1. TRUE Path: If age is greater than 18, proceed to offer eligibility logic.

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

API with Switch Case Node

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:

  1. Let's assume you are sending a type field through the query parameters and you want to execute different flows depending on the type.

  2. First, select the switch case node and add it to your flow.

  1. Now, configure the node as follows:

  1. You now have 4 branches labelled as billing, technical, account_management and default. Here's how the flow looks now:

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

  2. Similarly , add a unique response for other branches as well. This is how the flow looks like:

  1. Now let's test this API.

To learn more about the Switch Case node click here

Last updated