AutomationFlowsAI & RAG › Create Long-form Documents From Simple Titles with Gpt-5 and Google Docs

Create Long-form Documents From Simple Titles with Gpt-5 and Google Docs

ByNghia Nguyen @nghiaaidev on n8n.io

Generate the document structure based on the provided title or short description. Use prompt chaining to create detailed content for each section while maintaining consistent context. Append the final content to a Google Document for easy access and review. Open the submission…

Event trigger★★★★☆ complexityAI-powered14 nodesOutput Parser StructuredMemory Buffer WindowGoogle DocsOpenAI ChatAgentForm TriggerForm
AI & RAG Trigger: Event Nodes: 14 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #10435 — we link there as the canonical source.

This workflow follows the Agent → Form recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "TkSOqdrMsNs3WpDK",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Generate Long Document",
  "tags": [],
  "nodes": [
    {
      "id": "60f4490d-4cb9-4cc6-bf22-cd106c3ffef2",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        496,
        48
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"blogTitle\": \"How to Build an AI Automation Workflow with n8n\",\n  \"sections\": [\n    {\n      \"sectionId\": 1,\n      \"sectionTitle\": \"Introduction: Why AI Automation Matters\",\n      \"sectionSummary\": \"Explain the rise of AI automation and why it's valuable for productivity.\"\n    },\n    {\n      \"sectionId\": 2,\n      \"sectionTitle\": \"Tools You Need to Get Started\",\n      \"sectionSummary\": \"List and briefly describe essential tools like n8n, OpenAI API, and Supabase.\"\n    },\n    {\n      \"sectionId\": 3,\n      \"sectionTitle\": \"Step-by-Step Workflow Setup\",\n      \"sectionSummary\": \"Break down how to connect nodes, triggers, and APIs to build the automation.\"\n    },\n    {\n      \"sectionId\": 4,\n      \"sectionTitle\": \"Testing and Optimization\",\n      \"sectionSummary\": \"Show how to test, debug, and improve the automation workflow.\"\n    },\n    {\n      \"sectionId\": 5,\n      \"sectionTitle\": \"Conclusion and Next Steps\",\n      \"sectionSummary\": \"Wrap up the article and encourage readers to experiment with AI workflows.\"\n    }\n  ]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "0aa103cc-e536-4041-a546-bf2ad16cd58d",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        928,
        -192
      ],
      "parameters": {
        "include": "allOtherFields",
        "options": {},
        "fieldToSplitOut": "sections"
      },
      "typeVersion": 1
    },
    {
      "id": "84a0b969-dcf6-484a-ac18-5ca1663926d0",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1152,
        -192
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "ad643365-42ef-4e62-9c3d-7da17915bb09",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        1520,
        -80
      ],
      "parameters": {
        "sessionKey": "={{ $('GetSections').item.json.documentId }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 30
      },
      "typeVersion": 1.3
    },
    {
      "id": "69495066-646b-4cd5-8bb2-01abb95c67c7",
      "name": "GetSections",
      "type": "n8n-nodes-base.set",
      "position": [
        704,
        -192
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5b79fc5b-55ae-42ed-a138-9150a7b86c70",
              "name": "sections",
              "type": "array",
              "value": "={{ $json.output.sections }}"
            },
            {
              "id": "73ed193b-9d56-4229-a1da-89037a241a3e",
              "name": "documentId",
              "type": "string",
              "value": "={{ Math.random().toString(36).substring(2, 10).toUpperCase() }}"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "d45e18a1-274b-42f8-a516-cdd7fa472703",
      "name": "CreateDocument",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        128,
        -336
      ],
      "parameters": {
        "title": "={{ $('On form submission').item.json.Title }}",
        "folderId": "default"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "3da122af-c430-4dc0-a237-2fd6008f5e0c",
      "name": "UpdateDocument",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1728,
        -192
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{$json.output + \"\\n\\n\"}}\n",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "documentURL": "={{ $('CreateDocument').item.json.id }}"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "988ad51b-7a09-4712-907e-d852a4d228ef",
      "name": "gpt-5-mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        368,
        48
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini",
          "cachedResultName": "gpt-5-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "033dd289-00c8-4753-b0b1-0f78cdfd9e63",
      "name": "gpt-5",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1392,
        -80
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5",
          "cachedResultName": "gpt-5"
        },
        "options": {
          "timeout": 600000
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "17a2ab80-75e7-4f72-92cb-c4d06b2fbf3c",
      "name": "ContentWriter",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1376,
        -304
      ],
      "parameters": {
        "text": "=Help write section:  {{ $json.sections.sectionId }}. {{ $json.sections.sectionTitle }}",
        "options": {
          "systemMessage": "=You are a professional content generator and technical writer.  \nYour task is to generate complete Markdown sections based on a provided JSON structure.\n\n#JSON structure:\n{{ $('ContentPlanner').item.json.output.toJsonString() }}\n\n# \ud83e\udde0 Instructions\nGenerate a complete, well-structured Markdown document.\nInclude all sections in order using their **sectionId**.\nEach section should include:\n- Heading in the format: `# {sectionId}. {sectionTitle}`  \n- Section must not exceed {{Math.floor($('On form submission').item.json['Word Count'] / $('GetSections').item.json.sections.length)}} words\n\n",
          "passthroughBinaryImages": false
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "338f10a7-01f3-454e-bd82-4b59b2be54f3",
      "name": "ContentPlanner",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        352,
        -192
      ],
      "parameters": {
        "text": "={{ $('On form submission').item.json.Title }}",
        "options": {
          "systemMessage": "# \u270d\ufe0f Prompt: Blog Outline Generator Agent\n\n## **Role**\nYou are a **professional content planner and blog strategist**.\n\n## **Goal**\nAnalyze the user\u2019s topic or idea, then **generate a complete blog post outline** with clear structure, logical flow, and engaging section titles.\n\n## **Instructions**\n1. Read the user\u2019s description or topic carefully.  \n2. Identify the **main goal** of the article (inform, persuade, educate, or inspire).  \n3. Create a **structured outline** with key sections and short explanations for each.  \n4. Include **subheadings** (H2, H3) and **logical progression** from introduction to conclusion.  \n5. Focus on **clarity, SEO-friendly phrasing, and reader engagement**.  \n6. Do **not** write the full article \u2014 only the **outline and section summaries**."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "67ecec8d-12d3-4923-bbde-ca710d2465d4",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -96,
        -336
      ],
      "parameters": {
        "options": {},
        "formTitle": "Generate Long Content",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Title",
              "placeholder": "title or short description",
              "requiredField": true
            },
            {
              "fieldType": "number",
              "fieldLabel": "Word Count",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Help generate long document from a title"
      },
      "typeVersion": 2.3
    },
    {
      "id": "6e4ebbe6-c39d-4b9a-832a-69824b207f06",
      "name": "Form",
      "type": "n8n-nodes-base.form",
      "position": [
        416,
        -480
      ],
      "parameters": {
        "options": {
          "customCss": ":root {\n\t--font-family: 'Open Sans', sans-serif;\n\t--font-weight-normal: 400;\n\t--font-weight-bold: 600;\n\n\t/* Typography \u2014 larger & more readable */\n\t--font-size-body: 16px;\n\t--font-size-label: 15px;\n\t--font-size-test-notice: 13px;\n\t--font-size-input: 15px;\n\t--font-size-header: 24px;\n\t--font-size-paragraph: 16px;\n\t--font-size-link: 14px;\n\t--font-size-error: 13px;\n\t--font-size-html-h1: 34px;\n\t--font-size-html-h2: 26px;\n\t--font-size-html-h3: 20px;\n\t--font-size-html-h4: 18px;\n\t--font-size-html-h5: 16px;\n\t--font-size-html-h6: 14px;\n\t--font-size-subheader: 16px;\n\n\t/* Colors \u2014 higher contrast & friendlier accents */\n\t--color-background: #f7f8fc;\n\t--color-test-notice-text: #b45309;     /* deeper amber for contrast */\n\t--color-test-notice-bg: #fff7ed;\n\t--color-test-notice-border: #fed7aa;\n\n\t--color-card-bg: #ffffff;\n\t--color-card-border: #e5e7eb;\n\t--color-card-shadow: rgba(31, 41, 55, 0.06);\n\n\t--color-link: #2563eb;                 /* accessible blue for standard links */\n\t--color-header: #1f2937;               /* slate-800 */\n\t--color-label: #374151;                /* slate-700 */\n\t--color-input-border: #cbd5e1;         /* slate-300 */\n\t--color-input-text: #111827;           /* slate-900 */\n\t--color-focus-border: #7c3aed;         /* vivid violet focus ring */\n\t--color-submit-btn-bg: #ff6d5a;        /* brand coral kept */\n\t--color-submit-btn-text: #ffffff;\n\t--color-error: #dc2626;                /* red-600 */\n\t--color-required: #ef4444;             /* red-500 */\n\t--color-clear-button-bg: #6b7280;      /* slate-500 */\n\t--color-html-text: #374151;            /* slate-700 */\n\t--color-html-link: #ff6d5a;            /* brand accent for content links */\n\t--color-header-subtext: #6b7280;       /* slate-500 */\n\n\t/* Border Radii \u2014 slightly softer */\n\t--border-radius-card: 10px;\n\t--border-radius-input: 8px;\n\t--border-radius-clear-btn: 50%;\n\t--card-border-radius: 10px;\n\n\t/* Spacing \u2014 room to breathe */\n\t--padding-container-top: 32px;\n\t--padding-card: 28px;\n\t--padding-test-notice-vertical: 12px;\n\t--padding-test-notice-horizontal: 24px;\n\t--margin-bottom-card: 20px;\n\t--padding-form-input: 14px;\n\t--card-padding: 28px;\n\t--card-margin-bottom: 20px;\n\n\t/* Dimensions \u2014 wider layout */\n\t--container-width: 720px;\n\t--submit-btn-height: 52px;\n\t--checkbox-size: 20px;\n\n\t/* Others \u2014 subtle shadow & clearer placeholders */\n\t--box-shadow-card: 0px 6px 20px 0px var(--color-card-shadow);\n\t--opacity-placeholder: 0.6;\n}\n"
        },
        "operation": "completion",
        "completionTitle": "Generating your document\u2026 Please wait a few minutes, then access the link below",
        "completionMessage": "=https://docs.google.com/document/d/{{ $('CreateDocument').item.json.id }}"
      },
      "typeVersion": 2.3
    },
    {
      "id": "f3db576d-70cb-46ce-a6ec-f291c486807e",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        -592
      ],
      "parameters": {
        "width": 848,
        "height": 992,
        "content": "# \ud83e\udded Overview\nThis workflow takes a title and automatically creates a detailed Google Document.\nIt first builds an outline, then writes each section based on the word limit, and finally saves everything into the Google Doc.\n\n---\n\n## \u2699\ufe0f Setup\n1. Connect **Google Docs OAuth** for the `CreateDocument` and `UpdateDocument` nodes.  \n2. Add your **OpenAI API Key** for `gpt-5-mini` (outline planner) and `gpt-5` (content writer).  \n3. Open the public **Form URL**, submit your Title and Word Count.  \n4. The generated Google Document link will appear after submission.\n\n---\n\n## \ud83d\udcdd How to Use\n1. Open the submission form.\n2. Enter your title and word count.\n3. Click Submit to generate your Google Document link.\n4. Wait a few minutes \u2014 the completed document will be ready at that link.\n\n---\n\n## \ud83c\udfa8 Customize\n- Change models in **\u201cgpt-5-mini\u201d** and **\u201cgpt-5\u201d** nodes.  \n- Edit outline generation rules in the **ContentPlanner** system prompt.  \n- Modify section format and word-cap logic in the **ContentWriter** system prompt.  \n- Adjust document title or folder source (Form \u2192 Title or Folder ID).  \n- Update CSS in the **Form node \u2192 Completion \u2192 customCss** to match your brand.\n\n---\n\n## \ud83d\udcb0 Costs & Limits\n- **OpenAI token usage** scales with *Word Count \u00d7 Number of Sections*.  \n- **Execution time limit:** The `gpt-5` node has a 10-minute timeout (increase if needed).  \n- For long documents, consider reducing word count per section or batching.  \n- **Google Docs API** has write-rate limits \u2014 this workflow handles appends one section at a time to stay within safe limits.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "aac61755-8db8-4852-b401-a5cb8e5c21ef",
  "connections": {
    "gpt-5": {
      "ai_languageModel": [
        [
          {
            "node": "ContentWriter",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "gpt-5-mini": {
      "ai_languageModel": [
        [
          {
            "node": "ContentPlanner",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "GetSections": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ContentWriter": {
      "main": [
        [
          {
            "node": "UpdateDocument",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "ContentWriter",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "ContentPlanner": {
      "main": [
        [
          {
            "node": "GetSections",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CreateDocument": {
      "main": [
        [
          {
            "node": "Form",
            "type": "main",
            "index": 0
          },
          {
            "node": "ContentPlanner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "UpdateDocument": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "ContentWriter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "CreateDocument",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "ContentPlanner",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Generate the document structure based on the provided title or short description. Use prompt chaining to create detailed content for each section while maintaining consistent context. Append the final content to a Google Document for easy access and review. Open the submission…

Source: https://n8n.io/workflows/10435/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow serves as a comprehensive "Workflow Nodes SEO & Documentation Generator". It uses AI to analyze, rename, and document n8n workflows, offering a streamlined way to optimize workflow reada

Form Trigger, n8n, Output Parser Autofixing +11
AI & RAG

This workflow generates comprehensive B2B leads, from a selected Business type in ANY CITY IN THE WORLD, including: Company name; Website; Email (enriched with AI Agent); Phone number; Address; Main L

Output Parser Structured, Memory Buffer Window, Agent +8
AI & RAG

This workflow streamlines your content organization process by automatically analyzing new blog posts in your GitHub repository and assigning appropriate categories and tags using OpenAI. It compares

Agent, Memory Buffer Window, OpenAI Chat +5
AI & RAG

This n8n workflow automates the entire content creation process for SEO blog posts, from topic submission and AI drafting to human approval, revision, and final storage in Google Docs. It ensures high

Agent, OpenAI Chat, Memory Buffer Window +5
AI & RAG

Submit a LinkedIn profile URL through a form. The workflow finds their email and company info using Wiza, then researches the prospect and their company with Perplexity AI to uncover recent news, grow

Output Parser Structured, OpenAI Chat, Agent +8