{
  "nodes": [
    {
      "id": "f3824049-9114-447c-8c3f-e3a08af34d12",
      "name": "Google Search",
      "type": "n8n-nodes-base.httpRequest",
      "parameters": {
        "url": "https://www.googleapis.com/customsearch/v1",
        "queryParametersUi": {
          "parameter": [
            {
              "name": "key",
              "value": "$env.GOOGLE_CUSTOM_SEARCH_API_KEY"
            },
            {
              "name": "cx",
              "value": "$env.GOOGLE_CUSTOM_SEARCH_CX"
            },
            {
              "name": "q",
              "value": "=intitle:\"{{ $json.title }}\" (pricing OR features OR buy OR software) -medium.com -quora.com -youtube.com -linkedin.com"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "840baf66-d14c-4d2c-90f5-05ba174bcc15",
      "name": "Extract Competitor Data",
      "type": "n8n-nodes-base.function",
      "parameters": {
        "functionCode": "let allTitles = [];\nlet allDescriptions = [];\nlet allKeywords = [];\n\nfor (const item of $json.items) {\n  allTitles.push(item.title);\n  allDescriptions.push(item.snippet);\n\n  const keywords = item.title\n    .toLowerCase()\n    .replace(/[^a-zA-Z0-9 ]/g, '')\n    .split(' ')\n    .filter(w => w.length > 3);\n\n  allKeywords.push(...keywords);\n}\n\nconst uniqueKeywords = [...new Set(allKeywords)];\n\nreturn [\n  {\n    json: {\n      chatInput: `\nTitle List:\n${allTitles.join('\\n')}\n\nDescription List:\n${allDescriptions.join('\\n')}\n\nKeywords:\n${uniqueKeywords.join(', ')}\n      `.trim()\n    }\n  }\n];\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0a2929a1-d6fc-4a37-b142-54b0e2135652",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "parameters": {
        "messages": {
          "messageValues": [
            {
              "message": "You are an expert SEO content writer and product copywriter.  generate the following in one output:  1. SEO Meta Data: - Title: (exact product title) - Description: A concise, persuasive meta description optimized for Google SEO best practices. Make sure it is between 120-160 characters, includes main keywords naturally, and encourages clicks. - Keywords: A list of relevant, highly ranked keywords related to the product.  2. Product Content: - Product Title: (exact same title as SEO Meta Data Title) - Product Description: A detailed, engaging product description of minimum 150 words that highlights the product’s key features, benefits, and usage. Use natural language with relevant keywords but avoid keyword stuffing."
            }
          ]
        }
      },
      "typeVersion": 1.5
    },
    {
      "id": "797456cf-d4a2-49b7-8134-d5ebbf062cc7",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "parameters": {
        "modelName": "models/gemini-2.0-flash"
      },
      "typeVersion": 1
    },
    {
      "id": "44d6ebd9-ad12-4838-aee0-9b8a4a847a6b",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "parameters": {
        "columns": {
          "schema": [
            {
              "id": "type",
              "type": "string",
              "required": false
            },
            {
              "id": "title",
              "type": "string",
              "required": false
            },
            {
              "id": "description",
              "type": "string",
              "required": false
            },
            {
              "id": "keywords",
              "type": "string",
              "required": false
            },
            {
              "id": "product_title",
              "type": "string",
              "required": false
            },
            {
              "id": "product_description",
              "type": "string",
              "required": false
            }
          ]
        },
        "operation": "appendOrUpdate",
        "sheetName": {
          "value": ""
        },
        "documentId": {
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "typeVersion": 4.5
    },
    {
      "id": "571bb379-f061-42ae-b633-3e80467a0a3d",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "parameters": {
        "formTitle": "Product Research",
        "formFields": {
          "values": [
            {
              "fieldLabel": "title",
              "placeholder": "Enter product title",
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0a4b670a-50b3-4a60-ae51-e3bb958f573a",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "parameters": {
        "assignments": [
          {
            "name": "title",
            "type": "string",
            "value": "={{ $json.title }}"
          }
        ]
      },
      "typeVersion": 3.4
    }
  ],
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Google Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Search": {
      "main": [
        [
          {
            "node": "Extract Competitor Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Competitor Data": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}