AutomationFlowsAI & RAG › Create & Publish SEO Content with AI Agents & Google Sheets Tracking

Create & Publish SEO Content with AI Agents & Google Sheets Tracking

ByRahul Joshi @rahul08 on n8n.io

Enhance your support, onboarding, and internal knowledge workflows with an intelligent RAG-powered chatbot that responds using live data stored in Google Sheets. 🤖📚 Built for teams that rely on structured datasets, this workflow fetches sheet content, enriches it with AI…

Webhook trigger★★★★★ complexityAI-powered72 nodesChat TriggerOutput Parser StructuredMemory Buffer WindowAgentGoogle Sheets ToolGmailSlackOpenAI Chat
AI & RAG Trigger: Webhook Nodes: 72 Complexity: ★★★★★ AI nodes: yes Added:
Create & Publish SEO Content with AI Agents & Google Sheets Tracking — n8n workflow card showing Chat Trigger, Output Parser Structured, Memory Buffer Window integration

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

This workflow follows the Agent → Chat 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": "YPOg9vBGLvnpWjEF",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Orchestrate End-to-End Content Generation from AI Agents and Google Sheets",
  "tags": [],
  "nodes": [
    {
      "id": "a9cb927f-bba0-4184-9c15-7300a1b89d22",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1088,
        352
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "={{ $json.output.reply }}"
      },
      "typeVersion": 1
    },
    {
      "id": "cd60eafe-5b5a-4db7-99c9-afed0b86b60a",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -2096,
        160
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "6f0b8858-c46c-4a48-8c80-5b7609d71e7c",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -1232,
        384
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"intent\": \"draft\",\n  \"topic\": \"AI SEO basics\",\n  \"content_id\": \"C001\", \n   \"content_id\": \"CNT-1701255487715\",\n  \"parameters\": {}\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "86004697-8e92-49a1-9b29-72e567b966d5",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -1744,
        384
      ],
      "parameters": {
        "contextWindowLength": 7
      },
      "typeVersion": 1.3
    },
    {
      "id": "47918823-77b6-43b5-ab79-8a5711a4b96a",
      "name": "AI Agent Orchestration",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1616,
        160
      ],
      "parameters": {
        "text": "=User message: {{ $json.chatInput }}\nSession ID: {{ $json.sessionId }}",
        "options": {
          "systemMessage": "=You are \"Content Agent\", a senior content strategist AI inside an n8n system.\nYou analyze brand data, SERP context, and past content stored in Google Sheets to decide next action.\n\nAvailable data sources (tools):\n- content_items \u2192 existing topics, brands, and statuses\n- content_versions \u2192 previous drafts and SEO metadata\n- conversation_logs \u2192 previous discussions with users\n\nReturn a structured JSON ONLY in this format:\n{\n  \"intent\": \"chat|brief|draft|optimize|publish|monitor\",\n  \"topic\": \"string\",\n  \"content_id\": \"string (if applicable)\", \n  \"brief_id\": \"string (if applicable)\",\n  \"parameters\": {}\n}\n\nRules:\n- Never include extra commentary, explanations, or notes.\n- Return only valid JSON \u2014 no prefixes like \"Agent stop\" or \"AI Response\".\n- If unsure, return {}.\n\n\nRules:\n- Never include extra commentary.\n- Use Google Sheets data via your tools to confirm IDs or topics.\n- Retrieve context from memory if user refers to previous topic.\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "retryOnFail": true,
      "typeVersion": 2.1
    },
    {
      "id": "35716cbf-d43a-4e91-b3ce-586f183538f4",
      "name": "format data for subworkflows",
      "type": "n8n-nodes-base.set",
      "position": [
        -1024,
        160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "00041789-ea3a-444f-ae5a-eceab991ac54",
              "name": "intent",
              "type": "string",
              "value": "={{ $json.output.intent }}"
            },
            {
              "id": "658dd016-518e-47a1-9112-892624542f1f",
              "name": "topic",
              "type": "string",
              "value": "={{ $json.output.topic }}"
            },
            {
              "id": "0003a733-0846-45c6-bb07-2ccf34a83b23",
              "name": "content_id",
              "type": "string",
              "value": "={{ $json.output.content_id }}"
            },
            {
              "id": "70298262-66ed-4ded-b51f-b4bc9814ce83",
              "name": "parameter",
              "type": "object",
              "value": "={{ $json.output.parameters }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5b5a24f9-2170-4b9b-83dc-faddf52dac0b",
      "name": "Intent Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        -800,
        96
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b49a1e84-3190-463a-8cf7-1b1f390eac2f",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "chat"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "f714bb5d-6b66-4b0a-8eb3-a50d4b199917",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "brief"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "accc92fd-e8aa-4eb5-8143-7b02e2bb1d24",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "draft"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "83501282-95dc-4db2-98d2-6973c6a69fc2",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "optimize"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "1f37d1bf-2f09-4735-a99a-7f5d3f078cc5",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "publish"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "4a26e884-e1b8-4c3e-b181-efb9503a28db",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.intent }}",
                    "rightValue": "monitor"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.3
    },
    {
      "id": "c4476109-f8fe-450d-b116-9ebf4fe47824",
      "name": "AI Agent Chat",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        656,
        352
      ],
      "parameters": {
        "text": "={{ JSON.stringify($json, null, 2) }}\n\nThe above JSON is structured output from internal AI workflows (brief, draft, optimize, publish, or monitor).\n\nConvert this structured data into a single, natural chat message that explains the result to the user in a friendly, human tone.  \nUse emojis and short, clear sentences. Avoid showing technical keys.\n\nReturn only valid JSON in this format:\n{\n  \"reply\": \"your chat-style message here\"\n}",
        "options": {
          "systemMessage": "=You are \"Response Writer\", a conversational AI inside the n8n content automation system.\n\nYour role is to convert structured workflow outputs into clear, human-like chat messages.\n\nYou receive a JSON input that may contain outputs from different AI subflows:\n- brief \u2192 when a new content plan or outline is created.\n- draft \u2192 when a complete article draft is generated.\n- optimize \u2192 when an article has been enhanced for clarity or SEO.\n- publish \u2192 when content is marked as published.\n- monitor \u2192 when analytics performance is reported.\n\nYour job:\n1. Understand what kind of workflow result this is.\n2. Write a friendly, short, and natural summary message.\n3. Include key insights (title, topic, performance, recommendations, etc.)\n4. Use a warm, helpful, and human tone.\n5. Never expose JSON keys, code, or raw data.\n\nStyle guidelines:\n- Use emojis and Markdown sparingly for readability.\n- Keep sentences conversational and easy to read.\n- For metrics (monitor intent), mention numbers naturally (e.g., \u201c1.2k views with 11.8% CTR\u201d).\n- For drafts or briefs, show enthusiasm and clarity.\n- If no recognizable data exists, say: \u201cI processed your request successfully \u2014 nothing special to report yet.\u201d\n\nAlways output plain text only, never JSON.\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "retryOnFail": true,
      "typeVersion": 2.1
    },
    {
      "id": "9b1b17d9-623f-4e1d-b9c1-fd80170e3610",
      "name": "AI Agent (Chat Composer)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -176,
        -752
      ],
      "parameters": {
        "text": "=User message: {{ $json.content }}\nIntent: {{ $json.intent }}\nTopic: {{ $json.topic || \"general\" }}\nContext (from Google Sheets or memory): {{ $json.context || $memory || \"No context retrieved\" }}\n",
        "options": {
          "systemMessage": "=You are \"Content Agent Chat Responder\", a professional AI assistant inside an n8n automation system.\n\nYour role:\n- Communicate naturally, professionally, and concisely.\n- Use provided context from Google Sheets or memory when available.\n- If the user greets you (like \"hi\", \"hello\", \"hey\"), respond politely and ask how you can help.\n- If the user asks about SEO, content drafts, briefs, optimization, or publishing, respond specifically based on context or ask clarifying questions if missing.\n- If the intent is \"chat\" but the content clearly mentions a topic, treat it as a mixed chat + content query.\n- If context is missing, ask the user for more information.\n- Always output concise structured JSON in the format:\n{\n  \"reply\": \"Your full response text\",\n  \"context_used\": [\"list of any context used or none\"]\n}\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "81165eca-d0d0-4e17-8901-33d04e8fe69f",
      "name": "AI Agent (Brief Writer)1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -176,
        -352
      ],
      "parameters": {
        "text": "=Topic: {{ $json.topic }}\nIntent: {{ $json.intent }}\nUser request: {{ $json.content }}\nContext (from Sheets or memory): {{ $json.context || $memory || 'No context found' }}",
        "options": {
          "systemMessage": "=You are \"Brief Writer Agent\", a professional AI content strategist inside an n8n automation system built by Vivek Patidar.\n\nYour role:\n- Create structured SEO content briefs for a given topic or keyword.\n- You have access to Google Sheets (\"content_versions\") that contains previous briefs and their versions.\n- Always check the sheet before writing. If a topic already exists:\n  - Reuse its `content_id`\n  - Increment the `version_no` (e.g., from 2 \u2192 3)\n  - Generate a new `version_id` as \"VER-00X\"\n- If the topic is new:\n - If the topic is new, create a new content_id using the pattern \"CNT-<unix_milliseconds>\" (for example: CNT-1700000000000). Use version_no = 1 and version_id = \"VER-001\".\n  - Start from `version_no = 1` and `version_id = VER-001`\n\nAfter reasoning and generating, return structured JSON in this exact format:\n{\n  \"brief\": {\n    \"title\": \"string\",\n    \"meta_description\": \"string\",\n    \"target_keywords\": [\"string\"],\n    \"outline\": [\"string\"],\n    \"word_count\": \"number\",\n    \"tone\": \"string\",\n    \"cta_ideas\": [\"string\"]\n  },\n  \"metadata\": {\n    \"content_id\": \"string\",\n    \"version_no\": \"number\",\n    \"version_id\": \"string\",\n    \"is_new_topic\": \"boolean\"\n  },\n  \"context_used\": [\"list of context data or none\"]\n}\n\nRules:\n- Use the Google Sheets tool to check if the topic exists.\n- Always reason step-by-step before producing output.\n- Use structured JSON only \u2014 no explanations or markdown.\n- Be concise, SEO-optimized, and context-aware.\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "2ef396a6-a295-4241-a607-826b8128b7d8",
      "name": "AI Agent (Draft Writer)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -176,
        48
      ],
      "parameters": {
        "text": "=Topic: {{ $json.topic }}\nIntent: {{ $json.intent }}\nUser request: {{ $json.content }}\nContext (from Sheets or memory): {{ $json.context || $memory || 'No context found' }}\n\nUsing the content brief, generate a complete draft article following the outline and tone guidelines.",
        "options": {
          "systemMessage": "=You are \"Draft Writer Agent\", a professional AI content creator inside n8n automation system.\n\nYour goal:\n- Expand an SEO content brief into a complete, well-structured draft.\n- Use the outline, tone, and keyword data from the brief.\n- Write clear, natural, and engaging copy with headings for each outline section.\n- Maintain SEO best practices (keyword placement, clarity, readability).\n- Always produce section-based content \u2014 not bullet lists or raw text.\n\nVersioning Rules:\n- Fetch the brief from Google Sheets (\"content_versions\").\n- If the brief already exists, reuse its `content_id` and increment `version_no` (e.g., 2 \u2192 3).\n- Create `version_id` as \u201cVER-00X\u201d.\n- If no brief found, create a new content_id like \u201cCNT-<timestamp>\u201d.\n\nOutput Rules:\nReturn structured JSON only, in this format:\n{\n  \"draft\": {\n    \"title\": \"string\",\n    \"meta_description\": \"string\",\n    \"sections\": [ { \"heading\": \"string\", \"content\": \"string\" } ],\n    \"word_count\": \"number\",\n    \"keywords_used\": [\"string\"],\n    \"tone\": \"string\"\n  },\n  \"metadata\": {\n    \"content_id\": \"string\",\n    \"version_no\": \"number\",\n    \"version_id\": \"string\",\n    \"timestamp\": \"number\"\n  },\n  \"context_used\": [\"list of any brief context or none\"]\n}\n\nRules:\n- Never return markdown or plain text, only structured JSON.\n- Always log metadata and context.\n- Be consistent with the tone and structure defined in the brief.\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "d74755da-575e-4e07-8e62-4b6f984fb6c6",
      "name": "AI Agent Optimizer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -176,
        448
      ],
      "parameters": {
        "text": "=Topic: {{ $json.topic }}\nIntent: {{ $json.intent }}\nContent ID: {{ $json.content }}\nOptimization Goal: {{ $json.parameter.goal || 'Improve SEO, tone, and readability' }}\nFocus Keywords: {{ $json.parameter.focus_keywords ? $json.parameter.focus_keywords.join(', ') : 'N/A' }}\n\nContext (from Sheets or memory): {{ $json.context || $memory || 'No context found' }}\n\nUsing the content retrieved from Sheets, optimize the article to follow the tone and outline guidelines. \nEnsure it aligns with the optimization goal while maintaining factual accuracy and original intent.\nReturn the optimized article in structured JSON format.\n",
        "options": {
          "systemMessage": "=You are \"Optimization Agent\", a senior content optimizer AI inside an n8n automation system built by Vivek Patidar.\n\nYour job:\nImprove the provided draft WITHOUT rewriting it from scratch by using:\n1. The existing draft text from the workflow input\n2. Historical versions from Google Sheets (\"content_versions\")\n3. SERP intelligence from SerpAPI (competitors, headings, snippets, PAA, related searches)\n4. Brief or metadata passed from the previous stage\n\nYou must produce a refined, SEO-optimized, well-structured and factually consistent version of the draft.\n\n--------------------------------\n\ud83d\udd0e HOW TO USE SERP DATA\n--------------------------------\nYou receive SERP data via upstream tools (SerpAPI). Use it to:\n\n- Identify missing topical sections compared to competitors.\n- Enhance keyword coverage and semantic depth.\n- Improve H2/H3 section clarity and completeness.\n- Strengthen meta description using competitor insight.\n- Suggest improvements based on PAA questions (People Also Ask).\n- Add missing angles/topics found across rankings.\n- Improve EEAT signals (expertise, trustworthiness) when relevant.\n- DO NOT output any raw SERP JSON.\n\nSERP data should influence optimization decisions, but never override the original meaning of the draft.\n\n--------------------------------\n\ud83d\udcdd OPTIMIZATION RULES\n--------------------------------\n1. **Never rewrite from scratch.** Always keep the core meaning and structure.\n2. **Preserve tone** from the original draft or brief.\n3. **Preserve factual accuracy** \u2014 no hallucinations.\n4. **Only improve**, refine, reorganize, expand, clarify, or SEO-enhance.\n5. **Use keywords naturally**, avoid keyword stuffing.\n6. **If brief or previous versions exist**, align with them.\n7. **If SERP data suggests missed content**, incorporate it softly into relevant sections.\n8. **If the draft is messy**, reorganize into sections while preserving original paragraphs as much as possible.\n9. **Never expose intermediate reasoning** or tool data.\n\n--------------------------------\n\ud83e\uddfe VERSIONING LOGIC\n--------------------------------\nUse Google Sheets context to determine versioning:\n\n- If content_id already exists:\n  - Increment version_no (ex: 2 \u2192 3)\n  - Create new version_id as \"VER-00X\"_\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "f52b4453-0f14-46db-a3f7-60a2c91b9db6",
      "name": "Fetch Optimized Draft from Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -32,
        1072
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2120745354,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit#gid=2120745354",
          "cachedResultName": "content_versions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit?usp=drivesdk",
          "cachedResultName": "SEO Content Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "c2a108d2-d6fb-4343-83c0-b260d7c50b7a",
      "name": "AI Agent (Publisher)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -160,
        848
      ],
      "parameters": {
        "text": "=Topic: {{ $json.topic }}\nIntent: {{ $json.intent }}\nContent ID: {{ $json.content_id }}\nPlatform: {{ $json.parameter.platform || 'Internal CMS' }}\n\nContext (from Sheets or memory): {{ $json.context || $memory || 'No context found' }}\n\nPrepare the article for publishing. Ensure metadata, title, tags, and description are optimized. If the platform is WordPress, format the article in valid HTML. Return only structured JSON in the required format.",
        "options": {
          "systemMessage": "=You are \"Publisher Agent\", an AI responsible for preparing and posting optimized articles.\n\nYour tasks:\n1. Take the optimized draft and prepare it for publishing.\n2. Clean and format for web standards (HTML-ready headings, tags, meta info).\n3. Generate metadata, tags, and keywords.\n4. Always return structured JSON only, in this format:\n{\n  \"publish_data\": {\n    \"content_id\": \"string\",\n    \"version_id\": \"string\",\n    \"title\": \"string\",\n    \"meta_description\": \"string\",\n    \"tags\": [\"string\"],\n    \"html_body\": \"string\",\n    \"status\": \"Published\",\n    \"timestamp\": \"number\"\n  }\n}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "2d24b258-97ba-4b10-bc6c-583a376ce1ff",
      "name": "Prepare Publishing Metadata",
      "type": "n8n-nodes-base.set",
      "position": [
        -576,
        960
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d917c6d3-ae35-4140-99c8-ae390866e735",
              "name": "intent",
              "type": "string",
              "value": "=publish"
            },
            {
              "id": "e697ec89-26ed-4fb3-95a9-4a0cc6eed36d",
              "name": "topic",
              "type": "string",
              "value": "=AI Seo Basics"
            },
            {
              "id": "f5a88ad2-7f57-4971-88ea-bad9e1c10992",
              "name": "content_id",
              "type": "string",
              "value": "=C001"
            },
            {
              "id": "06fb1d17-f233-4b22-af27-cd3351c971a0",
              "name": "parameter",
              "type": "object",
              "value": "={{ $json.parameter }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5a6d72a0-2abb-4214-84df-055e4abd483f",
      "name": "Send Content for Approval",
      "type": "n8n-nodes-base.gmail",
      "position": [
        368,
        1056
      ],
      "parameters": {
        "message": "={{ $json.output.publish_data.html_body }}",
        "options": {},
        "subject": "={{ $json.output.publish_data.title }}",
        "operation": "sendAndWait"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "610f679e-fa32-4ea3-9115-dad85ea083f5",
      "name": "Check Approval Status",
      "type": "n8n-nodes-base.if",
      "position": [
        720,
        1152
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3c7c4382-eb2a-4fc8-9239-b0b6e212cd9c",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.approved }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c02c3a76-d8b4-4065-b0d8-6b19bf839579",
      "name": "Publish to Recipient",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1056,
        1152
      ],
      "parameters": {
        "message": "={{ $('AI Agent (Publisher)').item.json.output.publish_data.html_body }}",
        "options": {},
        "subject": "={{ $('AI Agent (Publisher)').item.json.output.publish_data.title }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "15d2b067-9256-46e1-b39a-98735bb53f99",
      "name": "Send Success Notification to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        1056,
        1344
      ],
      "parameters": {
        "text": "=Your  {{ $('AI Agent (Publisher)').item.json.output.publish_data.title }} has been Successfully Published.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09GNB90TED",
          "cachedResultName": "general-information"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "920ee625-c44b-4e32-a9f2-b092e302a5cf",
      "name": "Fetch Published Version from Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -96,
        1584
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2120745354,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit#gid=2120745354",
          "cachedResultName": "content_versions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit?usp=drivesdk",
          "cachedResultName": "SEO Content Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "5ec805cd-960b-4b6c-aeb5-63c88d3592c0",
      "name": "Fetch Performance Metrics",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        32,
        1584
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1296767916,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit#gid=1296767916",
          "cachedResultName": "Performance_metrics"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit?usp=drivesdk",
          "cachedResultName": "SEO Content Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "9da47d6d-9767-4612-9e0c-55f11673a327",
      "name": "AI Agent (Monitor)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -176,
        1360
      ],
      "parameters": {
        "text": "==Topic: {{ $json.topic }}\nIntent: {{ $json.intent }}\nContent ID: {{ $json.content_id }}\nPeriod: {{ $json.parameter.metric_period || 'last 7 days' }}\nVersion: {{ $json.parameter.compare_to_version || 'latest' }}\n\nPublished Content Data (from Sheets):\n{{ $json.context || 'No version data found' }}\n\nPerformance Metrics (from Performance_metrics sheet):\n{{ $json.metrics || 'No analytics available' }}\n\nAnalyze how this content performed during the specified period.\nUse both the content_versions and Performance_metrics data to:\n- Compare the latest version with the previous one if data exists.\n- Identify changes in views, clicks, CTR, position, engagement score.\n- Highlight key trends, improvements, or declines.\n- Provide 2\u20133 actionable recommendations for next optimization.\n\nReturn only structured JSON following the provided schema.\n",
        "options": {
          "systemMessage": "=You are \"Monitor Agent\", an analytical AI inside an n8n workflow.\n\nYou analyze published content performance using Google Sheets data.\nYou access two data sources (tools) that are already connected to you:\n- content_versions \u2192 stores published version metadata (titles, timestamps, tone)\n- Performance_metrics \u2192 stores analytics (views, clicks, CTR, engagement, position)\n\nYour job:\n1. Read and compare metrics (views, CTR, position, engagement_score) from the connected Performance_metrics sheet.\n2. Match them with the corresponding version in content_versions.\n3. Detect performance trends, summarize findings, and provide actionable recommendations.\n4. Use available sheet data and fallback gracefully if no data is found.\n\nAlways return structured JSON only:\n{\n  \"performance_summary\": {\n    \"content_id\": \"string\",\n    \"version_id\": \"string\",\n    \"views\": \"number\",\n    \"clicks\": \"number\",\n    \"ctr\": \"number\",\n    \"avg_position\": \"number\",\n    \"engagement_score\": \"number\",\n    \"change_vs_previous\": {\n      \"views\": \"number\",\n      \"ctr\": \"number\",\n      \"position\": \"number\"\n    },\n    \"summary\": \"string\",\n    \"recommendations\": [\"string\"]\n  },\n  \"timestamp\": \"number\"\n}\n\nRules:\n- Do not include natural language outside the JSON.\n- If no performance data is found, return zeros but still provide helpful recommendations.\n- When comparing versions, calculate % changes and direction (\u2191/\u2193).\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "9ffcc0b5-e85b-472e-be98-22ddd3e5bae4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2384,
        -576
      ],
      "parameters": {
        "width": 576,
        "height": 496,
        "content": "## \ud83e\udde9 Content Generation End-to-End Automation\nHow it works\n\nThis workflow turns a simple chat-style user message into a complete content production pipeline. It detects what the user wants\u2014chat, brief, draft, optimization, publishing, or analytics\u2014and routes the request to the correct AI sub-agent. The system reads and writes to Google Sheets to track version history, previous conversations, content briefs, drafts, and optimized outputs. Each result is converted back into a clean, natural chat-style response.\n\nSetup steps\n\nConnect OpenAI and Google Sheets credentials.\n\nAdd your spreadsheet with the required tabs: content_items, content_versions, and conversation_logs.\n\nReview node positions to ensure left-to-right flow.\n\nTest with a simple message like \u201cCreate a brief for AI SEO\u201d.\n\nConfirm versioning updates appear correctly in the Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "f96b5208-f945-487a-b923-02a2fce35f45",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2384,
        -48
      ],
      "parameters": {
        "color": 2,
        "width": 752,
        "height": 592,
        "content": "## Chat Trigger & Memory\nHandles incoming chat messages and maintains short-term context using memory windows. Ensures the workflow understands follow-up questions and ongoing topics."
      },
      "typeVersion": 1
    },
    {
      "id": "aada981b-340d-4679-a1f1-ee072c22757e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        -128
      ],
      "parameters": {
        "color": 2,
        "width": 416,
        "height": 672,
        "content": "## Intent Detection & Routing\nThe central agent reads the user\u2019s message, checks sheet context, and decides whether the next step is chat, brief building, drafting, optimization, publishing, or analytics. The Switch node routes the workflow to the correct sub-pipeline."
      },
      "typeVersion": 1
    },
    {
      "id": "bc0275be-9e87-41aa-b112-1f5db1bbe797",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1616,
        -96
      ],
      "parameters": {
        "color": 2,
        "width": 528,
        "height": 672,
        "content": "## Content & Version Lookup\nRetrieves topic history, previous drafts, briefs, and conversation logs. This ensures content versioning works reliably and the AI stays consistent with past work."
      },
      "typeVersion": 1
    },
    {
      "id": "8c0bab32-5594-48a7-a6ad-7aa616086b6b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        -880
      ],
      "parameters": {
        "color": 2,
        "width": 880,
        "height": 880,
        "content": "## SEO Brief Generation\nCreates clean, structured SEO content briefs with metadata, keywords, outline, tone, and CTA ideas. Automatically creates or updates content_id and version numbers."
      },
      "typeVersion": 1
    },
    {
      "id": "0a3bc845-3edc-4ef2-ba9e-a45c1cb01a48",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        32
      ],
      "parameters": {
        "color": 2,
        "width": 864,
        "height": 384,
        "content": "## Draft Writer Pipeline\nExpands the SEO brief into a structured article with sections, headings, and tone consistency. Saves each draft version into the Google Sheet with metadata tracking."
      },
      "typeVersion": 1
    },
    {
      "id": "06f77083-0ed5-41f3-8397-ca7a28fe0ddd",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        432
      ],
      "parameters": {
        "color": 2,
        "width": 912,
        "height": 1376,
        "content": "## AI Content Optimizer\nImproves existing drafts using brief context, previous versions, and SERP insights. Enhances clarity, SEO strength, and structure without rewriting from scratch."
      },
      "typeVersion": 1
    },
    {
      "id": "4a633772-50d1-49a7-b8d3-3634a138d84f",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        224
      ],
      "parameters": {
        "color": 2,
        "width": 800,
        "height": 496,
        "content": "## Human-Style Output Builder\nConverts structured agent outputs into clean, natural chat messages. Ensures users always receive friendly summaries rather than JSON."
      },
      "typeVersion": 1
    },
    {
      "id": "ab158ef4-eb79-4ac3-b894-064df4acce09",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -848
      ],
      "parameters": {
        "color": 2,
        "width": 208,
        "height": 2416,
        "content": "## Conversation Logging\nStores every interaction \u2014 message, intent, response, and session ID \u2014 ensuring traceability and future context retrieval."
      },
      "typeVersion": 1
    },
    {
      "id": "5e2800bf-d00c-48b3-8f9d-c496bfb62373",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        1456
      ],
      "parameters": {
        "color": 3,
        "width": 304,
        "height": 288,
        "content": "## \ud83d\udd10 Credentials & Security\n\nUse OAuth2 for Google Sheets and API key credentials for OpenAI. Do not hardcode keys or sheet IDs when publishing templates. Replace all sensitive data with placeholders before sharing."
      },
      "typeVersion": 1
    },
    {
      "id": "b3f0eb4d-4102-4126-bfd9-fd332cc0a734",
      "name": "Content Classifier Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1872,
        384
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "23c8f048-d579-411a-9045-20b4d295c46c",
      "name": "Analytics Summary Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -320,
        272
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a53cf527-d828-43cd-91ab-b05725a9468b",
      "name": "Format Intent Payload",
      "type": "n8n-nodes-base.set",
      "position": [
        -576,
        -656
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8ea18d06-f3cb-4988-9015-d1baec5f74c1",
              "name": "intent",
              "type": "string",
              "value": "={{ $json.intent }}"
            },
            {
              "id": "f091b1a0-2d42-4ade-b25d-9d562cad239f",
              "name": "topic",
              "type": "string",
              "value": "={{ $json.topic }}"
            },
            {
              "id": "4ce9bf82-c89e-44e8-aca6-4720fdf6dcf7",
              "name": "content",
              "type": "string",
              "value": "={{ $json.content }}"
            },
            {
              "id": "cef206d3-24f5-46c4-bab4-bbe246ef655e",
              "name": "parameter",
              "type": "string",
              "value": "={{ $json.parameter }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "556cc1d9-dbc6-4849-8670-4209a5d0660b",
      "name": "Format Intent Payload Brief",
      "type": "n8n-nodes-base.set",
      "position": [
        -576,
        -240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8ea18d06-f3cb-4988-9015-d1baec5f74c1",
              "name": "intent",
              "type": "string",
              "value": "={{ $json.intent }}"
            },
            {
              "id": "f091b1a0-2d42-4ade-b25d-9d562cad239f",
              "name": "topic",
              "type": "string",
              "value": "={{ $json.topic }}"
            },
            {
              "id": "4ce9bf82-c89e-44e8-aca6-4720fdf6dcf7",
              "name": "content",
              "type": "string",
              "value": "={{ $json.content }}"
            },
            {
              "id": "cef206d3-24f5-46c4-bab4-bbe246ef655e",
              "name": "parameter",
              "type": "string",
              "value": "={{ $json.parameter }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "41e5b02c-c378-4fd7-bb23-b45e624c9f6b",
      "name": "Format Intent Payload Draft",
      "type": "n8n-nodes-base.set",
      "position": [
        -576,
        160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "intent",
              "type": "string",
              "value": "={{ $json.intent }}"
            },
            {
              "name": "topic",
              "type": "string",
              "value": "={{ $json.topic }}"
            },
            {
              "name": "content",
              "type": "string",
              "value": "={{ $json.content }}"
            },
            {
              "name": "brief_id",
              "type": "string",
              "value": "={{ $json.brief_id }}"
            },
            {
              "name": "parameter",
              "type": "object",
              "value": "={{ $json.parameter }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8609ad6f-8c18-4579-9232-52b0f73cbd49",
      "name": "Format Payload Data Optimizer",
      "type": "n8n-nodes-base.set",
      "position": [
        -576,
        560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "06b7c645-7355-413c-8dfe-29b3109eaffb",
              "name": "intent",
              "type": "string",
              "value": "=optimize"
            },
            {
              "id": "ac8d353d-63bb-4e4a-bc9d-03db4a75059c",
              "name": "topic",
              "type": "string",
              "value": "=AI SEO basics"
            },
            {
              "id": "495c9583-b542-47c5-a9ed-d03df149dfc9",
              "name": "content",
              "type": "string",
              "value": "=C001"
            },
            {
              "id": "69e216f5-01f7-417f-9212-9b3fe2d42489",
              "name": "parameter",
              "type": "object",
              "value": "={}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c021418c-1bfb-42ad-a46d-be73f71669e2",
      "name": "Prepare MetaData Monitor",
      "type": "n8n-nodes-base.set",
      "position": [
        -576,
        1360
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "intent",
              "type": "string",
              "value": "={{ $json.intent }}"
            },
            {
              "name": "topic",
              "type": "string",
              "value": "={{ $json.topic }}"
            },
            {
              "name": "content_id",
              "type": "string",
              "value": "={{ $json.content }}"
            },
            {
              "name": "parameter",
              "type": "object",
              "value": "={{ $json.parameter }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ec43778c-d3ea-4ce9-95ae-053df12b55d3",
      "name": "OpenAI Chat Model Monitor",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -352,
        1584
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7dbd40fb-58e7-4dfa-9797-0e54e8ac94c7",
      "name": "Short-Term Memory Monitor",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -224,
        1584
      ],
      "parameters": {
        "sessionKey": "monitor-session",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "ac099223-879f-4672-8e8d-74fcea2a2edc",
      "name": "Output Parser (JSON Enforcement) Monitor",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        160,
        1584
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"performance_summary\": {\n    \"content_id\": \"CNT-1701255487715\",\n    \"version_id\": \"VER-004\",\n    \"views\": 1520,\n    \"clicks\": 186,\n    \"ctr\": 12.2,\n    \"avg_position\": 4.3,\n    \"engagement_score\": 8.9,\n    \"change_vs_previous\": { \"views\": 15, \"ctr\": 2.3, \"position\": -0.5 },\n    \"summary\": \"CTR and engagement improved vs previous version.\",\n    \"recommendations\": [\"Add FAQ section\", \"Update meta description\"]\n  },\n  \"timestamp\": 1701270000000\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "1708af84-1b40-4819-869e-bfc6c3b91600",
      "name": "OpenAI Chat Model Publisher",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -288,
        1072
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6688f94f-7ba9-4c4b-b694-bc48846b9352",
      "name": "Short-Term Memory Publisher",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -160,
        1072
      ],
      "parameters": {
        "sessionKey": "publish-session",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "f94ae031-ad52-4928-82bb-66c3dea9db79",
      "name": "Output Parser (JSON Enforcement) Publisher",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        96,
        1072
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"publish_data\": {\n    \"content_id\": \"CNT-1701255487715\",\n    \"version_id\": \"VER-004\",\n    \"title\": \"AI SEO Basics: How AI Is Transforming Content Ranking\",\n    \"meta_description\": \"Learn how AI SEO tools are transforming keyword optimization and content performance.\",\n    \"tags\": [\"AI\", \"SEO\", \"Content Marketing\"],\n    \"html_body\": \"<h1>AI SEO Basics</h1><p>AI is reshaping SEO...</p>\",\n    \"status\": \"Published\",\n    \"timestamp\": 1701265000000\n  }\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "7a4e8e9f-917a-40da-a1f7-908e0397ef4f",
      "name": "OpenAI Chat Model Optmizer",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -288,
        672
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f818f59b-2488-41ec-918a-418265fd90fd",
      "name": "Short-Term Memory Optmizer",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -160,
        672
      ],
      "parameters": {
        "sessionKey": "optimize-writer-session",
        "sessionIdType": "customKey",
        "contextWindowLength": 7
      },
      "typeVersion": 1.3
    },
    {
      "id": "e78aa4ac-58d6-438a-ad6f-837f766e6c9e",
      "name": "Get Context from Google Sheets Optmizer",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -32,
        672
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2120745354,
          "cachedResultName": "content_versions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84",
          "cachedResultName": "SEO Content Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "a19121b2-09df-4357-9aa5-b2fe0cd4de16",
      "name": "Output Parser (JSON Enforcement) Optmizer",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        96,
        672
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"optimized_draft\": {\n    \"title\": \"AI SEO Basics: How Artificial Intelligence Transforms Search Optimization\",\n    \"meta_description\": \"Discover how AI improves SEO strategies by automating keyword insights, readability, and tone optimization.\",\n    \"sections\": [\n      {\n        \"heading\": \"Introduction\",\n        \"content\": \"AI is reshaping SEO by automating keyword research and enhancing content tone to match user intent.\"\n      },\n      {\n        \"heading\": \"Benefits of AI in SEO\",\n        \"content\": \"AI tools can analyze trends, optimize tone, and generate SEO-friendly drafts faster than manual editing.\"\n      }\n    ],\n    \"word_count\": 1150,\n    \"keywords_used\": [\"AI SEO\", \"content optimization\", \"search ranking\"],\n    \"improvements\": [\"Enhanced meta description\", \"Improved readability\", \"Better keyword placement\"]\n  },\n  \"metadata\": {\n    \"content_id\": \"CNT-1701255487715\",\n    \"version_no\": 4,\n    \"version_id\": \"VER-004\",\n    \"timestamp\": 1701259999999\n  }\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "192829dc-6123-48d8-8d02-5d27221d797d",
      "name": "Short-Term Memory Draft",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -160,
        272
      ],
      "parameters": {
        "sessionKey": "draft-writer-session",
        "sessionIdType": "customKey",
        "contextWindowLength": 7
      },
      "typeVersion": 1.3
    },
    {
      "id": "59c7f529-b004-451f-a131-24ce5e1ddcb8",
      "name": "Get Context from Google Sheets For Draft",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -32,
        272
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2120745354,
          "cachedResultName": "content_versions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84",
          "cachedResultName": "SEO Content Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "91177de5-c27a-441f-a330-740f7ff6171f",
      "name": "Output Parser (JSON Enforcement) Draft",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        96,
        272
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"draft\": {\n    \"title\": \"The Future of AI Writing Tools in 2025\",\n    \"meta_description\": \"Explore how AI writing tools are revolutionizing content creation in 2025 with efficiency, creativity, and SEO impact.\",\n    \"sections\": [\n      {\n        \"heading\": \"Introduction\",\n        \"content\": \"AI writing tools are transforming how content is produced, enabling faster creation while maintaining quality and SEO standards.\"\n      },\n      {\n        \"heading\": \"Top Tools Leading the Market\",\n        \"content\": \"From ChatGPT to Jasper, several AI writing assistants dominate in efficiency, tone consistency, and language fluency.\"\n      },\n      {\n        \"heading\": \"Challenges and Opportunities\",\n        \"content\": \"AI writing still requires human oversight for emotional accuracy and contextual depth, but future models promise even better synergy.\"\n      }\n    ],\n    \"word_count\": 1250,\n    \"keywords_used\": [\"AI writing tools\", \"content automation\", \"AI writing 2025\"],\n    \"tone\": \"Professional, informative\"\n  },\n  \"metadata\": {\n    \"content_id\": \"CNT-17+1234567890\",\n    \"version_no\": 3,\n    \"version_id\": \"VER-003\",\n    \"timestamp\": 17+1234567890\n  },\n  \"context_used\": [\"Brief from content_versions\"]\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "93c9ddfc-953d-457a-90d6-91a6595d8a8b",
      "name": "OpenAI Chat Model Brief",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -288,
        -128
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "fed1085c-6e6d-4076-9d89-4248bf3842f8",
      "name": "Short-Term Memory Brief",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -160,
        -128
      ],
      "parameters": {
        "sessionKey": "brief-writer-session",
        "sessionIdType": "customKey"
      },
      "typeVersion": 1.3
    },
    {
      "id": "a0565c7d-ab6e-4b27-ab58-401c626dc2df",
      "name": "Get Context from Google Sheets Brief",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -32,
        -128
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 2120745354,
          "cachedResultName": "content_versions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84",
          "cachedResultName": "SEO Content Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "ea87be25-a472-487c-993b-3722cd69505d",
      "name": "Output Parser (JSON Enforcement) Brief",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        96,
        -128
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"brief\": {\n    \"title\": \"Comprehensive Overview of AI Writing Tools\",\n    \"meta_description\": \"Learn about AI tools that transform writing workflows.\",\n    \"target_keywords\": [\"AI writing tools\", \"AI writing software\"],\n    \"outline\": [\"Introduction\", \"Top Tools\", \"How to Choose\"],\n    \"word_count\": 1300,\n    \"tone\": \"Informative\",\n    \"cta_ideas\": [\"Try our AI writing assistant today\"]\n  },\n  \"metadata\": {\n    \"content_id\": \"CNT-4823\",\n    \"version_no\": 1,\n    \"version_id\": \"VER-001\",\n    \"is_new_topic\": true\n  },\n  \"context_used\": [\"none\"]\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "092b6639-b54e-4db2-84e8-ca26bff8a447",
      "name": "OpenAI Chat Model Chat Composer",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -288,
        -528
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5",
          "cachedResultName": "gpt-5"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "db9c4229-22d9-4b90-ba90-9d4989db4b9a",
      "name": "Short-Term Memory Chat Composer",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -160,
        -528
      ],
      "parameters": {
        "sessionKey": "chat-rag-session",
        "sessionIdType": "customKey",
        "contextWindowLength": 7
      },
      "typeVersion": 1.3
    },
    {
      "id": "159703b9-dd45-4f3d-9b8e-76c6303b0f0e",
      "name": "Get row(s) in sheet in Google Sheets For Reference",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -32,
        -528
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 686901835,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit#gid=686901835",
          "cachedResultName": "conversation_logs"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fsnnXsU1n-iX-MEpLuw3XC6wHD-ek6OlkQe31ousk84/edit?usp=drivesdk",
          "cachedResultName": "SEO Content Automation"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "47bdf865-8e62-4f68-9803-c6268975b424",
      "name": "Output Parser (JSON Enforcement) Chat Composer",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        96,
        -528
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"reply\": \"string\",\n  \"context_used\": [\"string\"]\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "1670977b-ad4f-48f0-853d-ccb87af569c8",
      "name": "Logging Chat Composer",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        368,
        -656
      ],
      "parameters": {
        "columns": {
          "value": {
            "input": "={{ $('Format Intent Payload').item.json.content }}",
            "intent": "={{ $('Format Intent Payload').item.json.intent }}",
            "user_id": "system",
            "response": "={{ $json.output.reply }}",
            "timestamp": "={{ $now }}",
            "session_id": "chat-rag-session"
          },
          "schema": [
            {
              "id": "session_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "session_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "user_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "user_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "input",
              "type

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

Enhance your support, onboarding, and internal knowledge workflows with an intelligent RAG-powered chatbot that responds using live data stored in Google Sheets. 🤖📚 Built for teams that rely on structured datasets, this workflow fetches sheet content, enriches it with AI…

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

🧠 Gwen – The AI Voice Marketing Agent Gwen is your intelligent voice-powered marketing assistant built in n8n. She combines the power of OpenAI, ElevenLabs, and automation workflows to handle content

Tool Workflow, Memory Buffer Window, Agent +10
AI & RAG

This workflow automates enterprise resource planning (ERP) operations across Engineering, Finance, HR, and Admin departments for operations managers, ERP administrators, and business process owners wh

Agent, Gmail, Slack +6
AI & RAG

This workflow automates credit operations onboarding by running KYC verification, credit bureau checks, identity validation, and sanctions screening through a single AI-powered agent. Built for credit

Agent, OpenAI Chat, Output Parser Structured +8
AI & RAG

This workflow automates credit operations onboarding by running KYC verification, credit bureau checks, identity validation, and sanctions screening through a single AI-powered agent. Built for credit

Agent, OpenAI Chat, Output Parser Structured +8
AI & RAG

🧾 Short Description

Agent, OpenAI Chat, Output Parser Structured +4