Agent.ai Documentation home page
Search...
⌘K
Ask AI
Support
Platform
Platform
Search...
Navigation
Actions
For Loop
Guides
API Reference
Recipes
Documentation
Community
Using Agent.ai
Welcome
AI Agents Explained
Security & Privacy
Marketplace Credits
Rate Limits
Profile
Settings
Integrations
Agent Team
Agent Runs
Agent Requests
For Builders
Builder Overview
Public Agent Policy
LLM Models
Action Availability
Knowledge Base
Secrets
Serverless Functions
Snippets
Clone an Agent
MCP Server
Lists in For Loops
Output Formatting
Actions
Get User Input
Get User File
Get User List
Get User KBs and Files
Click Go to Continue
Wait for User Confirmation
Get Bluesky Posts
Enrich with Breeze Intelligence
Get Data from Builder's Knowledge Base
Get Data from User's Uploaded Files
Get Instagram Followers
Get Instagram Profile
Get LinkedIn Activity
Get LinkedIn Profile
Get Twitter Users
Get Recent Tweets
Google News Data
Search Bluesky Posts
Search Results
Web Page Content
Web Page Screenshot
YouTube Channel Data
YouTube Search Results
Get HubSpot CRM Object
Add HubSpot CRM Object
Update HubSpot CRM Object
Get HubSpot Owners
Get HubSpot Object Properties
Get Assigned Company
Use GenAI (LLM)
Generate Image
Set Variable
Add to List
Continue or Exit Workflow
If/Else Statement
For Loop
End If/Else/For Statement
Show User Output
Send Message
Create Blog Post
Save To Google Doc
Format Text
Post to Bluesky
Save To File
Convert File
Call Serverless Function
Invoke Web API
Invoke Other Agent
Store Variable to Database
Get Variable from Database
On this page
Overview
Use Cases
How For Loops Work
Creating a For Loop
Step 1. Add the For Loop Action
Step 2. Configuration Fields
Step 3. Add Actions Inside the Loop
Step 4: End the Loop
Example: For Loop Example Agent
Actions
For Loop
Overview
For Loops allow your agent to repeat actions for each item in a list or a specific number of times. This saves you from having to create multiple copies of the same steps and makes your workflow more efficient.
Use Cases
Process Multiple Items
: Apply the same steps to each item in a list
Repeat Actions
: Perform the same task multiple times
Build Cumulative Results
: Gather information across multiple iterations
Process User Lists
: Handle user-provided lists of items or requests
How For Loops Work
A For Loop repeats the same actions for each item in your list. Think of it like an assembly line:
The loop takes one item from your list
It puts that item in a variable you can use
It performs all the actions you’ve added to the loop
Then it takes the next item and repeats the process until it’s gone through every item
Creating a For Loop
Step 1. Add the For Loop Action
In the Actions tab, click “Add action”
Select “For Loop” from the Run Process tab
Step 2. Configuration Fields
List to loop over
Description
: Enter a list to loop over or a fixed number of iterations.
Example:
A variable containing a list (like {{topics_list}})
A number of times to repeat (like 3)
A JSON array (like [“item1”, “item2”, “item3”])
Required
: Yes
Loop Index Variable Name
Description
: Name the variable that will count your loops (this counter starts at 0 and increases by 1 each time through the loop)
Example
: loop_index
If you’re looping 3 times, this variable will be 0 during the first loop, 1 during the second loop, and 2 during the third loop
Validation
: Only letters, numbers, and underscores (_) are allowed.
Required
: Yes
Step 3. Add Actions Inside the Loop
After your For Loop action, add the steps you want to repeat for each item.
Step 4: End the Loop
After all the actions you want to repeat, add an “End If/Else/For Statement” action to mark where your loop ends.
Example: For Loop Example Agent
See this
simple example agent
which uses a For Loop:
Gets a list of 3 topics from the user
Loops through each topic, one by one
For each topic:
Uses AI to generate an explanation
Adds the explanation to a cumulative output
Displays all topic explanations to the user when complete
If/Else Statement
End If/Else/For Statement
Assistant
Responses are generated using AI and may contain mistakes.