AutomationFlowsAI & RAG › Generate Branded Word Documents with Claude AI and Json2doc (up to 20 Pages)

Generate Branded Word Documents with Claude AI and Json2doc (up to 20 Pages)

By8Automator @kesim0 on n8n.io

This n8n workflow automatically generates professionally formatted Word documents (DOCX) with consistent company branding using AI. It leverages Json2Doc and the Json2Doc MCP server to transform simple text prompts into complete, multi-page documents.

Event trigger★★★★☆ complexityAI-powered15 nodesAnthropic ChatOutput Parser StructuredOpenRouter ChatMcp Client ToolAgentForm TriggerHTTP Request
AI & RAG Trigger: Event Nodes: 15 Complexity: ★★★★☆ AI nodes: yes Added:

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

This workflow follows the Agent → Form Trigger 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": "XwaL3YqmSyHJOAJk",
  "name": "0_generate_full_word_documents_with_ai",
  "tags": [],
  "nodes": [
    {
      "id": "3eb01a62-1f19-425c-9fed-fb2cb124f070",
      "name": "Anthropic Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        848,
        96
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {
          "thinking": false,
          "maxTokensToSample": 8000
        }
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "6e277f2c-66dd-48e7-9e52-180fa702818d",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1088,
        48
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "{\n\t\"JobId\": \"1234\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "8c0dbfa6-7819-40a8-bc59-65e92531a55c",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1088,
        176
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f6a6e5bb-3a29-4897-8831-b3997a16edb0",
      "name": "Json2Doc MCP",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        976,
        96
      ],
      "parameters": {
        "include": "selected",
        "options": {},
        "endpointUrl": "https://mcp.json2doc.com/mcp",
        "includeTools": [
          "Create_a_new_job",
          "Get_section_schema"
        ],
        "authentication": "headerAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "592591d8-8317-4033-a220-980721e56790",
      "name": "Add Company styleguide",
      "type": "n8n-nodes-base.set",
      "position": [
        576,
        -112
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"fontFamily\": \"Arial\",\n  \"fontSize\": 11,\n  \"color\": \"#333333\",\n  \"lineHeight\": 1.5,\n  \"spacing\": {\n    \"before\": {\n      \"h1\": 24,\n      \"h2\": 18,\n      \"h3\": 14,\n      \"text\": 0,\n      \"table\": 15,\n      \"list\": 10,\n      \"image\": 15\n    },\n    \"after\": {\n      \"h1\": 18,\n      \"h2\": 14,\n      \"h3\": 10,\n      \"text\": 12,\n      \"table\": 15,\n      \"list\": 10,\n      \"image\": 15\n    }\n  },\n  \"styles\": {\n    \"h1\": {\n      \"fontSize\": 28,\n      \"fontWeight\": \"bold\",\n      \"color\": \"#1a365d\",\n      \"align\": \"center\"\n    },\n    \"h2\": {\n      \"fontSize\": 22,\n      \"fontWeight\": \"bold\",\n      \"color\": \"#2d3748\"\n    }\n  },\n  \"header\": {\n    \"left\": \"Example LLC\",\n    \"right\": {\n      \"type\": \"image\",\n      \"src\": \"{{ $json['Logo URL'] }}\",\n      \"width\": 30,\n      \"alt\": \"Company Logo\"\n    },\n    \"excludeFirstPage\": false\n  },\n  \"footer\": {\n    \"center\": \"{{ 'Page ' + String.fromCharCode(123) + String.fromCharCode(123) + 'pageNumber' + String.fromCharCode(125) + String.fromCharCode(125) + ' of ' + String.fromCharCode(123) + String.fromCharCode(123) + 'totalPages' + String.fromCharCode(125) + String.fromCharCode(125) }}\",\n\n    \"align\": \"center\",\n    \"excludeFirstPage\": false\n  }\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "b3785edf-88e1-42d5-ba14-85c3235e1ca0",
      "name": "Generate Sections",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        880,
        -112
      ],
      "parameters": {
        "text": "=The user wants to create a document with the following prompt:\n```\n {{ $('On form submission').item.json.Prompt }}\n```",
        "options": {
          "maxIterations": 10,
          "systemMessage": "=You are a professional document creator using only the Json2Doc MCP tool.\n\nCheck the user input and generate based on experience a docx document.\n\nDO NOT USE THE BUILDER MODE.\n\nTHE TOOL Validate job and create a job REQUIRES A JSON CONFIG REPRESENTING THE DOCUMENT AS INPUT\n\nhow to proceed :\n1. get the schema for sections from the tool\n2. generate a Json Definition for the document based on the schema from 1 by adding them to this config:\n```\n{\n  \"document\": {\n    \"type\": \"docx\",\n    \"filename\": \"ADD A FITTING NAME HERE (without suffix)\",\n    \"title\": \"ADD THE DOCUMENT TITLE HERE\"\n  },\n  //KEEP DEFAULTS AS DEFINED HERE 1:1\n  \"defaults\": {{ $json.toJsonString() }},\n  \"sections\": [\n    // ADD SECTIONS ACORDING TO SCHEMA HERE (2 Types supportet page and flow)\n    {\n      \"type\": \"page\",\n      \"content\": [\n        {\n          \"type\": \"h1\",\n          \"text\": \"FULL SINGLE PAGE EXAMPLE\"\n        }\n      ]\n    },\n    {\n      \"type\": \"flow\",\n      \"content\": [\n        {\n          \"type\": \"h2\",\n          \"text\": \"EXAMPLE FLOW -> continues seamlessly across pages\",\n          \"spacing\": { \"before\": 20 }\n        }]}\n  ]\n}\n\n```\n\n3. validate your generated json configuration based on the schema from 2 as config input by creating a new jo (if vaidation returns invaid retry until its valid and you get the job id)\n4. trigger a new job with the valid json you generated based on the schema from 1\n5. return The JobID "
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "c6838320-5262-421f-81a8-024cc4564ecc",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        288,
        -112
      ],
      "parameters": {
        "options": {},
        "formTitle": "Generate docx",
        "formFields": {
          "values": [
            {
              "fieldType": "textarea",
              "fieldLabel": "Prompt",
              "placeholder": "Generate a template for an annual report",
              "requiredField": true
            },
            {
              "fieldLabel": "Logo URL",
              "placeholder": "https://example.com/logo.png"
            }
          ]
        },
        "formDescription": "Generate a Word file (docx) with company branding"
      },
      "typeVersion": 2.3
    },
    {
      "id": "06280495-249f-403f-ba3d-becd5194d116",
      "name": "Download Docx",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1856,
        -112
      ],
      "parameters": {
        "url": "=https://api.json2doc.com/api/v1/files/{{ $json.data.outputFileId }}/download",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/octet-stream"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "dba91ccb-3d9f-4d3f-ae3d-7603f5f4bcfd",
      "name": "Wait for Document Generation",
      "type": "n8n-nodes-base.wait",
      "position": [
        1424,
        -112
      ],
      "parameters": {
        "amount": 3
      },
      "typeVersion": 1.1
    },
    {
      "id": "fdb49828-9ad2-48ce-9297-bf498798c424",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1552,
        -112
      ],
      "parameters": {
        "url": "=https://api.json2doc.com/api/v1/jobs/{{ $json.output.JobId }}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "d1fdcd8b-7a56-46bb-95e8-2c639a192e74",
      "name": "is Completed?",
      "type": "n8n-nodes-base.if",
      "position": [
        1680,
        -112
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "27c14f40-8e32-4115-88f7-56098d814e71",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.status }}",
              "rightValue": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ee276d02-e143-48d7-a897-e563c020ff23",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        -192
      ],
      "parameters": {
        "color": 5,
        "width": 256,
        "height": 240,
        "content": "## Input Form\nTakes a Promt and a logo URL as input"
      },
      "typeVersion": 1
    },
    {
      "id": "7fd19214-9027-4dc2-85af-e14bc79481e4",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        -320
      ],
      "parameters": {
        "width": 288,
        "height": 400,
        "content": "## Consistent Styling\nAdd the company's style here.\n- Font\n- Font sizes, colors, and spacing\n- Footer & header\n- Table styles\nFor more details, see also:\n[Docs](https://docs.json2doc.com/docs/document-generation/overview#defaults-system)"
      },
      "typeVersion": 1
    },
    {
      "id": "69c6c80f-1c5f-46fd-a720-ede4586e8c50",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        -560
      ],
      "parameters": {
        "color": 4,
        "width": 544,
        "height": 880,
        "content": "## Generate Json2Doc Config\n\n**Warning**: The context generated by this step can become quite large depending on the size and complexity of the document.\n**Notes**:\n- This step uses the styling configuration passed from the previous node.\n- The output of this node is the **Job ID**, which will be required for the file download step.\n\n### **Authentication Setup**\nAn API Key header auth is required to use the MCP:\n\n1. **Get API Key:** \ud83d\udd17 [app.json2docs.com](https://app.json2docs.com)\n1. **Authentication:** Generic Credential Type  \n2. **Generic Auth Type:** Header Auth  \n3. **Create a new credential (or use the one create for MCP connection)** with:  \n   - **Header Name:** `x-api-key`  \n   - **Header Value:** *your API key*"
      },
      "typeVersion": 1
    },
    {
      "id": "c19905a5-9817-44ed-95c2-ccd54928ec46",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1376,
        -480
      ],
      "parameters": {
        "color": 6,
        "width": 704,
        "height": 688,
        "content": "# **Wait for Document & Download**\n\nThese nodes wait until the document associated with the returned **Job ID** is fully generated by the AI agent, and then download the final file.\n\n### **Authentication Setup (Same for MCP connection)**\nTo authenticate properly, configure the HTTP Request nodes as follows:\n\n1. **Authentication:** Generic Credential Type  \n2. **Generic Auth Type:** Header Auth  \n3. **Create a new credential (or use the one create for MCP connection)** with:  \n   - **Header Name:** `x-api-key`  \n   - **Header Value:** *your API key*"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c788a07d-3717-45c1-aa31-6bda61178036",
  "connections": {
    "HTTP Request": {
      "main": [
        [
          {
            "node": "is Completed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Json2Doc MCP": {
      "ai_tool": [
        [
          {
            "node": "Generate Sections",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "is Completed?": {
      "main": [
        [
          {
            "node": "Download Docx",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Document Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Sections": {
      "main": [
        [
          {
            "node": "Wait for Document Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Add Company styleguide",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Sections",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Add Company styleguide": {
      "main": [
        [
          {
            "node": "Generate Sections",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Generate Sections",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Document Generation": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "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

This n8n workflow automatically generates professionally formatted Word documents (DOCX) with consistent company branding using AI. It leverages Json2Doc and the Json2Doc MCP server to transform simple text prompts into complete, multi-page documents.

Source: https://n8n.io/workflows/11370/ — 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

The AI-Powered Shopify SEO Content Automation is an enterprise-grade workflow that transforms product content creation for e-commerce stores. This sophisticated multi-agent system integrates GPT-4o, C

Perplexity Tool, Memory Buffer Window, Agent +15
AI & RAG

Deep Research new (fr). Uses outputParserStructured, formTrigger, chainLlm, form. Event-driven trigger; 82 nodes.

Output Parser Structured, Form Trigger, Chain Llm +8
AI & RAG

My workflow 53. Uses formTrigger, httpRequest, lmChatOpenAi, form. Event-driven trigger; 74 nodes.

Form Trigger, HTTP Request, OpenAI Chat +15
AI & RAG

Episode 23: UGC with nanobanana. Uses lmChatOpenAi, lmChatOllama, lmChatDeepSeek, lmChatOpenRouter. Event-driven trigger; 74 nodes.

OpenAI Chat, Ollama Chat, Lm Chat Deep Seek +12
AI & RAG

This workflow is designed for marketers, founders, agencies, and product teams who want to understand how real customers talk about a product category, market, or problem space.

Reddit, Agent, Output Parser Structured +3