Controls
Control actions manage how your workflow executes. They handle the flow of data, make decisions, process repetitive tasks, and determine how your workflow starts and ends. These actions are essential for creating dynamic, responsive workflows that can handle complex scenarios.
Input
Every workflow starts with an input action. This action functions as the starting point for your workflow, defining what data it takes in and how it can be triggered. When you configure an Input action, you specify:
Expected input parameters
Optionally, authentication requirements
Once configured, other applications can trigger your workflow by calling its API endpoint. Alternatively, you can configure your workflow as a Form or Chat app.
Output
Every workflow path ends with an output action. This action defines what your workflow returns to the calling application. You can return:
Structured data (JSON objects or tables)
Simple text strings
Files (images, audio, documents)
Streams (for real-time data)
When returning files or streams as an API endpoint, the Output action automatically handles appropriate headers like Content-Type and Content-Length.
Branch
The branch action lets your workflow make decisions. It evaluates conditions and directs the flow down different paths based on your data. For example, you might route customer service requests to different departments based on the topic, or process orders differently depending on their priority.
Each branch consists of cases - conditions that evaluate your data to determine which path to take. You write these conditions using simple expressions, like state.movie.genre === 'scifi'
or customer.type === 'premium'
. When an item matches a case's condition, the workflow follows that case's path.
You can always add a default else case that catches anything not matched by your other cases. This ensures your workflow can handle unexpected situations gracefully. You can add as many specific cases as you need, and each path can have its own set of actions, including its own Output action if required.
For example, a movie recommendation branch might have:
Case "Sci-fi" with condition
state.movie.genre === 'scifi'
Case "Action" with condition
state.movie.genre === 'action'
A default else case for all other genres
Loop
Use the loop action when you need to process multiple items one by one. The Loop action takes a list of items and runs the same set of actions for each item in the list. This is particularly useful when you need to:
Process each item in a dataset
Generate content for multiple topics
Handle batch operations
Inside the loop, use {{loop.item}}
to access the current item being processed. Once all items are processed, the workflow continues to the next action after the loop.
Repeat
The repeat action is similar to Loop, but instead of processing a list, it executes the same actions a specified number of times. Use Repeat when you need to:
Try an operation multiple times
Generate variations of content
Perform a task until a condition is met
After completing all repetitions, the workflow moves on to the next action.
Best practices
When working with control actions:
Start simple and add complexity as needed
Test each branch and loop path thoroughly
Consider default cases for unexpected scenarios
Use descriptive names for your branches and conditions
Monitor loop performance with larger datasets
Last updated