Skip to main content

Beginner AI dataset generator using OpenAI + LangChain in n8n

Workflow preview

Workflow preview
100%
Beginner AI dataset generator using OpenAI + LangChain in n8n 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 n8n workflow dynamically generates a realistic sample dataset based on a single topic you provide. It uses OpenAI (via LangChain) and n8n’s built in nodes to: 1. Generate structured JSON data ...

Best for

  • Document Extraction automation workflows
  • Multimodal AI automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

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

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
Beginner AI dataset generator using OpenAI + LangChain in n8n
Workflow name
Beginner AI dataset generator using OpenAI + LangChain in n8n

This n8n workflow dynamically generates a realistic sample dataset based on a single topic you provide. It uses OpenAI (via LangChain) and n8n’s built-in nodes to:

  1. Generate structured JSON data for 5 columns with 3–5 values each
  2. Flatten that data into a single text blob
  3. Infer meaningful column names via a second AI call
  4. Pivot, split, merge, and rename columns automatically
  5. Output a clean, labeled dataset ready for export or further processing

⚙️ Prerequisites

  1. OpenAI API Key

  2. LangChain nodes enabled in your n8n instance

🥇 Step 1: Set Up OpenAI Credential

  1. Go to OpenAI API Keys
  2. Create and copy your key
  3. In n8n: Credentials → New → OpenAI API → paste key as “OpenAi account”

🥈 Step 2: Manual Trigger

  • Add Manual Trigger to start the workflow

🥉 Step 3: Set Topic

  • Add a Set node named Set Topic to Search
  • Field: Topic = n8n use cases (or any topic you choose)

✨ Step 4: Generate Structured Data

  • LangChain Agent node Generate Random Data
  • Connect to OpenAI Chat Model1 and Tool: Inject Creativity1
  • System prompt: instruct AI to output 5 columns of realistic values in JSON

🔧 Step 5: Parse AI Output

  • Structured Output Parser to validate JSON

🔄 Step 6: Flatten Data

  • Code node Outpt all Data to One Field
  • Joins all values into a comma-separated string for column naming

🧠 Step 7: Generate Column Names

  • LangChain Agent Generate Column Names
  • Connect to OpenAI Chat Model2
  • Prompt: infer 5 column names from the string

🔢 Step 8: Pivot Names Row

  • Code node Pivot Column Names transforms array into { column1: name1, … }

🪓 Step 9: Split Columns

  • 5 SplitOut nodes to break each array back into rows per column

🔗 Step 10: Merge Rows

  • Merge node Merge Columns together using combineByPosition

🏷️ Step 11: Rename Columns

  • Set node Rename Columns assigns the AI-generated names to each column

🔗 Step 12: Final Output

  • Merge Append Column Names combines data and header row

🏁 Done! You now have a fully AI-driven, labeled dataset generated from a single topic—no external services needed. Easily extend by adding a Google Sheets or HTTP node to export.

📬 Need Help or Want to Customize This?

📧 [email protected]
🔗 LinkedIn

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 - OpenAI Chat Model1

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

Block 2 - Tool: Inject Creativity1

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

Block 3 - Structured Output Parser

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

Block 4 - OpenAI Chat Model2

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

Block 5 - Structured Output Parser1

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

Block 6 - Run Workflow

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

Block 7 - Sticky Note4

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

Block 8 - Sticky Note5

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

Block 9 - Sticky Note7

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

Block 10 - Sticky Note8

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

Block 11 - Sticky Note10

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

Block 12 - Set Topic to Search

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

Block 13 - Generate Random Data

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

Block 14 - Outpt all Data to One Field

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

Block 15 - Generate Column Names

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

Block 16 - Pivot Column Names

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

Block 17 - Split Column 1

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

Block 18 - Split Column 2

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

Block 19 - Split Column 3

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

Block 20 - Split Column 4

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

Block 21 - Split Column 5

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

Block 22 - Merge Columns together

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 23 - Rename Columns

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

Block 24 - Append Column Names

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

3. Summary Table

Workflow Beginner AI dataset generator using OpenAI + LangChain in n8n
Complexity advanced
Nodes 24
Categories Document Extraction, Multimodal AI
Author Robert Breen
Published 08 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7154/7154.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 Beginner AI dataset generator using OpenAI + LangChain in n8n do?

This n8n workflow dynamically generates a realistic sample dataset based on a single topic you provide. It uses OpenAI (via LangChain) and n8n’s built in nodes to: 1. Generate structured JSON data ...

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 Document Extraction, Multimodal AI use case.