{
  "id": "c8i4Nyd5gZL5LOPx",
  "meta": {
    "builderVariant": "mcp",
    "aiBuilderAssisted": true
  },
  "name": "Turn a topic into a research-backed article with a multi-agent AI pipeline",
  "tags": [],
  "nodes": [
    {
      "id": "f0f62f74-e5a1-42fd-a8d3-7d9c27659b35",
      "name": "Article Brief Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        48,
        48
      ],
      "parameters": {
        "options": {
          "buttonLabel": "Write my article",
          "respondWithOptions": {
            "values": {
              "formSubmittedText": "Thanks! Your article is being researched and written and will arrive by email shortly."
            }
          }
        },
        "formTitle": "Topic to article",
        "formFields": {
          "values": [
            {
              "fieldType": "email",
              "fieldLabel": "Your email",
              "requiredField": true
            },
            {
              "fieldLabel": "Topic",
              "placeholder": "e.g. Benefits of intermittent fasting",
              "requiredField": true
            },
            {
              "fieldLabel": "Audience",
              "placeholder": "e.g. Busy beginners",
              "requiredField": true
            },
            {
              "fieldLabel": "Keyword",
              "placeholder": "e.g. intermittent fasting for beginners"
            }
          ]
        },
        "formDescription": "Give a topic and audience and get a research-backed, SEO-edited article by email."
      },
      "typeVersion": 2.6
    },
    {
      "id": "079e697c-d427-46ad-baaa-1884af787605",
      "name": "Research Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        240,
        48
      ],
      "parameters": {
        "text": "=Research the topic \"{{ $json.Topic }}\" for an audience of {{ $json.Audience }}. Use the Wikipedia tool to gather accurate facts. Produce concise research notes: 5-8 key points, any important numbers, and 2-3 common misconceptions to correct. Do not write the article yet - just the notes.",
        "options": {
          "systemMessage": "You are a diligent research assistant. Verify facts with Wikipedia before stating them."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "6bc9a69e-3fa2-4057-8b37-29cc73454950",
      "name": "Research Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        224,
        224
      ],
      "parameters": {
        "options": {
          "temperature": 0.2
        },
        "modelName": "models/gemini-3.1-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "c3d58078-8ba5-4520-96f8-ffe571b29eed",
      "name": "Wikipedia",
      "type": "@n8n/n8n-nodes-langchain.toolWikipedia",
      "position": [
        416,
        224
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "66ace249-be70-405b-9147-30c73abb57de",
      "name": "Write Draft with Gemini",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        576,
        48
      ],
      "parameters": {
        "text": "=You are a writer. Using ONLY the research notes below, write a friendly, well-structured article of about 500 words for an audience of {{ $('Article Brief Form').item.json.Audience }} on \"{{ $('Article Brief Form').item.json.Topic }}\". Use short paragraphs and a clear intro and conclusion. Do not invent facts beyond the notes.\n\nResearch notes:\n{{ $json.output }}",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "609fadc2-8b2c-48fd-9866-4df8a7386b5d",
      "name": "Writer Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        576,
        224
      ],
      "parameters": {
        "options": {
          "temperature": 0.7
        },
        "modelName": "models/gemini-3.1-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "c2425e2a-8df7-46ce-b514-e3310bfc9537",
      "name": "Edit and Optimise with Gemini",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        880,
        48
      ],
      "parameters": {
        "text": "=You are an SEO editor. Improve the draft below: tighten the writing, fix any awkward phrasing, and naturally work in the keyword \"{{ $('Article Brief Form').item.json.Keyword }}\" where it fits. Then output the finished article, a compelling 55-60 character SEO title on a line starting \"TITLE:\", and a 150-character meta description on a line starting \"META:\".\n\nDraft:\n{{ $json.text }}",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "ec48d034-4efc-4f96-9784-13c2c6efd230",
      "name": "Editor Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        880,
        224
      ],
      "parameters": {
        "options": {
          "temperature": 0.4
        },
        "modelName": "models/gemini-3.1-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "fc2a4e5f-e9d7-45bc-b7c9-76fde8336f6a",
      "name": "Split Article, Title and Meta",
      "type": "n8n-nodes-base.code",
      "position": [
        1232,
        48
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const out = String($json.text || '');\nconst t = out.match(/TITLE:\\s*(.*)$/im);\nconst m = out.match(/META:\\s*(.*)$/im);\nconst title = t ? t[1].trim() : '';\nconst meta = m ? m[1].trim() : '';\nconst body = out.replace(/TITLE:\\s*.*$/im, '').replace(/META:\\s*.*$/im, '').trim();\nconst f = $('Article Brief Form').item.json;\nreturn { email: f['Your email'], topic: f.Topic, title: title, meta: meta, article: body };"
      },
      "typeVersion": 2
    },
    {
      "id": "91d9085e-3de4-4c8e-ba72-9d7c19499cca",
      "name": "Log Article",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1456,
        48
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Articles"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Select your spreadsheet"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "f5bba6ea-a981-4cc9-80e3-d183fed50e0b",
      "name": "Email the Article",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1664,
        48
      ],
      "parameters": {
        "sendTo": "={{ $(\"Split Article, Title and Meta\").item.json.email }}",
        "message": "={{ \"TITLE: \" + $(\"Split Article, Title and Meta\").item.json.title + \"\\nMETA: \" + $(\"Split Article, Title and Meta\").item.json.meta + \"\\n\\n\" + $(\"Split Article, Title and Meta\").item.json.article }}",
        "options": {},
        "subject": "={{ \"Your article: \" + $(\"Split Article, Title and Meta\").item.json.title }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c5ab5e55-aa3b-42f2-a93d-38da3918610b",
      "name": "Overview Sticky",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        -160
      ],
      "parameters": {
        "width": 552,
        "height": 664,
        "content": "## Turn a topic into a research-backed article with a multi-agent AI pipeline\n\n### How it works\nInstead of one prompt doing everything, this template splits the job across three specialised AI steps, like a real editorial team. Submit a topic and audience in the built-in form. First an AI Agent researches the topic, using the Wikipedia tool to gather and verify facts, and produces structured notes. Then a Basic LLM Chain (the writer) turns only those notes into a friendly 500-word draft, so it cannot invent facts. Finally a second Basic LLM Chain (the SEO editor) tightens the draft, works in your keyword, and adds an SEO title and meta description. The finished piece is logged to Google Sheets and emailed to you.\n\n### Setup\n1. Connect Google Gemini (PaLM) API, Google Sheets and Gmail.\n2. Point the Log Article node at your spreadsheet (tab: Articles).\n3. Open the form URL and submit a topic.\n\n### Customization tips\nAdd a fact-check agent, or publish straight to WordPress or a Google Doc."
      },
      "typeVersion": 1
    },
    {
      "id": "a788c244-dd3a-4e54-8792-6951c990f95f",
      "name": "S1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 564,
        "height": 652,
        "content": "## 1. Research Agent\nAn AI Agent gathers and verifies facts with the Wikipedia tool and writes structured notes."
      },
      "typeVersion": 1
    },
    {
      "id": "16a64a47-c0d6-45cf-b385-829ec9833008",
      "name": "S2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 616,
        "height": 652,
        "content": "## 2. Writer & SEO editor (Basic LLM Chains)\nOne chain writes the draft from the notes only; a second chain edits it and adds an SEO title and meta."
      },
      "typeVersion": 1
    },
    {
      "id": "c5fe3ba5-8f73-4f32-92a1-135e1a0279f7",
      "name": "S3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 660,
        "height": 652,
        "content": "## 3. Log & deliver\nSplit out the title and meta, log the article to Sheets and email the finished piece."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": true,
    "executionOrder": "v1"
  },
  "versionId": "59fa85a1-f322-40f1-b64e-8b3b31ef249a",
  "nodeGroups": [],
  "connections": {
    "Wikipedia": {
      "ai_tool": [
        [
          {
            "node": "Research Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Log Article": {
      "main": [
        [
          {
            "node": "Email the Article",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Editor Model": {
      "ai_languageModel": [
        [
          {
            "node": "Edit and Optimise with Gemini",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Writer Model": {
      "ai_languageModel": [
        [
          {
            "node": "Write Draft with Gemini",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Research Agent": {
      "main": [
        [
          {
            "node": "Write Draft with Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Research Model": {
      "ai_languageModel": [
        [
          {
            "node": "Research Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Article Brief Form": {
      "main": [
        [
          {
            "node": "Research Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Draft with Gemini": {
      "main": [
        [
          {
            "node": "Edit and Optimise with Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit and Optimise with Gemini": {
      "main": [
        [
          {
            "node": "Split Article, Title and Meta",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Article, Title and Meta": {
      "main": [
        [
          {
            "node": "Log Article",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}