{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "63865e5c-9e83-49ad-8d51-02391ee9e36c",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -920,
        -700
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e935f831-25e0-4325-b0a4-72dd632c6c46",
      "name": "Fetch Google Search Results JSON",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -20,
        -680
      ],
      "parameters": {
        "url": "https://api.brightdata.com/request",
        "method": "POST",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendBody": true,
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "zone",
              "value": "serp_api1"
            },
            {
              "name": "url",
              "value": "=https://www.google.com/search?q={{ $json.search_term .replaceAll(\" \", \"+\")}}&start=0&brd_json=1"
            },
            {
              "name": "country",
              "value": "={{ $json['country code'] }}"
            },
            {
              "name": "format",
              "value": "raw"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "async",
              "value": "true"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "91fa9b7c-626d-48aa-9728-2126f75be833",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        160,
        -680
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "organic"
      },
      "typeVersion": 1
    },
    {
      "id": "ee4881f0-9148-493e-825e-ce2dde83fbae",
      "name": "Get Keywords",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -700,
        -700
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QU9rwawCZLiYW8nlYYRMj-9OvAUNZoe2gP49KbozQqw/edit#gid=0",
          "cachedResultName": "Keywords to Track"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1QU9rwawCZLiYW8nlYYRMj-9OvAUNZoe2gP49KbozQqw",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QU9rwawCZLiYW8nlYYRMj-9OvAUNZoe2gP49KbozQqw/edit?usp=drivesdk",
          "cachedResultName": "Position Tracking for Keyword + Dashboard "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "69fff95a-24de-4331-89a8-14d4ea25c066",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -460,
        -700
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "c4d31168-a21a-44ba-8cb6-a4a51167aa49",
      "name": "format fields",
      "type": "n8n-nodes-base.set",
      "position": [
        320,
        -680
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "bcca5d0b-e07d-4488-9e7f-4454bb7d2924",
              "name": "Keyword",
              "type": "string",
              "value": "={{ $('set keyword').item.json.search_term }}"
            },
            {
              "id": "d39c09ec-b94a-4d38-8ba1-5f54395186de",
              "name": "ranking page",
              "type": "string",
              "value": "={{ $json.link }}"
            },
            {
              "id": "a167b825-4324-42a5-bb16-9ae5d40b20eb",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "035f315b-1199-4e1a-bc1d-8055774cc290",
              "name": "Meta description",
              "type": "string",
              "value": "={{ $json.description }}"
            },
            {
              "id": "8c6b4298-420c-4648-9438-864ca9d9cb72",
              "name": "extensions",
              "type": "string",
              "value": "={{ $json.extensions?.toJsonString() }}"
            },
            {
              "id": "243329e0-2cae-4e75-a589-1ea098614ae5",
              "name": "position ",
              "type": "number",
              "value": "={{ $json.rank }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ee815b25-9a77-4bb5-96f8-54e26a8dcb6e",
      "name": "append ranking result",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1300,
        -680
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "position ",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "position ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ranking page",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ranking page",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Meta description",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Meta description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Keyword",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Keyword",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "extensions",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "extensions",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intent",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "intent",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "ranking page"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1031244896,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QU9rwawCZLiYW8nlYYRMj-9OvAUNZoe2gP49KbozQqw/edit#gid=1031244896",
          "cachedResultName": "Sheet2"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1QU9rwawCZLiYW8nlYYRMj-9OvAUNZoe2gP49KbozQqw",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QU9rwawCZLiYW8nlYYRMj-9OvAUNZoe2gP49KbozQqw/edit?usp=drivesdk",
          "cachedResultName": "Position Tracking for Keyword + Dashboard "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "baf30b06-9307-4c35-94f1-0c7342a08604",
      "name": "Intent Classifier",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        500,
        -720
      ],
      "parameters": {
        "options": {},
        "inputText": "=Keyword: {{  $json.Keyword}}\n\nTop pages title  : {{ $json.title }}\n\nmeta descriptions : {{ $json.description }}",
        "categories": {
          "categories": [
            {
              "category": "Informational",
              "description": "=The user wants to learn something (e.g., guides, tutorials, definitions)"
            },
            {
              "category": "Navigational",
              "description": "The user is looking for a specific brand or website."
            },
            {
              "category": "Commercial",
              "description": "=The user is researching products/services before making a purchase."
            },
            {
              "category": "Transactional",
              "description": "=The user is ready to take action or make a purchase (e.g., sign up, buy, download)."
            },
            {
              "category": "Mixed",
              "description": "=If results show multiple types equally (e.g., some blogs, some product pages)."
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "430917d7-75ea-481b-ae98-f11997f97863",
      "name": "Google Gemini Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        520,
        -480
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2cd17548-dc51-4b6a-a13f-ee3c60146412",
      "name": "informational",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        -1000
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f02fd6cc-9d46-47a0-9e65-cf0436c92ae7",
              "name": "intent",
              "type": "string",
              "value": "informational"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "1b6604e2-aefb-4c5b-929c-633161b0871b",
      "name": "Navigational",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        -840
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f02fd6cc-9d46-47a0-9e65-cf0436c92ae7",
              "name": "intent",
              "type": "string",
              "value": "Navigational"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "b4bd39b8-ae9d-4a6a-9cdb-3cdb86b218eb",
      "name": "Commercial",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        -680
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f02fd6cc-9d46-47a0-9e65-cf0436c92ae7",
              "name": "intent",
              "type": "string",
              "value": "Commercial"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "60e4efd2-52cc-44cb-9f6f-541a187364f0",
      "name": "Transactional",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        -540
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f02fd6cc-9d46-47a0-9e65-cf0436c92ae7",
              "name": "intent",
              "type": "string",
              "value": "Transactional"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "6cdb9432-caff-4338-986e-ecde27f7d8bb",
      "name": "Mixed",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        -400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f02fd6cc-9d46-47a0-9e65-cf0436c92ae7",
              "name": "intent",
              "type": "string",
              "value": "Mixed"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "7d335e4f-c521-4711-9aeb-e6e4c861fc4c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        -940
      ],
      "parameters": {
        "color": 2,
        "width": 320,
        "height": 620,
        "content": "## Analyze intent of the top ranking pages \n\n- We use AI to analyze each title and its intent as informational, Commercial, transactional, navigational or Mixed in the case it doesn't fall into any of those\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ca13d5f0-8bbe-464b-9778-18dee7b959ea",
      "name": "Merge intents",
      "type": "n8n-nodes-base.merge",
      "position": [
        1120,
        -720
      ],
      "parameters": {
        "numberInputs": 5
      },
      "typeVersion": 3.2
    },
    {
      "id": "ad137e75-05e9-4582-981f-43f6df6becbf",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1260,
        -780
      ],
      "parameters": {
        "width": 260,
        "height": 280,
        "content": "## How it works\n\n- We add our keywords and country code to a G sheet that we need to monitor and research on\n- Run the system\n- Scrape the top 10 pages\n- Analyze the intents of the top 10 and update to a G sheet\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ad89de82-a005-4851-8c40-102b83f3c912",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -740,
        -820
      ],
      "parameters": {
        "width": 220,
        "height": 320,
        "content": "- Make a copy of this [G sheet](https://docs.google.com/spreadsheets/d/1QU9rwawCZLiYW8nlYYRMj-9OvAUNZoe2gP49KbozQqw/edit?usp=sharing)\n\n- Add your desired keywords"
      },
      "typeVersion": 1
    },
    {
      "id": "571a1981-a9f3-4b66-8c9f-3d4779425df6",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        -820
      ],
      "parameters": {
        "color": 5,
        "width": 200,
        "height": 340,
        "content": "- We loop over each item one at a time"
      },
      "typeVersion": 1
    },
    {
      "id": "5b39d950-56e9-4069-81f0-8a061a56795d",
      "name": "set keyword",
      "type": "n8n-nodes-base.set",
      "position": [
        -180,
        -680
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cee3c6fe-dc44-43b2-9243-a1f1a62f9fa1",
              "name": "search_term",
              "type": "string",
              "value": "={{ $json.Keyword }}"
            },
            {
              "id": "3c58a493-6d15-4b90-bc5a-154d6f6d6474",
              "name": "country code",
              "type": "string",
              "value": "={{ $json['country code'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "72f54c66-32df-45a4-8b1d-84a02cc7c4b8",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -800
      ],
      "parameters": {
        "color": 4,
        "width": 340,
        "height": 320,
        "content": "- Map keyword and country code \n- Update the Zone name to match your zone on Bright Data\n- Run the scraper"
      },
      "typeVersion": 1
    },
    {
      "id": "336c7e9e-6d26-46d4-96b6-ebbcea39411b",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        -460
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 280,
        "content": "## Setting up SERP scraper in Bright Data\n\n1. On Bright Data, go to the [Proxies & Scraping](https://brightdata.com/cp/zones) tab\n2. Under SERP API, create a new zone\n3. Give it a suitable name and description. The default is `serp_api`\n3. Add this to your account\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "bb416232-7254-499e-98e5-6495ebd35e8d",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        840,
        -1060
      ],
      "parameters": {
        "color": 6,
        "width": 200,
        "height": 820,
        "content": "- Set intent field name for each path or output"
      },
      "typeVersion": 1
    },
    {
      "id": "24866dbb-0b4f-4f36-8ed6-a474b51455ac",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1260,
        -780
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "- Append the top pages to the G sheet for further analysis"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Mixed": {
      "main": [
        [
          {
            "node": "Merge intents",
            "type": "main",
            "index": 4
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "format fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Commercial": {
      "main": [
        [
          {
            "node": "Merge intents",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "set keyword": {
      "main": [
        [
          {
            "node": "Fetch Google Search Results JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Keywords": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Navigational": {
      "main": [
        [
          {
            "node": "Merge intents",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge intents": {
      "main": [
        [
          {
            "node": "append ranking result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transactional": {
      "main": [
        [
          {
            "node": "Merge intents",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "format fields": {
      "main": [
        [
          {
            "node": "Intent Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "informational": {
      "main": [
        [
          {
            "node": "Merge intents",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "set keyword",
            "type": "main",
            "index": 0
          },
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Intent Classifier": {
      "main": [
        [
          {
            "node": "informational",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Navigational",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Commercial",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Transactional",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mixed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Intent Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Google Search Results JSON": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Get Keywords",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}