Loop Over Items in n8n Tutorial

5 min
Lesson 3 of 4

Learn how to build a workflow that iterates through Google Sheet rows, processes data with an AI model, and updates the sheet in n8n.

Loop Over Items in n8n Tutorial

In this tutorial, you'll learn how to create an n8n workflow that automates content generation by looping over items from a Google Sheet. The workflow reads data, uses an AI model to generate excerpts for blog posts, and writes the results back to the sheet.

Loop Over Items in n8n

Workflow Overview

The workflow is designed to automatically process rows from a Google Sheet one by one.

  • When clicking 'Execute workflow' - This is a manual trigger to start the workflow.
  • Get row(s) in sheet - Fetches data from a Google Sheet. Each row should contain a blog title and category.
  • Loop Over Items - Iterates through each row of the sheet one by one.
  • Message a model - Sends the current row's data to an AI model for processing to generate an excerpt.
  • Edit Fields - Modifies or prepares data fields.
  • Update row in sheet - Writes the updated or processed information back into the same Google Sheet.

Message a Model Node Configuration

The "Message a Model" node is where the AI-powered content generation happens.

User Prompt

The user prompt sends the title and category from the current row in the Google Sheet to the AI model.

Your task is to write a excpert for the following blog title and category.

Title - {{ $json.Title }}
Category -  {{ $json.Category }}

System Prompt

The system prompt defines the role of the AI model.

You as a expert content writer with expertise in writing SEO optimized exceprts for blogs.

Download Template

You can download the n8n workflow template to get started quickly.

Loop Over Items Template