Back to Catalog

Generate written content with GPT Recursive Writing & Editing agents

Matty ReedMatty Reed
1434 views
2/3/2026
Official Page

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.

n8n AI Agent for Recursive Writing and Editing

This n8n workflow demonstrates a foundational setup for an AI agent capable of recursive writing and editing tasks. While the provided JSON defines the core components, it serves as a robust starting point for building sophisticated content generation and refinement processes using Large Language Models (LLMs).

What it does

This workflow establishes the basic architecture for an AI agent, including:

  1. Receives Chat Messages: Initiates the workflow upon receiving a chat message, likely containing a prompt or instruction for the AI agent.
  2. Initializes AI Agent: Sets up an AI Agent node, which is the core orchestrator for the AI's actions.
  3. Configures OpenAI Chat Model: Defines the specific OpenAI Chat Model to be used by the AI Agent for generating and processing text.
  4. Establishes Simple Memory: Integrates a basic memory buffer to allow the AI Agent to retain context from previous interactions within a window.
  5. Prepares Structured Output Parser: Includes a structured output parser, indicating an intention to guide the AI to produce output in a specific, parseable format (e.g., JSON).
  6. Conditional Logic: Incorporates an "If" node, suggesting the potential for branching logic based on conditions, which could be used for decision-making in recursive processes (e.g., "if content needs editing, then edit").
  7. Data Manipulation: Utilizes "Edit Fields (Set)" and "Code" nodes for transforming and manipulating data within the workflow, essential for preparing prompts or processing AI responses.
  8. Documentation: Includes a "Sticky Note" for internal documentation or notes within the workflow.

Prerequisites/Requirements

To use this workflow, you will need:

  • n8n Instance: A running n8n instance (cloud or self-hosted).
  • OpenAI API Key: Credentials for an OpenAI account with access to their chat models. This will need to be configured in the "OpenAI Chat Model" node.

Setup/Usage

  1. Import the workflow:
    • Save the provided JSON content as a .json file.
    • In your n8n instance, click "Workflows" in the left sidebar.
    • Click "New" or the "+" icon, then select "Import from JSON".
    • Upload the saved JSON file.
  2. Configure Credentials:
    • Locate the "OpenAI Chat Model" node.
    • Click on it and configure your OpenAI API credentials.
  3. Activate the Workflow:
    • Once configured, activate the workflow by toggling the "Active" switch in the top right corner of the workflow editor.
  4. Trigger the Workflow:
    • Send a chat message to the configured "Chat Trigger" to initiate the AI agent. The exact method for sending a chat message depends on how the "Chat Trigger" is exposed (e.g., through a specific chat platform integration).

This workflow provides a powerful foundation. To achieve full recursive writing and editing capabilities, you would typically expand upon this by:

  • Adding more sophisticated logic in the "If" node to determine if content needs further iteration (e.g., checking for specific keywords, length, or quality metrics).
  • Looping back AI responses to the agent for further refinement (e.g., taking an AI-generated draft, feeding it back with an "edit this" prompt).
  • Integrating external tools (e.g., for spell-checking, grammar, or content analysis) as custom tools for the AI Agent.
  • Defining specific "tools" for the AI Agent to use for various writing and editing tasks.

Related Templates

Auto-create TikTok videos with VEED.io AI avatars, ElevenLabs & GPT-4

💥 Viral TikTok Video Machine: Auto-Create Videos with Your AI Avatar --- 🎯 Who is this for? This workflow is for content creators, marketers, and agencies who want to use Veed.io’s AI avatar technology to produce short, engaging TikTok videos automatically. It’s ideal for creators who want to appear on camera without recording themselves, and for teams managing multiple brands who need to generate videos at scale. --- ⚙️ What problem this workflow solves Manually creating videos for TikTok can take hours — finding trends, writing scripts, recording, and editing. By combining Veed.io, ElevenLabs, and GPT-4, this workflow transforms a simple Telegram input into a ready-to-post TikTok video featuring your AI avatar powered by Veed.io — speaking naturally with your cloned voice. --- 🚀 What this workflow does This automation links Veed.io’s video-generation API with multiple AI tools: Analyzes TikTok trends via Perplexity AI Writes a 10-second viral script using GPT-4 Generates your voiceover via ElevenLabs Uses Veed.io (Fabric 1.0 via FAL.ai) to animate your avatar and sync the lips to the voice Creates an engaging caption + hashtags for TikTok virality Publishes the video automatically via Blotato TikTok API Logs all results to Google Sheets for tracking --- 🧩 Setup Telegram Bot Create your bot via @BotFather Configure it as the trigger for sending your photo and theme Connect Veed.io Create an account on Veed.io Get your FAL.ai API key (Veed Fabric 1.0 model) Use HTTPS image/audio URLs compatible with Veed Fabric Other APIs Add Perplexity, ElevenLabs, and Blotato TikTok keys Connect your Google Sheet for logging results --- 🛠️ How to customize this workflow Change your Avatar: Upload a new image through Telegram, and Veed.io will generate a new talking version automatically. Modify the Script Style: Adjust the GPT prompt for tone (educational, funny, storytelling). Adjust Voice Tone: Tweak ElevenLabs stability and similarity settings. Expand Platforms: Add Instagram, YouTube Shorts, or X (Twitter) posting nodes. Track Performance: Customize your Google Sheet to measure your most successful Veed.io-based videos. --- 🧠 Expected Outcome In just a few seconds after sending your photo and theme, this workflow — powered by Veed.io — creates a fully automated TikTok video featuring your AI avatar with natural lip-sync and voice. The result is a continuous stream of viral short videos, made without cameras, editing, or effort. --- ✅ Import the JSON file in n8n, add your API keys (including Veed.io via FAL.ai), and start generating viral TikTok videos starring your AI avatar today! 🎥 Watch This Tutorial --- 📄 Documentation: Notion Guide Need help customizing? Contact me for consulting and support : Linkedin / Youtube

Dr. FirasBy Dr. Firas
39510

Track competitor SEO keywords with Decodo + GPT-4.1-mini + Google Sheets

This workflow automates competitor keyword research using OpenAI LLM and Decodo for intelligent web scraping. Who this is for SEO specialists, content strategists, and growth marketers who want to automate keyword research and competitive intelligence. Marketing analysts managing multiple clients or websites who need consistent SEO tracking without manual data pulls. Agencies or automation engineers using Google Sheets as an SEO data dashboard for keyword monitoring and reporting. What problem this workflow solves Tracking competitor keywords manually is slow and inconsistent. Most SEO tools provide limited API access or lack contextual keyword analysis. This workflow solves that by: Automatically scraping any competitor’s webpage with Decodo. Using OpenAI GPT-4.1-mini to interpret keyword intent, density, and semantic focus. Storing structured keyword insights directly in Google Sheets for ongoing tracking and trend analysis. What this workflow does Trigger — Manually start the workflow or schedule it to run periodically. Input Setup — Define the website URL and target country (e.g., https://dev.to, france). Data Scraping (Decodo) — Fetch competitor web content and metadata. Keyword Analysis (OpenAI GPT-4.1-mini) Extract primary and secondary keywords. Identify focus topics and semantic entities. Generate a keyword density summary and SEO strength score. Recommend optimization and internal linking opportunities. Data Structuring — Clean and convert GPT output into JSON format. Data Storage (Google Sheets) — Append structured keyword data to a Google Sheet for long-term tracking. Setup Prerequisites If you are new to Decode, please signup on this link visit.decodo.com n8n account with workflow editor access Decodo API credentials OpenAI API key Google Sheets account connected via OAuth2 Make sure to install the Decodo Community node. Create a Google Sheet Add columns for: primarykeywords, seostrengthscore, keyworddensity_summary, etc. Share with your n8n Google account. Connect Credentials Add credentials for: Decodo API credentials - You need to register, login and obtain the Basic Authentication Token via Decodo Dashboard OpenAI API (for GPT-4o-mini) Google Sheets OAuth2 Configure Input Fields Edit the “Set Input Fields” node to set your target site and region. Run the Workflow Click Execute Workflow in n8n. View structured results in your connected Google Sheet. How to customize this workflow Track Multiple Competitors → Use a Google Sheet or CSV list of URLs; loop through them using the Split In Batches node. Add Language Detection → Add a Gemini or GPT node before keyword analysis to detect content language and adjust prompts. Enhance the SEO Report → Expand the GPT prompt to include backlink insights, metadata optimization, or readability checks. Integrate Visualization → Connect your Google Sheet to Looker Studio for SEO performance dashboards. Schedule Auto-Runs → Use the Cron Node to run weekly or monthly for competitor keyword refreshes. Summary This workflow automates competitor keyword research using: Decodo for intelligent web scraping OpenAI GPT-4.1-mini for keyword and SEO analysis Google Sheets for live tracking and reporting It’s a complete AI-powered SEO intelligence pipeline ideal for teams that want actionable insights on keyword gaps, optimization opportunities, and content focus trends, without relying on expensive SEO SaaS tools.

Ranjan DailataBy Ranjan Dailata
161

Generate song lyrics and music from text prompts using OpenAI and Fal.ai Minimax

Spark your creativity instantly in any chat—turn a simple prompt like "heartbreak ballad" into original, full-length lyrics and a professional AI-generated music track, all without leaving your conversation. 📋 What This Template Does This chat-triggered workflow harnesses AI to generate detailed, genre-matched song lyrics (at least 600 characters) from user messages, then queues them for music synthesis via Fal.ai's minimax-music model. It polls asynchronously until the track is ready, delivering lyrics and audio URL back in chat. Crafts original, structured lyrics with verses, choruses, and bridges using OpenAI Submits to Fal.ai for melody, instrumentation, and vocals aligned to the style Handles long-running generations with smart looping and status checks Returns complete song package (lyrics + audio link) for seamless sharing 🔧 Prerequisites n8n account (self-hosted or cloud with chat integration enabled) OpenAI account with API access for GPT models Fal.ai account for AI music generation 🔑 Required Credentials OpenAI API Setup Go to platform.openai.com → API keys (sidebar) Click "Create new secret key" → Name it (e.g., "n8n Songwriter") Copy the key and add to n8n as "OpenAI API" credential type Test by sending a simple chat completion request Fal.ai HTTP Header Auth Setup Sign up at fal.ai → Dashboard → API Keys Generate a new API key → Copy it In n8n, create "HTTP Header Auth" credential: Name="Fal.ai", Header Name="Authorization", Header Value="Key [Your API Key]" Test with a simple GET to their queue endpoint (e.g., /status) ⚙️ Configuration Steps Import the workflow JSON into your n8n instance Assign OpenAI API credentials to the "OpenAI Chat Model" node Assign Fal.ai HTTP Header Auth to the "Generate Music Track", "Check Generation Status", and "Fetch Final Result" nodes Activate the workflow—chat trigger will appear in your n8n chat interface Test by messaging: "Create an upbeat pop song about road trips" 🎯 Use Cases Content Creators: YouTubers generating custom jingles for videos on the fly, streamlining production from idea to audio export Educators: Music teachers using chat prompts to create era-specific folk tunes for classroom discussions, fostering interactive learning Gift Personalization: Friends crafting anniversary R&B tracks from shared memories via quick chats, delivering emotional audio surprises Artist Brainstorming: Songwriters prototyping hip-hop beats in real-time during sessions, accelerating collaboration and iteration ⚠️ Troubleshooting Invalid JSON from AI Agent: Ensure the system prompt stresses valid JSON; test the agent standalone with a sample query Music Generation Fails (401/403): Verify Fal.ai API key has minimax-music access; check usage quotas in dashboard Status Polling Loops Indefinitely: Bump wait time to 45-60s for complex tracks; inspect fal.ai queue logs for bottlenecks Lyrics Under 600 Characters: Tweak agent prompt to enforce fuller structures like [V1][C][V2][B][C]; verify output length in executions

Daniel NkenchoBy Daniel Nkencho
601