Google Search - Lead Gen - LinkedIn

    { "nodes": [ { "parameters": { "rule": { "interval": [ {} ] } }, "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [ -608, -976 ], "id": "3c669910-a295-4b14-80eb-fa728771efe4", "name": "Schedule Trigger" }, { "parameters": { "authentication": "serviceAccount", "operation": "append", "documentId": { "__rl": true, "value": "1mLzrKkvKr-RrGRzGBa2XtAoUiPwcy5i6DATlQbwW0BI", "mode": "list", "cachedResultName": "linkedin_leads", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mLzrKkvKr-RrGRzGBa2XtAoUiPwcy5i6DATlQbwW0BI/edit?usp=drivesdk" }, "sheetName": { "__rl": true, "value": 2094797344, "mode": "list", "cachedResultName": "fouders_dubai", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mLzrKkvKr-RrGRzGBa2XtAoUiPwcy5i6DATlQbwW0BI/edit#gid=2094797344" }, "columns": { "mappingMode": "autoMapInputData", "value": null, "matchingColumns": [], "schema": [], "attemptToConvertTypes": false, "convertFieldsToString": false }, "options": {} }, "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.5, "position": [ 512, -1040 ], "id": "ef5434be-dd3a-4fa7-a78c-2e0385a46014", "name": "Add to Sheet", "alwaysOutputData": true, "credentials": { "googleApi": { "id": "H4QBs8rB8FP7PZBN", "name": "Google Sheets account" } } }, { "parameters": { "url": "https://customsearch.googleapis.com/customsearch/v1", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "key", "value": "AIzaSyB4KMi5T67hl7vzY6LuCes44UjzyLC7ozw" }, { "name": "cx", "value": "854982e4b45874332" }, { "name": "q", "value": "Founder OR CEO OR Project Manager OR CTO Tech Dubai site:linkedin.com dubai" }, { "name": "start", "value": "={{ ($runIndex*10)+1 }}" } ] }, "sendHeaders": true, "headerParameters": { "parameters": [ {} ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ -160, -1056 ], "id": "1066a45d-1c7b-485f-b23d-8f4a740750b7", "name": "Search Google" }, { "parameters": { "amount": 2.5 }, "type": "n8n-nodes-base.wait", "typeVersion": 1.1, "position": [ 288, -1040 ], "id": "7513e547-893f-46d3-9759-c88e6b99ce3c", "name": "Wait", "webhookId": "7931db91-e6e7-46cb-b097-419a32dfa3c3" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 }, "conditions": [ { "id": "faef2862-80a4-465b-9e0b-be5b9753dcbd", "leftValue": "={{ $json.continueLoop }}", "rightValue": "true", "operator": { "type": "boolean", "operation": "true", "singleValue": true } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [ 960, -1040 ], "id": "cf256ce2-7147-474c-9555-182c0d5e4d02", "name": "Pagination Check" }, { "parameters": { "jsCode": "const inputItems = $input.all();\n\n\n// let nextStartIndex = 1;\n// let hasMoreResults = false;\n\n// if (inputItems && inputItems.length > 0) {\n// const firstItem = inputItems[0].json;\n\n// if (firstItem.startIndex !== undefined) {\n// nextStartIndex = firstItem.startIndex;\n// }\n\n// if (firstItem.hasMoreResults !== undefined) {\n// hasMoreResults = firstItem.hasMoreResults;\n// }\n// }\n\nreturn {\n json: {\n continueLoop:inputItems[inputItems.length-1].json.hasMoreResults,\n startIndex: inputItems[inputItems.length-1].json.itemIndex+1 ,\n pageNumber: inputItems[inputItems.length-1].json.pageNumber,\n }\n};\n" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 736, -1040 ], "id": "7e933840-e10b-40a3-b6bb-9ef4f59a059a", "name": "Pagination" }, { "parameters": { "jsCode": "// Get the response data\nconst response = $input.first().json;\nconst items = response.items || [];\nconst item_count = response.queries.request[0].count;\nconst startIndex = response.queries.request[0].startIndex;\nconst pageNumber_ = Math.floor((response.queries.request[0].startIndex - 1) / 10) + 1;\n// Track pagination info\nlet nextStartIndex = 1;\n\nif (response.queries.nextPage[0]) {\nnextStartIndex = response.queries.nextPage[0].startIndex;\n} //Get the start index of the next page if any. \n\n// Calculate if we should continue (Google only allows up to 100 results)\nconst hasMoreResults = nextStartIndex <= 100;\n\n// Process the items and include pagination info in each item\nconst results = items.map((item,index) => {\n const titleParts = item.title.split(\" - \");\n return {\n name: titleParts[0] || null,\n title: titleParts.slice(1).join(\" - \") || null,\n link: item.link || null,\n snippet: item.snippet || null,\n image: item.pagemap?.cse_thumbnail?.[0]?.src || null,\n // Add pagination info to each item\n itemIndex: startIndex+index,\n hasMoreResults: hasMoreResults,\n totalSet: item_count,\n pageNumber:pageNumber_,\n };\n});\n\n// If there are no results, return at least one item with pagination info\nif (results.length === 0) {\n return [{ \n json: {\n name: null,\n title: null,\n link: null,\n snippet: null,\n image: null,\n startIndex: 101,\n hasMoreResults: false,\n pageNumber:pageNumber_,\n }\n }];\n}\n\n// Return the processed results\nreturn results.map(r => ({ json: r }));" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 64, -1040 ], "id": "2e77eac0-f4bf-4bd3-ad0f-d382b17e4f1e", "name": "Extract Results" }, { "parameters": { "assignments": { "assignments": [ { "id": "cc27b2d9-8de7-43ca-a741-2d150084f78e", "name": "currentStartIndex", "value": "=1", "type": "number" }, { "id": "fc552c57-4510-4f04-aa09-2294306d0d9f", "name": "maxPages", "value": 10, "type": "number" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -384, -976 ], "id": "00b0ec01-e51f-447d-b25f-3023540192c9", "name": "Set Fields" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 }, "conditions": [ { "id": "05ee7d79-62bd-4fed-9a08-4c0f7b445f75", "leftValue": "={{ $json.startIndex+ 9 }}", "rightValue": 1000, "operator": { "type": "number", "operation": "lte" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [ 1184, -992 ], "id": "59193a13-6719-4944-9013-0ef37f991a59", "name": "If" } ], "connections": { "Schedule Trigger": { "main": [ [ { "node": "Set Fields", "type": "main", "index": 0 } ] ] }, "Add to Sheet": { "main": [ [ { "node": "Pagination", "type": "main", "index": 0 } ] ] }, "Search Google": { "main": [ [ { "node": "Extract Results", "type": "main", "index": 0 } ] ] }, "Wait": { "main": [ [ { "node": "Add to Sheet", "type": "main", "index": 0 } ] ] }, "Pagination Check": { "main": [ [ { "node": "If", "type": "main", "index": 0 } ] ] }, "Pagination": { "main": [ [ { "node": "Pagination Check", "type": "main", "index": 0 } ] ] }, "Extract Results": { "main": [ [ { "node": "Wait", "type": "main", "index": 0 } ] ] }, "Set Fields": { "main": [ [ { "node": "Search Google", "type": "main", "index": 0 } ] ] }, "If": { "main": [ [ { "node": "Search Google", "type": "main", "index": 0 } ] ] } }, "pinData": {}, "meta": { "templateCredsSetupCompleted": true, "instanceId": "784633b34b946c52696f8bcee5aa5878daa3acd944446e0b6ac2ec35a27f3ec1" } }

    Shared 10/6/2025

    110 views

    Visual Workflow

    JSON Code

    {
      "meta": {
        "instanceId": "784633b34b946c52696f8bcee5aa5878daa3acd944446e0b6ac2ec35a27f3ec1",
        "templateCredsSetupCompleted": true
      },
      "nodes": [
        {
          "id": "3c669910-a295-4b14-80eb-fa728771efe4",
          "name": "Schedule Trigger",
          "type": "n8n-nodes-base.scheduleTrigger",
          "position": [
            -608,
            -976
          ],
          "parameters": {
            "rule": {
              "interval": [
                {}
              ]
            }
          },
          "typeVersion": 1.2
        },
        {
          "id": "ef5434be-dd3a-4fa7-a78c-2e0385a46014",
          "name": "Add to Sheet",
          "type": "n8n-nodes-base.googleSheets",
          "position": [
            512,
            -1040
          ],
          "parameters": {
            "columns": {
              "value": null,
              "schema": [],
              "mappingMode": "autoMapInputData",
              "matchingColumns": [],
              "attemptToConvertTypes": false,
              "convertFieldsToString": false
            },
            "options": {},
            "operation": "append",
            "sheetName": {
              "__rl": true,
              "mode": "list",
              "value": 2094797344,
              "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mLzrKkvKr-RrGRzGBa2XtAoUiPwcy5i6DATlQbwW0BI/edit#gid=2094797344",
              "cachedResultName": "fouders_dubai"
            },
            "documentId": {
              "__rl": true,
              "mode": "list",
              "value": "1mLzrKkvKr-RrGRzGBa2XtAoUiPwcy5i6DATlQbwW0BI",
              "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mLzrKkvKr-RrGRzGBa2XtAoUiPwcy5i6DATlQbwW0BI/edit?usp=drivesdk",
              "cachedResultName": "linkedin_leads"
            },
            "authentication": "serviceAccount"
          },
          "credentials": {
            "googleApi": {
              "id": "H4QBs8rB8FP7PZBN",
              "name": "Google Sheets account"
            }
          },
          "typeVersion": 4.5,
          "alwaysOutputData": true
        },
        {
          "id": "1066a45d-1c7b-485f-b23d-8f4a740750b7",
          "name": "Search Google",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            -160,
            -1056
          ],
          "parameters": {
            "url": "https://customsearch.googleapis.com/customsearch/v1",
            "options": {},
            "sendQuery": true,
            "sendHeaders": true,
            "queryParameters": {
              "parameters": [
                {
                  "name": "key",
                  "value": "AIzaSyB4KMi5T67hl7vzY6LuCes44UjzyLC7ozw"
                },
                {
                  "name": "cx",
                  "value": "854982e4b45874332"
                },
                {
                  "name": "q",
                  "value": "Founder OR CEO OR Project Manager OR CTO Tech Dubai site:linkedin.com dubai"
                },
                {
                  "name": "start",
                  "value": "={{ ($runIndex*10)+1 }}"
                }
              ]
            },
            "headerParameters": {
              "parameters": [
                {}
              ]
            }
          },
          "typeVersion": 4.2
        },
        {
          "id": "7513e547-893f-46d3-9759-c88e6b99ce3c",
          "name": "Wait",
          "type": "n8n-nodes-base.wait",
          "position": [
            288,
            -1040
          ],
          "webhookId": "7931db91-e6e7-46cb-b097-419a32dfa3c3",
          "parameters": {
            "amount": 2.5
          },
          "typeVersion": 1.1
        },
        {
          "id": "cf256ce2-7147-474c-9555-182c0d5e4d02",
          "name": "Pagination Check",
          "type": "n8n-nodes-base.if",
          "position": [
            960,
            -1040
          ],
          "parameters": {
            "options": {},
            "conditions": {
              "options": {
                "version": 2,
                "leftValue": "",
                "caseSensitive": true,
                "typeValidation": "strict"
              },
              "combinator": "and",
              "conditions": [
                {
                  "id": "faef2862-80a4-465b-9e0b-be5b9753dcbd",
                  "operator": {
                    "type": "boolean",
                    "operation": "true",
                    "singleValue": true
                  },
                  "leftValue": "={{ $json.continueLoop }}",
                  "rightValue": "true"
                }
              ]
            }
          },
          "typeVersion": 2.2
        },
        {
          "id": "7e933840-e10b-40a3-b6bb-9ef4f59a059a",
          "name": "Pagination",
          "type": "n8n-nodes-base.code",
          "position": [
            736,
            -1040
          ],
          "parameters": {
            "jsCode": "const inputItems = $input.all();\n\n\n// let nextStartIndex = 1;\n// let hasMoreResults = false;\n\n// if (inputItems && inputItems.length > 0) {\n//   const firstItem = inputItems[0].json;\n\n//   if (firstItem.startIndex !== undefined) {\n//     nextStartIndex = firstItem.startIndex;\n//   }\n\n//   if (firstItem.hasMoreResults !== undefined) {\n//     hasMoreResults = firstItem.hasMoreResults;\n//   }\n// }\n\nreturn {\n  json: {\n    continueLoop:inputItems[inputItems.length-1].json.hasMoreResults,\n    startIndex: inputItems[inputItems.length-1].json.itemIndex+1 ,\n    pageNumber: inputItems[inputItems.length-1].json.pageNumber,\n  }\n};\n"
          },
          "typeVersion": 2
        },
        {
          "id": "2e77eac0-f4bf-4bd3-ad0f-d382b17e4f1e",
          "name": "Extract Results",
          "type": "n8n-nodes-base.code",
          "position": [
            64,
            -1040
          ],
          "parameters": {
            "jsCode": "// Get the response data\nconst response = $input.first().json;\nconst items = response.items || [];\nconst item_count = response.queries.request[0].count;\nconst startIndex = response.queries.request[0].startIndex;\nconst pageNumber_ = Math.floor((response.queries.request[0].startIndex - 1) / 10) + 1;\n// Track pagination info\nlet nextStartIndex = 1;\n\nif (response.queries.nextPage[0]) {\nnextStartIndex = response.queries.nextPage[0].startIndex;\n} //Get the start index of the next page if any. \n\n// Calculate if we should continue (Google only allows up to 100 results)\nconst hasMoreResults = nextStartIndex <= 100;\n\n// Process the items and include pagination info in each item\nconst results = items.map((item,index) => {\n  const titleParts = item.title.split(\" - \");\n  return {\n    name: titleParts[0] || null,\n    title: titleParts.slice(1).join(\" - \") || null,\n    link: item.link || null,\n    snippet: item.snippet || null,\n    image: item.pagemap?.cse_thumbnail?.[0]?.src || null,\n    // Add pagination info to each item\n    itemIndex: startIndex+index,\n    hasMoreResults: hasMoreResults,\n    totalSet: item_count,\n     pageNumber:pageNumber_,\n  };\n});\n\n// If there are no results, return at least one item with pagination info\nif (results.length === 0) {\n  return [{ \n    json: {\n      name: null,\n      title: null,\n      link: null,\n      snippet: null,\n      image: null,\n      startIndex: 101,\n      hasMoreResults: false,\n      pageNumber:pageNumber_,\n    }\n  }];\n}\n\n// Return the processed results\nreturn results.map(r => ({ json: r }));"
          },
          "typeVersion": 2
        },
        {
          "id": "00b0ec01-e51f-447d-b25f-3023540192c9",
          "name": "Set Fields",
          "type": "n8n-nodes-base.set",
          "position": [
            -384,
            -976
          ],
          "parameters": {
            "options": {},
            "assignments": {
              "assignments": [
                {
                  "id": "cc27b2d9-8de7-43ca-a741-2d150084f78e",
                  "name": "currentStartIndex",
                  "type": "number",
                  "value": "=1"
                },
                {
                  "id": "fc552c57-4510-4f04-aa09-2294306d0d9f",
                  "name": "maxPages",
                  "type": "number",
                  "value": 10
                }
              ]
            }
          },
          "typeVersion": 3.4
        },
        {
          "id": "59193a13-6719-4944-9013-0ef37f991a59",
          "name": "If",
          "type": "n8n-nodes-base.if",
          "position": [
            1184,
            -992
          ],
          "parameters": {
            "options": {},
            "conditions": {
              "options": {
                "version": 2,
                "leftValue": "",
                "caseSensitive": true,
                "typeValidation": "strict"
              },
              "combinator": "and",
              "conditions": [
                {
                  "id": "05ee7d79-62bd-4fed-9a08-4c0f7b445f75",
                  "operator": {
                    "type": "number",
                    "operation": "lte"
                  },
                  "leftValue": "={{ $json.startIndex+ 9 }}",
                  "rightValue": 1000
                }
              ]
            }
          },
          "typeVersion": 2.2
        }
      ],
      "pinData": {},
      "connections": {
        "If": {
          "main": [
            [
              {
                "node": "Search Google",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Wait": {
          "main": [
            [
              {
                "node": "Add to Sheet",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Pagination": {
          "main": [
            [
              {
                "node": "Pagination Check",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Set Fields": {
          "main": [
            [
              {
                "node": "Search Google",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Add to Sheet": {
          "main": [
            [
              {
                "node": "Pagination",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Search Google": {
          "main": [
            [
              {
                "node": "Extract Results",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Extract Results": {
          "main": [
            [
              {
                "node": "Wait",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Pagination Check": {
          "main": [
            [
              {
                "node": "If",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Schedule Trigger": {
          "main": [
            [
              {
                "node": "Set Fields",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    }