{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "1849d161-5e20-4984-b257-d4beba8d3984",
      "name": "OpenAI Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2240,
        2560
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "56bcccd4-b43b-4614-af68-965f006f4442",
      "name": "Structured Output Parser2",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2420,
        2600
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"email\": \"emailaddress\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "cec08431-626d-42c3-9ad4-ef76dc5954b9",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "onError": "continueRegularOutput",
      "position": [
        1720,
        2400
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "a523d13f-653d-4a91-a672-b0bd5d558f27",
      "name": "Run Workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1060,
        2840
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "46962894-9e74-4fec-a1f4-14b28ee824b1",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        2420
      ],
      "parameters": {
        "color": 5,
        "width": 500,
        "height": 640,
        "content": "## \ud83d\udee0\ufe0f Step-by-Step Setup & Execution\n\n### 1\ufe0f\u20e3 Run Workflow (Manual Trigger)\n- **Node**: `Run Workflow`  \n- **Type**: Manual Trigger  \n- **Purpose**: Kick off the flow on demand.\n\n---\n\n### 2\ufe0f\u20e3 Set Your Topic\n- **Node**: `Set Topic`  \n- **Type**: Set  \n- **Prerequisite**: None  \n- **Configuration**:  \n  - Add field **Topic** (string)  \n  - Value: e.g. `\"n8n\"`\n\n---"
      },
      "typeVersion": 1
    },
    {
      "id": "6d4a9f51-0ab5-43f9-888a-2ffd9fec5792",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        2240
      ],
      "parameters": {
        "color": 3,
        "width": 1840,
        "height": 820,
        "content": "### 7\ufe0f\u20e3 Loop Over Each URL\n- **Node**: `Loop Over Items1`  \n- **Type**: SplitInBatches  \n- **Purpose**: Process one URL at a time  \n- **Error Handling**: `onError: continueRegularOutput`\n\n---\n\n### 8\ufe0f\u20e3 Scrape Page Content with Apify\n- **Node**: `Scrape URL with apify`  \n- **Type**: HTTP Request  \n- **Prerequisite / API Setup**:  \n  1. Sign up at https://console.apify.com/  \n  2. Create an API token (Account \u2192 API tokens)  \n  3. In n8n: **Credentials \u2192 New \u2192 HTTP Query Auth**, set query param `token=YOUR_TOKEN`  \n- **Request**:  \n  - Method: POST  \n  - URL: `https://api.apify.com/v2/acts/6sigmag~fast-website-content-crawler/run-sync-get-dataset-items`  \n  - Body (JSON):  \n    ```json\n    {\n      \"startUrls\": [\"{{ $json.link }}\"]\n    }\n    ```\n\n---\n\n### 9\ufe0f\u20e3 Extract Email Address via AI\n- **Node**: `Extract Email from webpage`  \n- **Type**: LangChain Agent  \n- **Prerequisite / API Setup**:  \n  1. Create OpenAI API key at https://platform.openai.com/account/api-keys  \n  2. In n8n: **Credentials \u2192 New \u2192 OpenAI API**, paste key as **OpenAi account**  \n- **Prompt**:"
      },
      "typeVersion": 1
    },
    {
      "id": "e0dcc28a-b52e-4622-b7bd-e89bf3e132dc",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        2240
      ],
      "parameters": {
        "color": 6,
        "width": 1320,
        "height": 820,
        "content": "\n### 3\ufe0f\u20e3 Search Google Results (1\u201310)\n- **Node**: `Search Google (top 10)`  \n- **Type**: SerpAPI  \n- **Prerequisite / API Setup**:  \n  1. Sign up at https://serpapi.com/  \n  2. Copy your API key  \n  3. In n8n: **Credentials \u2192 New \u2192 SerpAPI**, paste key as **SerpAPI account**  \n- **Parameters**:  \n  - `q`: `={{ $json.Topic }} Expert`  \n  - `location`: your region code (e.g., `\"585069efee19ad271e9c9b36\"`)  \n  - `additionalFields.start`: `\"10\"` (for results 1\u201310)\n\n---\n\n### 4\ufe0f\u20e3 Search Google Results (11\u201320)\n- **Node**: `Search Google (11-20)`  \n- **Type**: SerpAPI  \n- **Prerequisite**: Uses same **SerpAPI account** credential  \n- **Parameters**:  \n  - `q`: `={{ $json.Topic }} Expert`  \n  - `location`: same as above  \n  - omit `start` or set for results 11\u201320\n\n---\n\n### 5\ufe0f\u20e3 Extract URLs from Responses\n- **Nodes**: `Extract Url` & `Extract Url 2`  \n- **Type**: Code  \n- **Purpose**: Parse `organic_results` to JSON items with `title`, `link`, and `displayed_link`  \n- **Configuration**: Use JavaScript to map `data.organic_results` accordingly.\n\n---\n\n### 6\ufe0f\u20e3 Combine Both Result Sets\n- **Node**: `Append Results`  \n- **Type**: Merge (combineAll)  \n- **Purpose**: Merge arrays from top 10 and 11\u201320 searches into one list.\n\n---\n"
      },
      "typeVersion": 1
    },
    {
      "id": "be1e7afd-b791-43ab-94be-daf8c23b01b0",
      "name": "Set Topic",
      "type": "n8n-nodes-base.set",
      "position": [
        -820,
        2860
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "04f4cbfd-8d9c-4b12-aed0-ec8cea84944d",
              "name": "Topic",
              "type": "string",
              "value": "n8n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e14ad342-76a7-4227-a950-d45cc345867f",
      "name": "Search Google (top 10)",
      "type": "n8n-nodes-serpapi.serpApi",
      "onError": "continueRegularOutput",
      "position": [
        60,
        2400
      ],
      "parameters": {
        "q": "={{ $json.Topic }} Expert",
        "location": "585069efee19ad271e9c9b36",
        "requestOptions": {},
        "additionalFields": {
          "start": "10"
        }
      },
      "credentials": {
        "serpApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8b11f8ed-8a6f-42dc-82d1-4fa6e6a7fd1e",
      "name": "Search Google (11-20)",
      "type": "n8n-nodes-serpapi.serpApi",
      "onError": "continueRegularOutput",
      "position": [
        40,
        2620
      ],
      "parameters": {
        "q": "={{ $json.Topic }} Expert",
        "location": "585069efee19ad271e9c9b36",
        "requestOptions": {},
        "additionalFields": {}
      },
      "credentials": {
        "serpApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4a0122a6-3ac2-4d0b-97fa-fe369ca9c638",
      "name": "Extract Url",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        240,
        2620
      ],
      "parameters": {
        "jsCode": "// Get JSON input\nconst data = $input.first().json;\n\n// Extract organic results\nconst results = data.organic_results || [];\n\nconst output = results.map(result => {\n  return {\n    json: {\n      title: result.title || \"\",\n      link: result.link || \"\",\n      displayed_link: result.displayed_link || \"\"\n    }\n  };\n});\n\nreturn output;\n"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "3f92ad79-4829-43cd-8a99-578df75e259b",
      "name": "Extract Url 2",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        240,
        2820
      ],
      "parameters": {
        "jsCode": "// Get JSON input\nconst data = $input.first().json;\n\n// Extract organic results\nconst results = data.organic_results || [];\n\nconst output = results.map(result => {\n  return {\n    json: {\n      title: result.title || \"\",\n      link: result.link || \"\",\n      displayed_link: result.displayed_link || \"\"\n    }\n  };\n});\n\nreturn output;\n"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "da2c21e0-7d55-4bc6-a695-ed911ebc6713",
      "name": "Append Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        500,
        2680
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "10774467-0641-4dc5-875b-7a8d5680baa5",
      "name": "Scrape URL with apify",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        2000,
        2440
      ],
      "parameters": {
        "url": "=https://api.apify.com/v2/acts/6sigmag~fast-website-content-crawler/run-sync-get-dataset-items\n",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"startUrls\": [\n        \"{{ $json.link }}\"\n    ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth"
      },
      "credentials": {
        "httpQueryAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "dcdd0bba-3379-40d3-9d6c-893f0fe8539b",
      "name": "Extract Email from webpage",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "onError": "continueRegularOutput",
      "position": [
        2240,
        2380
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "extract the email address from the text. if there is no email address, output null. "
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "bea6d164-80bd-4f6c-883f-fa50557bb578",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        2240
      ],
      "parameters": {
        "width": 500,
        "content": "## \ud83d\udcec Need Help or Want to Customize This?\n\ud83d\udce7 [robert@ynteractive.com](mailto:robert@ynteractive.com)  \n\ud83d\udd17 [LinkedIn](https://www.linkedin.com/in/robert-breen-29429625/)"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Set Topic": {
      "main": [
        [
          {
            "node": "Search Google (top 10)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Search Google (11-20)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Url": {
      "main": [
        [
          {
            "node": "Append Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Workflow": {
      "main": [
        [
          {
            "node": "Set Topic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Url 2": {
      "main": [
        [
          {
            "node": "Append Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Append Results": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [],
        [
          {
            "node": "Scrape URL with apify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Extract Email from webpage",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Scrape URL with apify": {
      "main": [
        [
          {
            "node": "Extract Email from webpage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Google (11-20)": {
      "main": [
        [
          {
            "node": "Extract Url 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Google (top 10)": {
      "main": [
        [
          {
            "node": "Extract Url",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser2": {
      "ai_outputParser": [
        [
          {
            "node": "Extract Email from webpage",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Extract Email from webpage": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}