Skip to main content

Loop over items — beginner example

Workflow preview

Workflow preview
100%
Loop over items — beginner example preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This workflow introduces beginners to one of the most fundamental concepts in n8n: looping over items . Using a simple use case—generating LinkedIn captions for content ideas—it demonstrates how to...

Best for

  • Content Creation automation workflows
  • Multimodal AI automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.splitinbatches, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.toolthink, n8n-nodes-base.stickynote, n8n-nodes-base.manualtrigger, n8n-nodes-base.code, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.set

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Robert Breen.

Original n8n.io source

1.1 Workflow description

Title
Loop over items — beginner example
Workflow name
Loop over items — beginner example

This workflow introduces beginners to one of the most fundamental concepts in n8n: looping over items. Using a simple use case—generating LinkedIn captions for content ideas—it demonstrates how to split a dataset into individual items, process them with AI, and collect the output for review or export.


✅ Key Features

  • 🧪 Create Dummy Data: Simulate a small dataset of content ideas.
  • 🔁 Loop Over Items: Process each row independently using the SplitInBatches node.
  • 🧠 AI Caption Creation: Automatically generate LinkedIn captions using OpenAI.
  • 🧰 Tool Integration: Enhance AI output with creativity-injection tools.
  • 🧾 Final Output Set: Collect the original idea and generated caption.

🧰 What You’ll Need

  • ✅ An OpenAI API key
  • ✅ The LangChain nodes enabled in your n8n instance
  • ✅ Basic knowledge of how to trigger and run workflows in n8n

🔧 Step-by-Step Setup

1️⃣ Run Workflow

  • Node: Manual Trigger (Run Workflow)
  • Purpose: Manually start the workflow for testing or learning.

2️⃣ Create Random Data

  • Node: Create Random Data (Code)
  • What it does: Simulates incoming data with multiple content ideas.
  • Code:
return [
  {
    json: {
      row_number: 2,
      id: 1,
      Date: '2025-07-30',
      idea: 'n8n rises to the top',
      caption: '',
      complete: ''
    }
  },
  {
    json: {
      row_number: 3,
      id: 2,
      Date: '2025-07-31',
      idea: 'n8n nodes',
      caption: '',
      complete: ''
    }
  },
  {
    json: {
      row_number: 4,
      id: 3,
      Date: '2025-08-01',
      idea: 'n8n use cases for marketing',
      caption: '',
      complete: ''
    }
  }
];

3️⃣ Loop Over Items

  • Node: Loop Over Items (SplitInBatches)
  • Purpose: Sends one record at a time to the next node.
  • Why It Matters: Loops in n8n are created using this node when you want to iterate over multiple items.

4️⃣ Create Captions with AI

  • Node: Create Captions (LangChain Agent)
  • Prompt:
idea: {{ $json.idea }}
  • System Message:
You are a helpful assistant creating captions for a LinkedIn post. Please create a LinkedIn caption for the idea.
  • Model: GPT-4o Mini or GPT-3.5
  • Credentials Required:
    • OpenAI Credential
      • Go to: OpenAI API Keys
      • Create a key and add it in n8n under credentials as “OpenAi account”

5️⃣ Inject Creativity (Optional)

  • Node: Tool: Inject Creativity (LangChain Tool)
  • Purpose: Demonstrates optional LangChain tools that can enhance or manipulate input/output.
  • Why It’s Cool: A great way to show chaining tools to AI agents.

6️⃣ Output Table

  • Node: Output Table (Set)
  • Purpose: Combines original ideas and generated captions into final structure.
  • Fields:
    • idea: ={{ $('Create Random Data').item.json.idea }}
    • output: ={{ $json.output }}

💡 Educational Value

This workflow demonstrates:

  • Creating dynamic inputs with the Code node
  • Using SplitInBatches to simulate looping
  • Sending dynamic prompts to an AI model
  • Using Set to structure the output data

Beginners will understand how item-level processing works in n8n and how powerful looping combined with AI can be.


📬 Need Help or Want to Customize This?

Robert Breen
Automation Consultant | AI Workflow Designer | n8n Expert
📧 [email protected]
🌐 ynteractive.com
🔗 LinkedIn


🏷️ Tags

n8n loops OpenAI LangChain workflow training beginner LinkedIn automation caption generator

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 2 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 3 - Tool: Inject Creativity

Type / Role
@n8n/n8n-nodes-langchain.toolThink - toolThink
Config choices
Version 1

Block 4 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Run Workflow

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 6 - Create Random Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 7 - Create Captions

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2

Block 8 - Output Table

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

3. Summary Table

Workflow Loop over items — beginner example
Complexity intermediate
Nodes 8
Categories Content Creation, Multimodal AI
Author Robert Breen
Published 07 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7152/7152.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Loop over items — beginner example do?

This workflow introduces beginners to one of the most fundamental concepts in n8n: looping over items . Using a simple use case—generating LinkedIn captions for content ideas—it demonstrates how to...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Content Creation, Multimodal AI use case.