{
  "nodes": [
    {
      "id": "4d2499a9-5fca-430c-b1c1-19dfd9524fd4",
      "name": "Workflow Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -48
      ],
      "parameters": {
        "width": 612,
        "height": 1052,
        "content": "# Automated Blog Content Creation & Publishing\n\nThis workflow helps agencies and content teams automate their entire blog publishing process. It handles everything from keyword research to WordPress publication, saving hours of manual work each week.\n\n## How it works\n\nEvery morning at 7 AM, the workflow checks your active client projects and their publishing schedules. For each client due to publish today, it fetches approved blog topics from Google Sheets. The system then conducts deep SEO research using Perplexity web search to analyze top competitors and identify content opportunities.\n\nNext, an AI agent writes an 800-1000 word article optimized for Indian investors, using simple language and proper HTML formatting. The content includes internal links, FAQs, and LSI keywords. After extracting the title and body, the workflow prepares the data and triggers a sub-workflow that handles WordPress publishing with images.\n\nThe entire process runs without manual intervention, publishing one blog per client per day based on their frequency settings.\n\n## Setup steps\n\n1. **Add your credentials**: Connect Google Sheets OAuth, Google Gemini API, DeepSeek API, and Perplexity API in n8n's credential manager.\n\n2. **Prepare your project sheet**: Create a Google Sheet with columns for Client ID, Website URL, Blog API, GMB Name, Weekly Frequency (Daily/Mon/Tue/etc), and On Page Sheet URL. Add this sheet URL in the \"Load Active Client Projects\" node.\n\n3. **Set up content sheets**: For each client, maintain a separate sheet with columns: Focus Keyword, Content Topic, Internal Linking URLs, Words, Topic Approval, Content Approval. Link these in your project sheet.\n\n4. **Configure the sub-workflow**: Ensure the \"Blog Publishing\" node points to your WordPress publishing workflow (not included in this template).\n\n5. **Test with one client**: Add a test project, run manually, and verify the content quality before activating the daily schedule.\n\n\n## Important: 2-Part Automation System\n\nThis workflow (Part 1) handles content research and writing. To complete the automation, you need Part 2 which handles WordPress publishing with images."
      },
      "typeVersion": 1
    },
    {
      "id": "54f8899e-148f-43b2-b689-98ec63bf67b1",
      "name": "Daily Blog Publishing Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        416,
        352
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f04166f2-0b12-48a3-baa7-42ec3050ccea",
      "name": "Load Active Client Projects",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        640,
        352
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "=Select_Your_Column"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "=Your_Sheet_URL"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "2c251de2-d752-4d59-9c1a-fff657de0a7e",
      "name": "Verify Publishing Day & Frequency",
      "type": "n8n-nodes-base.if",
      "position": [
        848,
        352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "ad02573b-8ca4-4657-9e4a-ee6490d9cce3",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json['Weekly Frequency'] }}",
              "rightValue": "={{ $now.toFormat('ccc') }}"
            },
            {
              "id": "b170466b-7f1b-4575-8749-1e6185cae9f8",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json['Weekly Frequency'] }}",
              "rightValue": "Daily"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "409cf0b3-4632-4c27-9820-b6658ca88497",
      "name": "Process Each Client Project",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1152,
        336
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "64b080a9-b6cb-4225-a720-627421368066",
      "name": "Get Approved Blog Topics from Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueRegularOutput",
      "position": [
        1360,
        352
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "ID"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "=your_sheet_url"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "notesInFlow": false,
      "typeVersion": 4.5,
      "alwaysOutputData": true
    },
    {
      "id": "f66c60a1-ab65-4c3a-bc54-6f2e4828d71c",
      "name": "Validate Focus Keyword Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        1568,
        352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8cc1c059-bf65-4864-bfb8-12c56481789a",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json['Focus Keyword'] }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "601b04a9-dfb0-482d-a64b-399bd2b569fe",
      "name": "Select First Pending Topic",
      "type": "n8n-nodes-base.code",
      "position": [
        1824,
        336
      ],
      "parameters": {
        "jsCode": "// Keep only the first item\nreturn [items[0]];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "0c08f81d-1caf-4d48-bfc6-08878e7d2edb",
      "name": "Research Keyword & Topics",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2096,
        336
      ],
      "parameters": {
        "text": "=Keyword: {{ $json['Focus Keyword'] }}\nContent Topic: {{ $json['Content Topic'] }}",
        "options": {
          "systemMessage": "=I will provide a content topic and a targeted keyword. As an expert content writer, please conduct comprehensive research and deliver a detailed, actionable report that will help craft a highly engaging, user-focused blog post. Your report should include:\n\nSearch Intent Analysis: Identify the main search intent (informational, commercial, navigational, transactional) behind the keyword and explain why it matters for content strategy.\n\nIf the topic is related to Top, Best type than do the research for this website {{ $('Load Active Client Projects').item.json['Website URL'] }}\n\nTop Competitor Insights: Analyze the top 5\u201310 ranking pages for this keyword. For each, provide the title, meta description, URL, and a brief summary highlighting their approach and content strengths.\n\nContent Gaps & Opportunities: Identify what these top pages miss or underdeliver on, revealing opportunities to make my blog more valuable and distinctive.\n\nAudience Profile & Needs: Describe the target audience\u2019s demographics, pain points, desires, and the key questions they want answered related to this topic.\n\nTrending Subtopics & Related Keywords: List relevant, trending subtopics and related keywords, including search volume and difficulty metrics where available, to help expand and deepen the blog content.\n\nLSI Keywords & Related Keywords: Provide 5 LSI (Latent Semantic Indexing) keywords and 5 closely related keywords that can be incorporated to improve SEO and content relevance.\n\nSEO-Optimized Blog Outline: Propose a detailed blog outline with clear headings and subheadings designed to maximize SEO impact and reader engagement.\n\nTrusted Sources & References: Provide a curated list of credible sources and references for fact-checking and citation to ensure authoritative and trustworthy content.\n\nPlease make your recommendations practical and focused on creating an engaging, authoritative, and SEO-friendly blog post that stands out. "
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "7fcf5603-6283-4580-80d9-a958dab54ccb",
      "name": "Generate SEO-Optimized Article",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2480,
        336
      ],
      "parameters": {
        "text": "=- **Keyword:** {{ $('Select First Pending Topic').item.json['Focus Keyword'] }}\n- **Content Topic:** {{ $('Select First Pending Topic').item.json['Content Topic'] }}\n- **Target Page:** {{ $node[\"Select First Pending Topic\"].json['Internal Linking URLs'] }}\n- **Words:** {{ $('Select First Pending Topic').item.json.Words }}\n\n- Reaesrch: {{ $json.output }}",
        "options": {
          "systemMessage": "=You are an expert content writer. Write an 800\u20131000 word article in clear, easy-to-read, conversational English. Use short sentences, avoid heavy jargon, and explain technical terms simply for an Indian investor audience. The content must have a high readability score.\nAdd FAQs Section as well and 5 question and 5 answers with the Section Heading \"Frequently Asked Questions\"\nInstructions:\nStart content with the Question.\nIf the Topic is Related to Top and Best list than Keep the Client ({{ $('Load Active Client Projects').item.json['Website URL'] }}) Business Name: {{ $('Load Active Client Projects').item.json['GMB Name'] }} on top Number\n\nDo not use AI Terms Like Imagine\nUse simple HTML with only these tags: <h1>, <h2>, <p>, <ul>, <ol>, <b>, <i>, <a>.\nKeep FAQs Question in H4 Heading\n\nStart directly with the content section\u2014no <head>, <footer>, CSS, or extra formatting.\n\nIntegrate the primary keyword naturally without repeating it too closely. Use it once in a subheading (<h2> or <h3>), phrased naturally (e.g., instead of \u201cbuy sell unlisted shares India,\u201d write \u201cbuy and sell unlisted shares in India\u201d).\n\nAdd relevant LSI keywords naturally to provide context.\n\n\nKeep paragraphs short (3\u20134 sentences) to enhance readability.\n\nAvoid repeated points and do not use em dashes or \\n line breaks in the HTML.\n\nWrite as if explaining to a smart friend, with practical tips and examples tailored for Indian investors.\n\nAvoid keyword stuffing; integrate keywords naturally throughout the text.\n\nDeliverable:\nOutput only the HTML content\u2014no explanations or extra comments. "
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "c72ed67b-1e84-4b4f-b8f6-6d303bbd032c",
      "name": "Extract Title & Body Content",
      "type": "n8n-nodes-base.code",
      "position": [
        2880,
        336
      ],
      "parameters": {
        "jsCode": "// Get the input string\nlet content = $input.first().json.output;\n\n// Remove all newlines\ncontent = content.replace(/\\n/g, '');\n\n// Remove em dashes\ncontent = content.replace(/\u2014/g, ' ');\n\n// Extract the content inside the first <h1> tag\nconst h1Match = content.match(/<h1[^>]*>(.*?)<\\/h1>/);\nconst h1Content = h1Match ? h1Match[1] : '';\n\n// Remove all <h1> tags and their content from the original string\nconst excludedH1Content = content.replace(/<h1[^>]*>.*?<\\/h1>/g, '');\n\nreturn {\n  json: {\n    h1Only: h1Content,\n    excludedH1: excludedH1Content\n  }\n};\n"
      },
      "typeVersion": 2
    },
    {
      "id": "237c9834-d7ec-44eb-8f53-336ce3644951",
      "name": "Prepare Blog Data for Publishing",
      "type": "n8n-nodes-base.set",
      "position": [
        3088,
        336
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "879ec377-94b8-47da-a593-5876e2f35f28",
              "name": "S NO",
              "type": "string",
              "value": "={{ $node[\"Select First Pending Topic\"].json['row_number'] }}"
            },
            {
              "id": "be91b8ad-22cd-4a72-ae04-0e9a44df7cb2",
              "name": "Blog Title",
              "type": "string",
              "value": "={{ $('Select First Pending Topic').item.json['Content Topic'] }}"
            },
            {
              "id": "b04eb3ec-c74d-42ca-95ea-190f05e160d2",
              "name": "Content",
              "type": "string",
              "value": "={{ $json.excludedH1 }}"
            },
            {
              "id": "5267bc48-e1ec-454b-b85c-c87b9f789123",
              "name": "Auth Code",
              "type": "string",
              "value": "={{ $node[\"Load Active Client Projects\"].json['Blog API'] }}"
            },
            {
              "id": "23e11954-9595-448c-ad95-ad56c652edf5",
              "name": "Website URL",
              "type": "string",
              "value": "={{ $node[\"Load Active Client Projects\"].json['Website URL'] }}"
            },
            {
              "id": "e9e5d5fd-973f-4f82-b433-a6ef83697dc5",
              "name": "OnPage SEO",
              "type": "string",
              "value": "={{ $('Process Each Client Project').item.json['On Page Sheet'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4f58c6cb-1115-4f78-a03f-de2354ffb468",
      "name": "Trigger WordPress Publishing Workflow",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        3312,
        336
      ],
      "parameters": {
        "options": {
          "waitForSubWorkflow": false
        },
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "NZ064TnXQVyJikPh",
          "cachedResultUrl": "/workflow/NZ064TnXQVyJikPh",
          "cachedResultName": "Plan>Design>Test \u2014 Blog Publishing Automation"
        },
        "workflowInputs": {
          "value": {
            "Content": "={{ $json.Content }}",
            "Client ID": "={{ $node[\"Process Each Client Project\"].json['Client ID'] }}",
            "Blog S.NO.": "={{ $node[\"Get Approved Blog Topics from Sheet\"].json.row_number.toString() }}",
            "Blog Title": "={{ $json['Blog Title'] }}",
            "OnPage SEO": "={{ $json['OnPage SEO'] }}",
            "Focus Keyword": "={{ $('Select First Pending Topic').item.json['Focus Keyword'] }}"
          },
          "schema": [
            {
              "id": "Client ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Client ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Blog S.NO.",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Blog S.NO.",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Blog Title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Blog Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Content",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "OnPage SEO",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "OnPage SEO",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Focus Keyword",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Focus Keyword",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "5ca55d4f-1205-48f3-81a2-335655701356",
      "name": "Gemini - Content Writing Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        2480,
        624
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1d6bcd54-e57a-4d4a-998e-1c54454996ba",
      "name": "DeepSeek - Research Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatDeepSeek",
      "position": [
        2096,
        640
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "deepSeekApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c5659bb0-e387-4ebf-b7e7-3f2f8bfa33ec",
      "name": "Perplexity - Web Search Tool",
      "type": "n8n-nodes-base.perplexityTool",
      "position": [
        2240,
        640
      ],
      "parameters": {
        "options": {},
        "messages": {
          "message": [
            {
              "content": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('message0_Text', ``, 'string') }}"
            }
          ]
        },
        "requestOptions": {}
      },
      "credentials": {
        "perplexityApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "de740781-a712-42c6-af1d-0c23ab7275c2",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 256,
        "content": "## Project Scheduling & Validation\n\nRuns daily at 7 AM to load active client projects and verify which clients should publish today based on their weekly frequency settings\n"
      },
      "typeVersion": 1
    },
    {
      "id": "324aa406-ce19-4034-8112-e35c0de327ed",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 240,
        "content": "## Client Data Processing\n\nLoops through each client project, fetches approved blog topics from their Google Sheet, validates keyword data, and selects the first pending topic for content creation\n"
      },
      "typeVersion": 1
    },
    {
      "id": "90c2d705-e221-4685-99ae-b95811525ae9",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2096,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 240,
        "content": "## AI-Powered Content Creation\n\nUses Perplexity for web research, DeepSeek for competitor analysis, and Google Gemini to write an 800-1000 word SEO-optimized article with FAQs and internal links\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0115ac5a-be81-4d5b-976a-f343106ed2a3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2880,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 240,
        "content": "## Content Formatting\n\nExtracts the H1 title from generated HTML, removes it from body content, and prepares all blog data for WordPress publishing\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a43687ec-4fd7-4426-bd4e-0d1588e374fb",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3264,
        144
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 240,
        "content": "## WordPress Publishing\n\nSends prepared blog content to a sub-workflow that handles WordPress posting with featured images and category assignment\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "DeepSeek - Research Model": {
      "ai_languageModel": [
        [
          {
            "node": "Research Keyword & Topics",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Research Keyword & Topics": {
      "main": [
        [
          {
            "node": "Generate SEO-Optimized Article",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select First Pending Topic": {
      "main": [
        [
          {
            "node": "Research Keyword & Topics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Active Client Projects": {
      "main": [
        [
          {
            "node": "Verify Publishing Day & Frequency",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Each Client Project": {
      "main": [
        [],
        [
          {
            "node": "Get Approved Blog Topics from Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Title & Body Content": {
      "main": [
        [
          {
            "node": "Prepare Blog Data for Publishing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Perplexity - Web Search Tool": {
      "ai_tool": [
        [
          {
            "node": "Research Keyword & Topics",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Validate Focus Keyword Exists": {
      "main": [
        [
          {
            "node": "Select First Pending Topic",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Process Each Client Project",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Blog Publishing Schedule": {
      "main": [
        [
          {
            "node": "Load Active Client Projects",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini - Content Writing Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate SEO-Optimized Article",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Generate SEO-Optimized Article": {
      "main": [
        [
          {
            "node": "Extract Title & Body Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Blog Data for Publishing": {
      "main": [
        [
          {
            "node": "Trigger WordPress Publishing Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verify Publishing Day & Frequency": {
      "main": [
        [
          {
            "node": "Process Each Client Project",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Approved Blog Topics from Sheet": {
      "main": [
        [
          {
            "node": "Validate Focus Keyword Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger WordPress Publishing Workflow": {
      "main": [
        [
          {
            "node": "Process Each Client Project",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}