{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "63865e5c-9e83-49ad-8d51-02391ee9e36c",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1536,
        1536
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e935f831-25e0-4325-b0a4-72dd632c6c46",
      "name": "Fetch Google Search Results JSON",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        -512,
        1616
      ],
      "parameters": {
        "url": "https://api.brightdata.com/request",
        "method": "POST",
        "options": {
          "batching": {
            "batch": {}
          },
          "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(\" \", \"+\")}}s&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": "ee4881f0-9148-493e-825e-ce2dde83fbae",
      "name": "Get Keywords",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1312,
        1536
      ],
      "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": [
        -928,
        1536
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "ad89de82-a005-4851-8c40-102b83f3c912",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1584,
        1440
      ],
      "parameters": {
        "width": 200,
        "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": [
        -1360,
        1440
      ],
      "parameters": {
        "color": 5,
        "width": 200,
        "height": 324,
        "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": [
        -704,
        1616
      ],
      "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": [
        -992,
        1472
      ],
      "parameters": {
        "color": 4,
        "width": 628,
        "height": 368,
        "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": [
        -576,
        1872
      ],
      "parameters": {
        "color": 7,
        "width": 300,
        "height": 264,
        "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"
      },
      "typeVersion": 1
    },
    {
      "id": "b5c69402-333d-4b03-a010-1ae32ac1effe",
      "name": "ads found",
      "type": "n8n-nodes-base.set",
      "position": [
        -160,
        1536
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0ccd2982-a41f-4469-a819-ee60adc0b4fe",
              "name": "top_ads",
              "type": "array",
              "value": "={{ $json.top_ads }}"
            },
            {
              "id": "bb089ad0-5f59-46a4-8df7-c0004fb9d66d",
              "name": "bottom_ads",
              "type": "array",
              "value": "={{ $json.bottom_ads }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ae34e2d9-17ec-4013-a1cc-1ed7b1adfcae",
      "name": "No Operation, do nothing1",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -320,
        1680
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a8fd8664-66e6-4e90-9948-7205df495549",
      "name": "Split ads",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        256,
        832
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "bottom_ads, top_ads"
      },
      "typeVersion": 1
    },
    {
      "id": "20cde328-1f21-4b60-ab18-1c65d5d0a659",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        432,
        832
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "58b497a1-1135-41c2-90c8-63551460576b",
              "name": "keyword",
              "type": "string",
              "value": "Business automations"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "c7056da4-4460-4475-8be5-9f0b76ec7ebd",
      "name": "Top ads",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        624,
        832
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "link",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "display_link",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "display_link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "referral_link",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "referral_link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "description",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "extensions",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "extensions",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rank",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "global_rank",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "global_rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "keyword",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "keyword",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "referral_link"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 93452282,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1QU9rwawCZLiYW8nlYYRMj-9OvAUNZoe2gP49KbozQqw/edit#gid=93452282",
          "cachedResultName": "Top ads"
        },
        "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": "3a7aadbf-fcd2-4291-88cd-4d8b22db7533",
      "name": "Filter1",
      "type": "n8n-nodes-base.filter",
      "position": [
        -1136,
        1536
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "758ff896-f5c7-4bcf-bd47-661638ef1a3e",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.Keyword }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "212244ea-466c-462a-a3c8-60d048dfa91c",
      "name": "extract ads",
      "type": "n8n-nodes-base.code",
      "position": [
        16,
        1536
      ],
      "parameters": {
        "jsCode": "const topAds = $json.top_ads || [];\nconst bottomAds = $json.bottom_ads || [];\n\n// Combine both ad arrays\nconst allAds = [...topAds, ...bottomAds];\n\n// Return each ad as a separate item\nreturn allAds.map(ad => ({ json: ad }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "838d232e-a100-4c2a-9da2-e9f4d3e6fa56",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        384,
        1328
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9e4e6644-2928-4baf-a691-2927d1e29ab2",
      "name": "Value Proposition & Messaging Analysis",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        480,
        1184
      ],
      "parameters": {
        "text": "={{ $json.data .toJsonString()}}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=You are an expert in advertising psychology and copywriting analysis.\n\nYou will be given JSON data for one or more Google Ads, including `title`, `description`, and possibly `extensions`.\n\nYour job is to analyze and extract structured insights about the advertiser's messaging style and strategy.\n\nFor each ad:\n\n1. Identify the **core value proposition** (what are they offering and to whom?).\n2. Classify the tone as one or more of: \n   - **Emotional hook** (e.g., fear, trust, urgency, hope)\n   - **Rational benefit** (e.g., affordability, proven ROI, features)\n3. Detect the presence of marketing claims or persuasive devices such as:\n   - Guarantees (\u201cwe guarantee\u201d, \u201cmoney back\u201d)\n   - Results-focused (\u201cget more traffic\u201d, \u201cincrease conversions\u201d)\n   - Authority/credibility (\u201caward-winning\u201d, \u201ctop-rated\u201d)\n4. Extract common phrase patterns (e.g., \u201cYour satisfaction guaranteed\u201d, \u201cIn a market full of stars\u2026\u201d)\n\nOutput format should be JSON with fields:\n\n```json\n{\n  \"advertiser\": \"<display_link or domain>\",\n  \"value_proposition\": \"<summary of their offer>\",\n  \"tone\": [\"trust\", \"urgency\", \"rational\"],\n  \"messaging_features\": [\"guarantee\", \"ROI\", \"authority\"],\n  \"common_phrases\": [\"Your satisfaction guaranteed\", \"We'll make yours shine the brightest\"]\n}\n"
            }
          ]
        },
        "promptType": "define",
        "needsFallback": true,
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "fa3075a7-f634-4ed0-bdba-c568e1b6ad15",
      "name": "Structured Output Parser3",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        704,
        1328
      ],
      "parameters": {
        "jsonSchemaExample": "[{\n  \"advertiser\": \"<display_link or domain>\",\n  \"value_proposition\": \"<summary of their offer>\",\n  \"tone\": [\"trust\", \"urgency\", \"rational\"],\n  \"messaging_features\": [\"guarantee\", \"ROI\", \"authority\"],\n  \"common_phrases\": [\"Your satisfaction guaranteed\", \"We'll make yours shine the brightest\"]\n}]"
      },
      "typeVersion": 1.3
    },
    {
      "id": "cd203873-2ec3-4976-95a5-b5feeb931c39",
      "name": "Google Gemini Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        544,
        1328
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "001407eb-a551-4db7-8f8d-adf3f1a4bb61",
      "name": "extensions",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        272,
        1536
      ],
      "parameters": {
        "include": "allFieldsExcept",
        "options": {},
        "aggregate": "aggregateAllItemData",
        "fieldsToExclude": "referral_link, image, image_base64, rank, global_rank, image_alt"
      },
      "typeVersion": 1
    },
    {
      "id": "705e7655-6498-422d-a3b8-fd13ec908738",
      "name": "OpenRouter Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        400,
        1664
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e5885d75-c08a-46a2-b6dc-bf6df5927524",
      "name": "Google Gemini Chat Model4",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        544,
        1664
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7d60db99-e815-4463-b462-da17e9a92b6e",
      "name": "Structured Output Parser4",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        688,
        1664
      ],
      "parameters": {
        "jsonSchemaExample": "[{\n  \"advertiser\": \"<display_link or domain>\",\n  \"value_proposition\": \"<summary of their offer>\",\n  \"tone\": [\"trust\", \"urgency\", \"rational\"],\n  \"messaging_features\": [\"guarantee\", \"ROI\", \"authority\"],\n  \"common_phrases\": [\"Your satisfaction guaranteed\", \"We'll make yours shine the brightest\"]\n}]"
      },
      "typeVersion": 1.3
    },
    {
      "id": "9b19ae21-488c-4a6e-b033-2b710cb418c9",
      "name": "Site Link Extension Mining",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        496,
        1536
      ],
      "parameters": {
        "text": "={{ $json.data.toJsonString() }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=You are a digital marketing analyst specializing in ad funnels and call-to-action strategies.\n\nYou will be provided with JSON ad data including `extensions` where each extension may be of type `site_link`.\n\nYour task is to:\n\n1. Extract all `site_link` extensions and list their link text + destination.\n2. Categorize each link by destination type:\n   - \"service\", \"landing page\", \"blog\", \"pricing\", \"case study\", \"contact\", \"grant\", etc.\n3. Detect if the link contains tracking or UTM parameters.\n4. Identify patterns in CTA strategies across ads (e.g., are most advertisers linking to grants, blog content, or specific services?)\n\nOutput format should be:\n\n```json\n[{\n  \"advertiser\": \"<display_link or domain>\",\n  \"site_links\": [\n    {\n      \"text\": \"SEO Services\",\n      \"url\": \"https://www.tryboostlocal.com/marketing-services/seo/\",\n      \"type\": \"service\",\n      \"has_utm\": false\n    },\n    ...\n  ],\n  \"cta_focus\": [\"services\", \"grants\", \"conversion-optimized pages\"]\n}]\n"
            }
          ]
        },
        "promptType": "define",
        "needsFallback": true,
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "5d07433c-1892-4d2f-8bbe-6ca3753374b5",
      "name": "OpenRouter Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        400,
        2000
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "94d1a201-2138-4722-a8de-7d7f95e4368d",
      "name": "Google Gemini Chat Model5",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        544,
        2000
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ab48beae-bba6-4784-98bd-430d51de37df",
      "name": "Structured Output Parser5",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        704,
        2000
      ],
      "parameters": {
        "jsonSchemaExample": "[{\n  \"keyword\": \"Business automation\",\n  \"ads\": [\n    {\n      \"advertiser\": \"tryboostlocal.com\",\n      \"title\": \"SEO Agency | We Guarantee Results\",\n      \"value_proposition\": \"Full-service SEO with results guarantee\",\n      \"core_focus\": \"SEO services for local businesses\"\n    }\n  ],\n  \"related_keywords_cluster\": [\"workflow automation\", \"small business automation\"],\n  \"notable_differences\": \"Business automation ads focus on SEO; workflow automation ads focus on tools or software.\"\n}]"
      },
      "typeVersion": 1.3
    },
    {
      "id": "91808a62-8de4-4217-b4f1-de6c0184225a",
      "name": "keywords",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        272,
        1856
      ],
      "parameters": {
        "include": "allFieldsExcept",
        "options": {},
        "aggregate": "aggregateAllItemData",
        "fieldsToExclude": "referral_link, image, image_base64, rank, global_rank, image_alt"
      },
      "typeVersion": 1
    },
    {
      "id": "55dd1a7e-8093-4c26-8d6e-3ac01dc0d63d",
      "name": "Keyword-Ad Mapping",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        496,
        1856
      ],
      "parameters": {
        "text": "=keyword: {{ $('set keyword').item.json.search_term }}\n\nAds : {{ $json.data.toJsonString() }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=\nYou are a search engine marketing analyst.\n\nYou are provided with JSON ad data including the `keyword` that triggered the ad and the full ad metadata.\n\nYour task is to:\n\n1. For each ad, map the keyword to:\n   - The advertiser (display_link or domain)\n   - The ad's value proposition or theme\n2. Compare ads across keywords:\n   - Identify if advertisers reuse the same ad across multiple keywords\n   - Highlight differences in messaging per keyword\n\n3. Identify and cluster related keywords (e.g., \"business automation\", \"workflow automation\") and how their associated ads differ.\n\nReturn a structured summary like:\n\n```json\n[{\n  \"keyword\": \"Business automation\",\n  \"ads\": [\n    {\n      \"advertiser\": \"tryboostlocal.com\",\n      \"title\": \"SEO Agency | We Guarantee Results\",\n      \"value_proposition\": \"Full-service SEO with results guarantee\",\n      \"core_focus\": \"SEO services for local businesses\"\n    }\n  ],\n  \"related_keywords_cluster\": [\"workflow automation\", \"small business automation\"],\n  \"notable_differences\": \"Business automation ads focus on SEO; workflow automation ads focus on tools or software.\"\n}]"
            }
          ]
        },
        "promptType": "define",
        "needsFallback": true,
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "37950c2a-29a4-4609-b1f1-e9b2436abad9",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        1136,
        1520
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "6619a377-6fb1-49d6-9467-50399edd2b11",
      "name": "value proposition",
      "type": "n8n-nodes-base.set",
      "position": [
        848,
        1184
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a3133a95-ab56-4ec7-a190-d31447f38192",
              "name": "value proposition",
              "type": "array",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f77d059b-464b-4036-9429-51b45f8278ce",
      "name": "site links",
      "type": "n8n-nodes-base.set",
      "position": [
        864,
        1536
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a3133a95-ab56-4ec7-a190-d31447f38192",
              "name": "site links",
              "type": "array",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7ae035de-42dc-496c-8700-7448b11acd5c",
      "name": "keywords1",
      "type": "n8n-nodes-base.set",
      "position": [
        864,
        1856
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a3133a95-ab56-4ec7-a190-d31447f38192",
              "name": "keywords",
              "type": "array",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ab74a2a8-6a19-4635-84c6-e3a76c1b801b",
      "name": "Google Gemini Chat Model6",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1504,
        1712
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4e8de21c-b9ff-4acd-bb69-f79ac28f27d1",
      "name": "OpenRouter Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1328,
        1712
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "766b1ee4-c6a2-406e-954d-819394793c5e",
      "name": "Generate HTML",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1360,
        1536
      ],
      "parameters": {
        "text": "={{ $json.toJsonString() }}",
        "options": {
          "systemMessage": "=You are a senior marketing analyst tasked with generating clear, insightful email reports from structured JSON ad intelligence data.\n\nThe input will include 3 major sections:\n1. value proposition & messaging analysis\n2. site link insights\n3. keyword-to-ad mapping\n\nYour job is to write an **HTML-formatted email body** (not plain text), focusing on clarity, structure, and highlighting useful patterns, trends, and strategic insights.\n\n**Requirements:**\n- No greetings or closings; just the body.\n- Use `<h2>`, `<ul>`, `<p>`, `<strong>`, and styled `<div>`s for clarity.\n- Group insights advertiser-by-advertiser.\n- Highlight value propositions, tones, messaging devices, and common phrases.\n- Break down site link strategies per advertiser.\n- Analyze keyword mapping per keyword, with competitive comparisons.\n- Summarize notable differences and strategic positioning.\n- Close with a quick recap of key marketing trends observed.\n\nThe tone should be professional and analytical. Keep sections distinct and easy to scan. Use bullet points where appropriate. Ensure it can be pasted into a marketing performance report email.\n\nThe report is intended for an admin or strategist.\n\nGenerate only the HTML block \u2014 no Markdown or narrative explanation.\n"
        },
        "promptType": "define",
        "needsFallback": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "f992ddf2-40ca-4a10-b3d0-98b092ae5bd7",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1680,
        1536
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "={{ $json.output }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "=Ads overview report for the Keyword [{{ $('set keyword').item.json.search_term }}]"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "41352ed2-238c-4a54-89f1-48fa388810b5",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        1040
      ],
      "parameters": {
        "width": 784,
        "height": 1104,
        "content": "## AI processing of the top ads\n\nThese ai steps analyze and extract different results from the top and bottom ads found on the given page per keyword"
      },
      "typeVersion": 1
    },
    {
      "id": "ceb1e065-f94e-4e5f-8ebc-b40cbd55b1b0",
      "name": "value proposition1",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        256,
        1184
      ],
      "parameters": {
        "include": "allFieldsExcept",
        "options": {},
        "aggregate": "aggregateAllItemData",
        "fieldsToExclude": "referral_link, image, image_base64"
      },
      "typeVersion": 1
    },
    {
      "id": "10159971-ef5d-40f4-9ead-a7d892eef2e5",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        1488
      ],
      "parameters": {
        "width": 688,
        "height": 384,
        "content": "## Generate HTML from insights"
      },
      "typeVersion": 1
    },
    {
      "id": "ebc80312-4609-4921-afae-2cc5c6320b60",
      "name": "filter ads",
      "type": "n8n-nodes-base.filter",
      "position": [
        -336,
        1536
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5aeed586-2e55-4986-9e79-536c42f6ad82",
              "operator": {
                "type": "array",
                "operation": "lengthGte",
                "rightType": "number"
              },
              "leftValue": "={{ $json.top_ads }}",
              "rightValue": 1
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a96db7fd-ca88-45e8-b2ce-b727f831d4e5",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        1136
      ],
      "parameters": {
        "color": 5,
        "width": 560,
        "height": 192,
        "content": "## Extract the value proposition and message"
      },
      "typeVersion": 1
    },
    {
      "id": "dce257ac-0d7b-4b88-9d69-663bd4778602",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        352,
        1488
      ],
      "parameters": {
        "color": 4,
        "width": 560,
        "height": 192,
        "content": "## Extract Insights from Sitelinks ad extensions"
      },
      "typeVersion": 1
    },
    {
      "id": "daf5307a-0098-4119-a17d-c2ff7555624b",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        1808
      ],
      "parameters": {
        "color": 6,
        "width": 560,
        "height": 192,
        "content": "## Keyword mapping"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Merge1": {
      "main": [
        [
          {
            "node": "Generate HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "keywords": {
      "main": [
        [
          {
            "node": "Keyword-Ad Mapping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split ads": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ads found": {
      "main": [
        [
          {
            "node": "extract ads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "keywords1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "extensions": {
      "main": [
        [
          {
            "node": "Site Link Extension Mining",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "filter ads": {
      "main": [
        [
          {
            "node": "ads found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "site links": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Top ads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "extract ads": {
      "main": [
        [
          {
            "node": "value proposition1",
            "type": "main",
            "index": 0
          },
          {
            "node": "extensions",
            "type": "main",
            "index": 0
          },
          {
            "node": "keywords",
            "type": "main",
            "index": 0
          },
          {
            "node": "Split ads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set keyword": {
      "main": [
        [
          {
            "node": "Fetch Google Search Results JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Keywords": {
      "main": [
        [
          {
            "node": "Filter1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate HTML": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "set keyword",
            "type": "main",
            "index": 0
          },
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "value proposition": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keyword-Ad Mapping": {
      "main": [
        [
          {
            "node": "keywords1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "value proposition1": {
      "main": [
        [
          {
            "node": "Value Proposition & Messaging Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Value Proposition & Messaging Analysis",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Site Link Extension Mining",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Keyword-Ad Mapping",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Generate HTML",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Value Proposition & Messaging Analysis",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "Google Gemini Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "Site Link Extension Mining",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "Google Gemini Chat Model5": {
      "ai_languageModel": [
        [
          {
            "node": "Keyword-Ad Mapping",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "Google Gemini Chat Model6": {
      "ai_languageModel": [
        [
          {
            "node": "Generate HTML",
            "type": "ai_languageModel",
            "index": 1
          }
        ]
      ]
    },
    "Structured Output Parser3": {
      "ai_outputParser": [
        [
          {
            "node": "Value Proposition & Messaging Analysis",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser4": {
      "ai_outputParser": [
        [
          {
            "node": "Site Link Extension Mining",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser5": {
      "ai_outputParser": [
        [
          {
            "node": "Keyword-Ad Mapping",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Site Link Extension Mining": {
      "main": [
        [
          {
            "node": "site links",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Google Search Results JSON": {
      "main": [
        [
          {
            "node": "filter ads",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Get Keywords",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Value Proposition & Messaging Analysis": {
      "main": [
        [
          {
            "node": "value proposition",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}