Cosmocloud Build Documentation
DocumentationTutorials
  • Welcome to Cosmocloud
  • Getting Started
    • 1. Organisations
    • 2. Projects
    • 3. Connect your Database
    • 4. Create Database Models
    • 5. Create APIs
    • 6. Testing Free Tier APIs
  • Free Tier
    • Connecting with MongoDB Data APIs
  • Templates
    • CRUD APIs
    • Entity Search APIs
    • Fetch / Upload Media APIs
  • Examples - How To?
    • Making an external API call
    • Reusable Flows - SubFlows
    • Creating Custom Error Responses
    • Flow Builder - Building Conditional Logics
    • Flow Builder - Utilising Loops
    • Creating Dynamic Queries
    • Accessing Auth Tokens in APIs
    • How to upload/download media in Object Storage
  • Resources
    • APIs
      • Checking Logs
    • SubFlows
    • Models
      • Building Models
    • Environments
      • Environment Tier Types
    • Secrets
      • Custom Secrets
    • Databases
    • Releases
    • Vector Search
      • Create a Vector Search Index
      • Edit a Vector Search Index
      • Delete a Vector Search Index
    • Document Search
      • Full Text Search
        • Concepts
          • Indexing in full-text search
          • Data processing using Analyzers
        • Create a Search Index
        • Creating a Custom Analyzer
        • Full Text Search FAQ
      • Vector Search
    • Object Storage
  • Flow Builder
    • Node Types
      • Trigger Nodes
        • HTTP Response
      • Conditional Nodes
        • If Else
        • If Else V2
        • Switch Case
      • Crypto Nodes
        • PBKDF2 Hmac Hash
      • Debug Node
      • Database Nodes
        • Delete One
        • Delete Many
        • Fetch By ID
        • Find One
        • Find Many
        • Insert One
        • Insert Many
        • List Records
        • Run Aggregation Pipeline
        • Update One
        • Update by ID
        • Update Many
      • External Nodes
        • Fire Events (SQS)
        • API Call
        • Delete storage objects
        • Execute SubFlow
        • Get Presigned URL
        • Post Presigned URL
        • Send EMAIL (SES)
        • Send SMS (SNS)
      • Loop Nodes
        • For loop
        • While loop
      • Variable Nodes
        • Arrays
          • Append array
          • Contains
          • Check array empty
          • Extend array
          • Get Array Item
          • Length of array
          • Reverse array
          • Sort array
        • Date and Time
          • Set current datetime
        • Strings
          • Append String
          • Concat Strings
          • Convert to String
          • Length of String
          • Slice String
          • Split String
          • String Operations
          • To Lower
          • To Upper
          • Trim String
        • Mathematical
          • Add Variable
          • Complex Math Expr
          • Decrement Variable
          • Divide Variable
          • Increment Variable
          • Multiply Variable
          • Subtract Variable
        • JSON
          • Build JSON Object
          • Merge JSON Objects
          • Object to String
          • Update JSON Object
        • Special
          • Build Map
          • Set Variable
          • Exists Check
    • Node name
    • CQL - Cosmocloud Query Language
      • Building Expressions
        • $abs
        • $add
        • $addDate
        • $arrayElemAt
        • $avg
        • $buildDateTime
        • $buildMap
        • $ceil
        • $cond
        • $divide
        • $floor
        • $getDay
        • $getHour
        • $getMinute
        • $getMonth
        • $getSecond
        • $getYear
        • $ifNull
        • $max
        • $min
        • $mod
        • $multiply
        • $pow
        • $subtract
        • $sqrt
      • Building Conditions
        • Compound Operators
          • $and
          • $or
        • Conditional Operators
          • $eq
          • $gt
          • $gte
          • $lt
          • $lte
          • $neq
      • Magical Autocomplete
  • Advanced Guide
    • Configuring Authentication
      • SSO Providers
        • AWS Cognito
      • Authentication Concepts
    • MongoDB Query Language
      • Limitations
    • Performance Considerations
      • Instant Deployments
  • User Management
  • Billing and Payments
    • Billing Portal
  • Help & Support
  • References
    • Change log
    • Available Cloud & Regions
Powered by GitBook
On this page
  • Utilising If/Else Node
  • API with Switch Case Node
  1. Examples - How To?

Flow Builder - Building Conditional Logics

PreviousCreating Custom Error ResponsesNextFlow Builder - Utilising Loops

Last updated 10 months ago

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.

  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.

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.

For creating more complex conditions, you can check .

To learn more about the If/else node .

To learn more about the Switch Case node

building conditions
click here
click here