Skip to main content

Generate written content with GPT Recursive Writing & Editing agents

Workflow preview

Workflow preview
100%
Generate written content with GPT Recursive Writing & Editing agents preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Who is this for? Content creators, writers, and automation enthusiasts experimenting with recursive AI workflows for content generation and refinement. Ideal for those exploring AI agents that coll...

Best for

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

Tools used

@n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.memorybufferwindow, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.outputparserstructured, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.code, n8n-nodes-base.if, @n8n/n8n-nodes-langchain.agent

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Generate written content with GPT Recursive Writing & Editing agents
Workflow name
Generate written content with GPT Recursive Writing & Editing agents

Who is this for?

Content creators, writers, and automation enthusiasts experimenting with recursive AI workflows for content generation and refinement. Ideal for those exploring AI agents that collaborate in cycles of writing and editing.

What problem does this solve?

This template introduces a fully automated, recursive writing‑editing loop using multi‑agent collaboration. A “Writing Agent” generates content based on an input topic. An “Editing Agent” reviews it, suggests improvements, and determines whether the work is complete. The loop continues until the editor is satisfied—allowing for high‑quality, iterative AI‑assisted writing with minimal human input.

How it works

This template is a foundational setup to help you build custom recursive writing workflows:

  1. Trigger: Activated by an n8n chat message containing a topic. You can customize this to work with webhooks, forms, or other input sources.

  2. Edit Handler: A code node checks for previous edits and sets a default empty string if none are found.

  3. Writing Agent: Generates a blurb based on the topic and any edits. Customize the prompt in this node by editing the user/system instructions to fit your tone, domain, or style preferences.

  4. Editing Agent: Suggests specific edits and outputs a structured JSON object:

    {
      "status": "incomplete",
      "edits": "Replace passive voice with active voice in the second sentence. Clarify the main idea in the opening line."
    }
    

    You can adjust the JSON format or editing criteria in the prompt field. Customize the prompt in this node by editing the user/system instructions to fit your tone, domain, or style preferences.

  5. Recursive Loop: If the status is “incomplete,” the edits are passed back to the Writing Agent, which revises the blurb.

  6. Completion: Once the Editing Agent outputs a status of “complete,” the workflow ends, and the final blurb is returned to the n8n chat.

Setup Steps

  1. Import the Template into your n8n workspace.
  2. Configure API Credentials: Link your OpenAI API key (or your preferred LLM like Claude or Gemini) in the credentials section.
  3. Customize the Prompts (Optional but recommended):
    • In the Writing Agent, you can instruct it to mimic a specific tone, format, or genre.
    • In the Editing Agent, specify your editing standards (e.g., concise, persuasive, technical).
    • Modify the JSON output structure in the Structured Output Parser node if needed.
  4. Test and Iterate: Run a test by sending a topic via the chat trigger and observe the loop behavior.

Example Output

Input Topic: “The future of remote work”
Final Blurb: “Remote work is here to stay. As companies embrace flexible setups, productivity and employee satisfaction are reaching new highs. The challenge now is to build culture and collaboration tools that keep up.”

This template offers a powerful starting point for recursive AI writing. Expand it with additional agents, tone shifts, formatting layers, or sentiment analysis as needed.

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 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 2 - Window Buffer Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 3 - set variables

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

Block 4 - chatInput

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

Block 5 - Structured Output Parser

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

Block 6 - OpenAI Chat Model

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

Block 7 - handle edits

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

Block 8 - If Status Complete

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 9 - Writing Agent

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

Block 10 - Editing Agent

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

Block 11 - chatOutput

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

Block 12 - Sticky Note

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

Block 13 - Sticky Note1

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

3. Summary Table

Workflow Generate written content with GPT Recursive Writing & Editing agents
Complexity intermediate
Nodes 13
Categories Content Creation, Multimodal AI
Author Matty Reed
Published 09 Apr 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3503/3503.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 Generate written content with GPT Recursive Writing & Editing agents do?

Who is this for? Content creators, writers, and automation enthusiasts experimenting with recursive AI workflows for content generation and refinement. Ideal for those exploring AI agents that coll...

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.