{
  "nodes": [
    {
      "id": "0cd19fc6-3a7e-4398-b180-eeb96eb7be32",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {},
        "formTitle": "Website Audit ",
        "formFields": {
          "values": [
            {
              "fieldLabel": "url",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Website Audit "
      },
      "typeVersion": 2.2
    },
    {
      "id": "1683a3a1-1680-496f-a184-0c4148753abc",
      "name": "Website Audit",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        240,
        0
      ],
      "parameters": {
        "url": "https://website-seo-analyzer-and-audit-ai.p.rapidapi.com/seo.php",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.url }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "website-seo-analyzer-and-audit-ai.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "your key "
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0c5903dd-af19-4223-bd64-33df65747bba",
      "name": "Reformat",
      "type": "n8n-nodes-base.code",
      "position": [
        540,
        0
      ],
      "parameters": {
        "jsCode": "const data = $input.first().json.data.apiData.results;\n\n// Basic metadata\nconst basic = data.basic;\nconst adv = data.advanced;\nconst perf = data.performance;\nconst sec = data.security;\n\nconst formatStatus = (status) => status === 'passed' ? '\u2705 Passed' : '\u274c Failed';\n\n// Format keyword counts\nconst keywordStats = Object.entries(basic.keywords || {})\n  .map(([word, count]) => `- **${word}**: ${count}`)\n  .join('\\n');\n\nconst keywordsInTD = basic.keywordsInTitleDescription?.value || {};\nconst titleKeywords = Object.entries(keywordsInTD.title || {}).map(([k, v]) => `${k} (${v})`).join(', ');\nconst descKeywords = Object.entries(keywordsInTD.description || {}).map(([k, v]) => `${k} (${v})`).join(', ');\n\n// Format no alt images\nconst missingAltImgs = basic.noImgAltAtts?.value?.length || 0;\n\n// Format H1/H2 Tags\nconst h1Tags = basic.h1Tags?.value || [];\nconst h2Tags = basic.h2Tags?.value || [];\n\nconst formatted = `\n# \ud83d\udd0d SEO Site Audit Summary\n\n## \ud83d\udcdd Page Metadata\n- **Title:** ${basic.title?.value || 'N/A'} (${basic.title?.length || 0} chars) \u2014 ${formatStatus(basic.title?.status)}\n- **Description:** ${basic.description?.value || 'N/A'} (${basic.description?.length || 0} chars) \u2014 ${formatStatus(basic.description?.status)}\n- **Title Keywords:** ${titleKeywords || 'None'}\n- **Description Keywords:** ${descKeywords || 'None'}\n\n## \ud83c\udff7\ufe0f Keyword Density\n${keywordStats || 'No keywords found.'}\n\n## \ud83e\uddf1 Headers\n- **H1 Tags:** ${h1Tags.length > 0 ? h1Tags.join('; ') : '\u274c None Found'}\n- **H2 Tags:** ${h2Tags.length > 0 ? h2Tags.join('; ') : '\u274c None Found'}\n\n## \ud83d\uddbc\ufe0f Image Optimization\n- Missing \\`alt\\` tags: ${missingAltImgs} ${missingAltImgs > 0 ? '\u274c Needs improvement' : '\u2705 All good'}\n\n## \ud83d\udd17 Links Summary\n- Internal Links: ${basic.linksRatio?.value?.internal || 0}\n- External Links: ${basic.linksRatio?.value?.external || 0} \u2014 ${formatStatus(basic.linksRatio?.status)}\n\n## \ud83d\udcf1 Search Preview\n${adv.searchPreview || 'N/A'}\n\n## \ud83d\udce6 Performance\n- JS Unminified: ${perf.unminifiedJs?.value?.length || 0} \u2014 ${formatStatus(perf.unminifiedJs?.status)}\n- CSS Unminified: ${perf.unminifiedCss?.value?.length || 0} \u2014 ${formatStatus(perf.unminifiedCss?.status)}\n- Total Page Objects: ${perf.pageObjects?.value?.total || 0} \u2014 ${formatStatus(perf.pageObjects?.status)}\n- Page Size: ${perf.pageSize?.value || 0} KB\n- Response Time: ${perf.responseTime?.value || 0} sec\n\n## \ud83d\udee1\ufe0f Security\n- Secure Connection: ${formatStatus(sec.secureConnection?.status)}\n- Google Safe Browsing: ${formatStatus(sec.googleSafeBrowsing?.status)}\n- Directory Listing: ${formatStatus(sec.directoryListing?.status)}\n\n## \ud83e\udde0 Structured Data\n- Open Graph Tags: ${adv.openGraph?.status === 'error' ? `\u274c Missing: ${adv.openGraph?.value?.join(', ')}` : '\u2705 Present'}\n- Schema.org Markup: ${formatStatus(adv.schema?.status)}\n\n---\n`;\n\nreturn [\n  {\n    json: {\n      docContent: formatted.trim()\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "17a12918-acce-46c2-9c54-05baa4a0f50d",
      "name": "Add Data In Google Docs",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        800,
        0
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ $json.docContent }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "documentURL": "",
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "21db8a8f-d651-4c2b-9884-dfdf29099cd7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -700,
        -380
      ],
      "parameters": {
        "width": 540,
        "height": 720,
        "content": "### \ud83e\uddfe Automated Website SEO Audit and Google Docs Report\n\n### This n8n workflow performs an SEO audit of a submitted website URL using a RapidAPI service and generates a well-formatted SEO report in Google Docs.\n\n---\n\n### 1\ufe0f\u20e3 **On form submission** (`formTrigger`)\n- Collects a website URL from a form input to initiate the audit process.\n\n---\n\n### 2\ufe0f\u20e3 **Website Audit** (`httpRequest`)\n- Sends the submitted URL to the SEO Audit API via RapidAPI to fetch audit results.\n\n---\n\n### 3\ufe0f\u20e3 **Reformat** (`code`)\n- Parses and reformats the raw audit JSON into a clean, readable Markdown report.\n\n---\n\n### 4\ufe0f\u20e3 **Add Data In Google Docs** (`googleDocs`)\n- Inserts the generated SEO audit report into a specified Google Docs file.\n\n---\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f6e2c21f-1c6a-4e03-9f9d-838ccb417dbe",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -220
      ],
      "parameters": {
        "height": 340,
        "content": "\ud83d\udfe2 **On form submission**\n- **Type:** `formTrigger`\n- **Purpose:** Captures the website URL entered by the user in the form to initiate the audit process.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "6a153f89-ba90-4330-852f-1bfe023539c2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        -220
      ],
      "parameters": {
        "height": 340,
        "content": "\ud83c\udf10 **Website Audit**\n- **Type:** `httpRequest`\n- **Purpose:** Sends a POST request with the submitted URL to the SEO Analyzer API via RapidAPI to retrieve audit data.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ea5d183b-03cf-4f7b-9e88-bdecc6506084",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        -220
      ],
      "parameters": {
        "height": 340,
        "content": " \ud83e\udde0 **Reformat**\n- **Type:** `code`\n- **Purpose:** Extracts and formats the raw SEO data into a structured, readable Markdown report summarizing performance, metadata, security, and more.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "d306ad26-fe30-4c40-bf9a-bb4403366b91",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        -220
      ],
      "parameters": {
        "height": 340,
        "content": "\ud83d\udcc4 **Add Data In Google Docs**\n- **Type:** `googleDocs`\n- **Purpose:** Appends the formatted SEO report into a specified Google Docs document using the connected Google account.\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Reformat": {
      "main": [
        [
          {
            "node": "Add Data In Google Docs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Website Audit": {
      "main": [
        [
          {
            "node": "Reformat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Website Audit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}