Loop through data

Looping is one of the most useful patterns in axiom.ai. A loop repeats a group of steps, usually once per row of data. For example, loop through a list of URLs to scrape data from each page, or loop through rows of a Google Sheet to fill in a web form.

There are three steps you can use to build a loop. The primary one is Loop through data. The Jump to another step and Conditionally jump to another step steps can also create loops, and you can use logic inside any of them.

Loop with Build from description


The quickest way to get a loop is to describe it. Words like loop, repeat, each and all tell the agent to repeat something: "scrape all the products", "for each URL", "repeat for every row". The agent decides when a loop is needed, adds the Loop through data step, puts the right steps inside it and connects the data.

  1. Read URLs from a Google Sheet
  2. Go to each page and scrape the data I want
  3. Write the data to a Google Sheet
Click to launch the Chrome extension. Not installed? You can create an account and try it free.Opens the Chrome extension. Free account to try.

That description builds a loop over the sheet's rows with the scrape and the write inside it. See build from description for how it works. If you would rather place the steps yourself, read on.

Set up your own loop


The Loop through data step repeats its sub-steps once for each row of data passed into it.

Add the loop

  1. Open the step finder, search for loop, and add Loop through data.
  2. Add the steps you want to repeat with Add sub-step. Steps outside the loop are not repeated.

To wrap steps you already have, tick their checkboxes, click Loop in the Move toolbar and choose Loop through data.

Pass a data source to the loop

A loop won't run until it has data. The usual source is a step before the loop that produces rows, such as Read data from a Google Sheet.

Selecting data to loop through in the axiom.ai Builder

Example: loop through the rows of a sheet and fill a form with each one.

  1. Add Read data from a Google Sheet and pick the sheet.
  2. Add Loop through data below it, with your form-filling steps as its sub-steps.
  3. In a sub-step, click Insert data and choose the sheet's data. The variable you pick is set as the loop's Data to loop through at the same time, and each sub-step sees one row at a time.

You can also set Data to loop through on the loop step itself.

Note: A loop returns an error if its data source is empty.

Nest loops

Nested Loop through data steps in the axiom.ai Builder

A loop can sit inside another loop, up to four levels deep. Two or three levels cover almost every automation.

Use the loop's output

Every Loop through data step outputs a token that later steps can read. It holds the data from every sub-step in every iteration, assembled into a table. To collect the output of several steps into a single token, inside or outside a loop, use the Group steps step.

Other kinds of loop and condition


  • End Loop stops a loop before it finishes its iterations, usually paired with a condition.
  • Jump to another step repeats a run of steps a set number of times, with no data source.
  • Conditionally jump to another step jumps back only while a condition holds, for example clicking Next until a value appears.
  • If condition runs sub-steps only when a condition is met, inside a loop or anywhere else. See logic.

Full walkthroughs: loop through links and scrape data, enter text into a search field, and scrape HTML and extract data with AI.