{
  "id": "WT5NjMrz6SipamHI",
  "name": "AI SEO Analyzer & Suggestions",
  "tags": [],
  "nodes": [
    {
      "id": "6ba384d0-5cbb-4ca7-b274-50e38c5d49f6",
      "name": "Webhook Trigger - Input URL",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1312,
        -3440
      ],
      "parameters": {
        "path": "seo-analyzer",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "lastNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c8bfdc37-a14e-49d0-a48f-29fabda05da8",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -1088,
        -3440
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "websiteUrl",
              "type": "string",
              "value": "={{ $json.body.url }}"
            },
            {
              "id": "id-2",
              "name": "analysisTimestamp",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "f56134d4-0b9c-48c5-aa7d-6a1127ddeaec",
      "name": "Fetch Website HTML",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -864,
        -3440
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.websiteUrl }}",
        "options": {
          "redirect": {
            "redirect": {}
          },
          "response": {
            "response": {}
          }
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "f9e4cdd0-8eba-4135-9969-235a903e8c75",
      "name": "Extract SEO Elements",
      "type": "n8n-nodes-base.html",
      "position": [
        -640,
        -3440
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "sourceData": "binary",
        "extractionValues": {
          "values": [
            {
              "key": "title",
              "cssSelector": "title"
            },
            {
              "key": "metaDescription",
              "attribute": "content",
              "cssSelector": "meta[name=\"description\"]",
              "returnValue": "attribute"
            },
            {
              "key": "h1",
              "cssSelector": "h1"
            },
            {
              "key": "h2",
              "cssSelector": "h2"
            },
            {
              "key": "images",
              "attribute": "src",
              "cssSelector": "img",
              "returnValue": "attribute"
            },
            {
              "key": "links",
              "attribute": "href",
              "cssSelector": "a",
              "returnValue": "attribute"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8d082f5e-cc4c-4257-8727-1237914e9c3f",
      "name": "AI SEO Analysis",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -400,
        -3440
      ],
      "parameters": {
        "options": {
          "instructions": "You are an expert SEO analyst. Analyze the provided website data and provide:\n\n1. SEO Score (0-100)\n2. Critical Issues (if any)\n3. Recommendations for:\n   - Title optimization\n   - Meta description improvements\n   - Heading structure\n   - Keyword usage\n   - Internal linking strategy\n   - Image optimization\n\nProvide your response in JSON format with these fields:\n{\n  \"seoScore\": number,\n  \"criticalIssues\": [string],\n  \"recommendations\": {\n    \"title\": string,\n    \"metaDescription\": string,\n    \"headings\": string,\n    \"keywords\": string,\n    \"internalLinking\": string,\n    \"images\": string\n  },\n  \"summary\": string\n}"
        },
        "responses": {
          "values": [
            {
              "content": "=Website URL: {{ $('Workflow Configuration').first().json.websiteUrl }}\n\nPage Title: {{ $json.title }}\nMeta Description: {{ $json.metaDescription }}\nH1 Headings: {{ $json.h1 }}\nH2 Headings: {{ $json.h2 }}\nNumber of Images: {{ $json.images?.length || 0 }}\nNumber of Links: {{ $json.links?.length || 0 }}\n\nPlease analyze this page and provide:"
            }
          ]
        },
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "e9379220-8819-47c2-aed9-600b3c0f71ab",
      "name": "Format AI Output",
      "type": "n8n-nodes-base.set",
      "position": [
        -64,
        -3440
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "aiAnalysis",
              "type": "string",
              "value": "={{ $json.message.content }}"
            },
            {
              "id": "id-2",
              "name": "websiteUrl",
              "type": "string",
              "value": "={{ $('Workflow Configuration').first().json.websiteUrl }}"
            },
            {
              "id": "id-3",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $('Workflow Configuration').first().json.analysisTimestamp }}"
            },
            {
              "id": "id-4",
              "name": "extractedElements",
              "type": "object",
              "value": "={{ { title: $('Extract SEO Elements').first().json.title, metaDescription: $('Extract SEO Elements').first().json.metaDescription, h1Count: $('Extract SEO Elements').first().json.h1?.length || 0, h2Count: $('Extract SEO Elements').first().json.h2?.length || 0, imageCount: $('Extract SEO Elements').first().json.images?.length || 0, linkCount: $('Extract SEO Elements').first().json.links?.length || 0 } }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "217dd9a1-a3a2-4f38-b49c-f6f848753980",
      "name": "Route by SEO Score",
      "type": "n8n-nodes-base.switch",
      "position": [
        160,
        -3456
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Critical Issues",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.aiAnalysis }}",
                    "rightValue": "seoScore"
                  },
                  {
                    "operator": {
                      "type": "number",
                      "operation": "lt"
                    },
                    "leftValue": "={{ $json.seoScore }}",
                    "rightValue": 60
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Minor Issues",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.aiAnalysis }}",
                    "rightValue": "seoScore"
                  },
                  {
                    "operator": {
                      "type": "number",
                      "operation": "gte"
                    },
                    "leftValue": "={{ $json.seoScore }}",
                    "rightValue": 60
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "ignoreCase": true,
          "fallbackOutput": "extra",
          "renameFallbackOutput": "No Score"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6cdfca25-ad04-4ca5-8570-7d667ea3de31",
      "name": "Log to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        384,
        -3632
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "websiteUrl"
          ]
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "<__PLACEHOLDER_VALUE__Sheet Name (e.g., SEO Analysis)__>"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "<__PLACEHOLDER_VALUE__Google Sheets Document ID__>"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "107f4f86-c47b-4e10-9b81-375a0d0f86a4",
      "name": "Send Slack Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        384,
        -3440
      ],
      "parameters": {
        "text": "=\ud83d\udea8 *Critical SEO Issues Found*\n\n*Website:* {{ $json.websiteUrl }}\n*Timestamp:* {{ $json.timestamp }}\n\n*AI Analysis:*\n{{ $json.aiAnalysis }}\n\nPlease review the full report in Google Sheets.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "<__PLACEHOLDER_VALUE__Slack Channel ID or Name__>"
        },
        "otherOptions": {}
      },
      "typeVersion": 2.4
    },
    {
      "id": "a294c668-90e2-4c24-b09f-aed1a03735bd",
      "name": "Send Email Report",
      "type": "n8n-nodes-base.gmail",
      "position": [
        384,
        -3248
      ],
      "parameters": {
        "sendTo": "<__PLACEHOLDER_VALUE__Recipient Email Address__>",
        "message": "=<h2>SEO Analysis Report</h2>\n<p><strong>Website:</strong> {{ $json.websiteUrl }}</p>\n<p><strong>Analysis Date:</strong> {{ $json.timestamp }}</p>\n\n<h3>Extracted Elements</h3>\n<ul>\n<li><strong>Title:</strong> {{ $json.extractedElements.title }}</li>\n<li><strong>Meta Description:</strong> {{ $json.extractedElements.metaDescription }}</li>\n<li><strong>H1 Count:</strong> {{ $json.extractedElements.h1Count }}</li>\n<li><strong>H2 Count:</strong> {{ $json.extractedElements.h2Count }}</li>\n<li><strong>Images:</strong> {{ $json.extractedElements.imageCount }}</li>\n<li><strong>Links:</strong> {{ $json.extractedElements.linkCount }}</li>\n</ul>\n\n<h3>AI Recommendations</h3>\n<pre>{{ $json.aiAnalysis }}</pre>\n\n<p>Full details are available in the Google Sheets log.</p>",
        "options": {},
        "subject": "=SEO Analysis Report - {{ $json.websiteUrl }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d5866573-81d7-4fb9-800d-fc066c496654",
      "name": "Final Report Storage",
      "type": "n8n-nodes-base.set",
      "position": [
        608,
        -3440
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "finalReport",
              "type": "object",
              "value": "={{ { websiteUrl: $json.websiteUrl, timestamp: $json.timestamp, extractedElements: $json.extractedElements, aiAnalysis: $json.aiAnalysis, status: 'completed' } }}"
            },
            {
              "id": "id-2",
              "name": "reportId",
              "type": "number",
              "value": "={{ $now.toMillis() }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "3f3ac293-98b6-44dc-9790-cee2eb99ef65",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1360,
        -3744
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 544,
        "content": "## Webhook & Config"
      },
      "typeVersion": 1
    },
    {
      "id": "9192c316-6894-4e4a-9d57-e1c6c9d8b66a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -3744
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 544,
        "content": "## Website Data"
      },
      "typeVersion": 1
    },
    {
      "id": "3126949b-3258-4f27-8219-b69dc0351a55",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -3744
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 544,
        "content": "## SEO Analysis"
      },
      "typeVersion": 1
    },
    {
      "id": "6ab8a006-c262-4c51-8b4c-cf3f77aba544",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        112,
        -3792
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 736,
        "content": "## Log & Notify"
      },
      "typeVersion": 1
    },
    {
      "id": "cb183d2a-5d18-4214-9bab-385e26168479",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1680,
        -3792
      ],
      "parameters": {
        "width": 304,
        "height": 656,
        "content": "## Main\nThis workflow automatically analyzes any website for SEO performance using AI and provides actionable suggestions.\nIt fetches the website content, extracts key elements, and uses OpenAI to identify improvements in headings, keywords, meta tags, and internal linking.\n\nPerfect for agencies, consultants, or anyone managing websites who wants instant SEO insights.\n\nCreated by Hyrum Hurst, AI Automation Engineer at QuarterSmart.\n\n## Setup\n1. Input your target website URL in the Manual Trigger or Webhook node.\n2. Add your Google Sheets credentials and choose the sheet to store results.\n3. Configure Slack/Gmail nodes for notifications.\n4. Add your OpenAI API key in the OpenAI node (do not hardcode in HTTP nodes).\n5. Optional: customize the Switch node thresholds for critical/minor issues.\nFor setup help, contact: hyrum@quartersmart.com\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f9ecb539-3be2-481a-9499-3cdbfd46ee9b",
  "connections": {
    "AI SEO Analysis": {
      "main": [
        [
          {
            "node": "Format AI Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format AI Output": {
      "main": [
        [
          {
            "node": "Route by SEO Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Slack Alert": {
      "main": [
        [
          {
            "node": "Final Report Storage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Report": {
      "main": [
        [
          {
            "node": "Final Report Storage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Website HTML": {
      "main": [
        [
          {
            "node": "Extract SEO Elements",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by SEO Score": {
      "main": [
        [
          {
            "node": "Log to Google Sheets",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Slack Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Email Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract SEO Elements": {
      "main": [
        [
          {
            "node": "AI SEO Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Google Sheets": {
      "main": [
        [
          {
            "node": "Final Report Storage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Fetch Website HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook Trigger - Input URL": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}