Loop
Overview
The Loop Node in UPTIQ Workbench allows workflows to repeatedly execute a process until a specified exit condition is met. This is particularly useful for iterating over lists, verifying input validity, or ensuring a task completes before proceeding.
By using the Loop Node, developers can: ✅ Handle Iterative Processing – Process lists of items dynamically. ✅ Validate User Input Repeatedly – Ensure correct data entry before proceeding. ✅ Create Conditional Workflows – Execute repeated steps based on runtime conditions.
Unlike static workflows, the Loop Node dynamically determines whether to continue execution or exit based on real-time data evaluation.
Configurations
Exit Condition
A condition (in natural language) that, when met, will cause the loop to exit. If not met, the loop continues.
Execution Flow:
1️⃣ The Loop Node receives input from previous steps.
2️⃣ It evaluates the exit condition based on the provided data.
3️⃣ If the condition is met, the node outputs {"action": "exit"}
and the loop terminates.
4️⃣ If the condition is NOT met, it outputs {"action": "continue"}
, repeating the process.
Output Format
{ "action": "continue" }
Loop continues.
{ "action": "exit" }
Loop stops execution.
Example Use-Cases
Use-Case 1: Validating User Email Input
A workflow requires users to enter a valid email before proceeding. The Loop Node repeats the request until a valid email format is entered.
Configuration:
Exit Condition
userInput should be a valid email
Execution Process:
If the user enters an invalid email, the node outputs:
🔹 The workflow asks the user to re-enter their email.
Once the user enters a valid email, the node outputs:
🔹 The workflow proceeds to the next step.
Use-Case 2: Iterating Through a List of Questions
A chatbot is programmed to ask multiple questions, and the workflow loops until all questions are answered.
Configuration:
Exit Condition
"If we don’t have any questions left to ask"
Input to Loop Node:
Execution Process:
1️⃣ First Iteration → The bot asks Q1, removing it from the list.
2️⃣ Second Iteration → The bot asks Q2, removing it from the list.
3️⃣ Third Iteration → The bot asks Q3, removing it from the list.
🔹 Once no questions remain, the workflow exits the loop.
Use-Case 3: Retry Logic for API Requests
A workflow fetches data from an external API. If the API fails, the Loop Node retries the request until a successful response is received or retries are exhausted.
Configuration:
Exit Condition
"API response is successful or retry count exceeds 3"
Execution Process:
1️⃣ If the API fails, the node outputs:
🔹 The API call is retried.
2️⃣ If the API succeeds or retries reach 3, the node outputs:
🔹 The workflow proceeds to handle the response or logs an error.
Key Takeaways for Developers
✅ Automates Loop Execution – Runs a process repeatedly until a condition is met.
✅ Uses Natural Language for Exit Conditions – Unlike traditional programming logic, the Loop Node allows developers to define exit conditions in plain language, making it easy to configure and readable within workflows.
✅ Reduces Redundant Workflow Steps – Instead of creating multiple nodes for repetitive tasks, use a Loop Node for dynamic iteration.
✅ Enables Smart Decision-Making – The exit condition is evaluated dynamically, ensuring real-time logic execution.
✅ Supports Multiple Use Cases – Ideal for validations, API retries, question sequences, and dynamic task execution.
By integrating the Loop Node, developers can create intelligent, adaptable workflows that respond dynamically to user input, process execution results, and iterative data operations. 🚀
Last updated