{
  "name": "AI SEO Meta Tag Generator",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "generate-seo-meta",
        "responseMode": "lastNode"
      },
      "id": "a1b2c3d4-1005-4000-8000-000000000001",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1.1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ $json.body.url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        }
      },
      "id": "a1b2c3d4-1005-4000-8000-000000000002",
      "name": "Scrape Page Content",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const html = $input.first().json.data;\n// Extract text content from HTML\nconst textContent = html\n  .replace(/<script[^>]*>[\\s\\S]*?<\\/script>/gi, '')\n  .replace(/<style[^>]*>[\\s\\S]*?<\\/style>/gi, '')\n  .replace(/<[^>]+>/g, ' ')\n  .replace(/\\s+/g, ' ')\n  .trim()\n  .substring(0, 3000);\n\nconst existingTitle = (html.match(/<title>([^<]+)<\\/title>/) || [])[1] || '';\nconst existingMeta = (html.match(/<meta\\s+name=\"description\"\\s+content=\"([^\"]+)\"/) || [])[1] || '';\n\nreturn [{\n  json: {\n    url: $('Webhook').first().json.body.url,\n    pageContent: textContent,\n    existingTitle: existingTitle,\n    existingMeta: existingMeta\n  }\n}];"
      },
      "id": "a1b2c3d4-1005-4000-8000-000000000003",
      "name": "Extract Page Text",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        750,
        300
      ]
    },
    {
      "parameters": {
        "resource": "chat",
        "model": "gpt-4",
        "messages": {
          "values": [
            {
              "content": "Analyze the following web page content and generate optimized SEO meta tags.\n\nURL: {{ $json.url }}\nExisting Title: {{ $json.existingTitle }}\nExisting Meta Description: {{ $json.existingMeta }}\nPage Content: {{ $json.pageContent }}\n\nReturn JSON with:\n- metaTitle (max 60 chars, include primary keyword)\n- metaDescription (max 160 chars, compelling with CTA)\n- ogTitle (Open Graph title)\n- ogDescription (Open Graph description, max 200 chars)\n- keywords (array of 5-10 relevant keywords)\n- h1Suggestion (suggested H1 tag)\n- improvements (array of 3-5 SEO improvement suggestions)"
            }
          ]
        },
        "options": {
          "temperature": 0.5,
          "maxTokens": 1500
        }
      },
      "id": "a1b2c3d4-1005-4000-8000-000000000004",
      "name": "OpenAI Generate SEO Meta",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.3,
      "position": [
        1000,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const response = JSON.parse($input.first().json.message.content);\nreturn [{\n  json: {\n    url: $('Extract Page Text').first().json.url,\n    ...response,\n    generatedAt: new Date().toISOString()\n  }\n}];"
      },
      "id": "a1b2c3d4-1005-4000-8000-000000000005",
      "name": "Format Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1250,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json) }}"
      },
      "id": "a1b2c3d4-1005-4000-8000-000000000006",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1500,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Scrape Page Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Page Content": {
      "main": [
        [
          {
            "node": "Extract Page Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Page Text": {
      "main": [
        [
          {
            "node": "OpenAI Generate SEO Meta",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Generate SEO Meta": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}