{
  "id": "GlL4ZWBpE4Uymzlu",
  "name": "Extract employee emails from company domains using Human-in-the-Loop scraping",
  "tags": [],
  "nodes": [
    {
      "id": "e5d4f91c-6448-40c7-87fb-2cec2a1c2a9c",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1008,
        272
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "a527b41b-7ef8-4501-8332-46347db018d9",
      "name": "Splitting Items",
      "type": "n8n-nodes-base.code",
      "position": [
        2816,
        240
      ],
      "parameters": {
        "jsCode": "// Get the JSON string using the exact path provided by the user.\nconst jsonString = $input.first().json.output.string;\n\nlet parsedData;\n\n// Check if the string exists before attempting to parse\nif (!jsonString) {\n    // Return an empty array or throw an error if no string is found\n    // Throwing an error is usually better to stop the workflow if data is missing.\n    throw new Error(\"Input string is empty or missing at the specified path: $input.first().json.output.string\");\n}\n\ntry {\n    // 1. Parse the JSON string into a JavaScript array of objects\n    parsedData = JSON.parse(jsonString);\n} catch (error) {\n    // Handle JSON parsing errors (e.g., if the string is malformed)\n    throw new Error(`Failed to parse JSON string: ${error.message}`);\n}\n\n// 2. Ensure the parsed data is an array\nif (!Array.isArray(parsedData)) {\n    throw new Error('Parsed data is not an array. It cannot be split into multiple items.');\n}\n\n// 3. Map the array of objects into the n8n item format { json: object }\n// Each element in this array will be treated as a new item by n8n, achieving the split.\nconst outputItems = parsedData.map(item => ({\n    json: item,\n}));\n\n// 4. Return the new array of items\nreturn outputItems;"
      },
      "typeVersion": 2
    },
    {
      "id": "22b97434-be60-4e14-8976-b2022b785b0c",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2976,
        256
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{ $json.item[0].name }}",
            "Email": "={{ $json.item[0].email }}",
            "Position": "={{ $json.item[0].position }}"
          },
          "schema": [
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Position",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Position",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Database Sheet').item.json.sheetId }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1olY9B0qt_GWLcWitUW49j8qZFilM-rP4IRhr6du6RH4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1olY9B0qt_GWLcWitUW49j8qZFilM-rP4IRhr6du6RH4/edit?usp=drivesdk",
          "cachedResultName": "Company Email List"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "e9bca7f6-3eda-4ca0-bf22-4f45a16bee7a",
      "name": "Add Headers",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1584,
        272
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Database Sheet').item.json.sheetId }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1olY9B0qt_GWLcWitUW49j8qZFilM-rP4IRhr6du6RH4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1olY9B0qt_GWLcWitUW49j8qZFilM-rP4IRhr6du6RH4/edit?usp=drivesdk",
          "cachedResultName": "Company Email List"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "35bf87a5-a1e9-49dd-be31-9575f0acce1b",
      "name": "Reading company data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        816,
        272
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1olY9B0qt_GWLcWitUW49j8qZFilM-rP4IRhr6du6RH4/edit#gid=0",
          "cachedResultName": "Company URLs"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1olY9B0qt_GWLcWitUW49j8qZFilM-rP4IRhr6du6RH4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1olY9B0qt_GWLcWitUW49j8qZFilM-rP4IRhr6du6RH4/edit?usp=drivesdk",
          "cachedResultName": "Company Email List"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "0d242c28-c8a1-4c95-8393-ec38d40d2b17",
      "name": "Create Database Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1232,
        272
      ],
      "parameters": {
        "title": "={{ $json[\"Company url\"] }}",
        "options": {},
        "operation": "create",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1olY9B0qt_GWLcWitUW49j8qZFilM-rP4IRhr6du6RH4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1olY9B0qt_GWLcWitUW49j8qZFilM-rP4IRhr6du6RH4/edit?usp=drivesdk",
          "cachedResultName": "Company Email List"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "29f0dc34-ca23-4cb8-ac3d-51911d82de64",
      "name": "Define Headers",
      "type": "n8n-nodes-base.set",
      "position": [
        1392,
        272
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5bcde5f1-e4d6-46fd-a871-188353b627e0",
              "name": "Email",
              "type": "string",
              "value": ""
            },
            {
              "id": "c364f1a4-5ad8-48bf-96cc-21c2a4a7eee3",
              "name": "Position",
              "type": "string",
              "value": ""
            },
            {
              "id": "b40c0b30-7811-4766-8c05-b779d5e20ed0",
              "name": "Name",
              "type": "string",
              "value": ""
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "218d9b53-b266-482c-982e-90905ae60610",
      "name": "Give Time to Complete Verification",
      "type": "n8n-nodes-base.wait",
      "position": [
        2432,
        144
      ],
      "parameters": {
        "unit": "minutes",
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "aa4b80cc-f694-4014-b2ab-47d14729fc81",
      "name": "Get Data From BrowserAct",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2624,
        144
      ],
      "parameters": {
        "url": "https://api.browseract.com/v2/workflow/get-task",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "task_id",
              "value": "={{ $('Domain-Specific Lead Extraction').item.json.id }}"
            }
          ]
        },
        "nodeCredentialType": "browserActApi"
      },
      "credentials": {
        "browserActApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "9239d703-0b2c-4084-86c9-31bc13e2c2e8",
      "name": "Send Failure Alert",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2432,
        304
      ],
      "parameters": {
        "text": "=Sorry we facing problem right now.",
        "chatId": "=parameters.chatId==@Channel_ID (Use Channel ID or Chat ID )",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "72e2ccf9-eba9-4cc5-91ad-89ce5073126a",
      "name": "Human verification Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        2192,
        256
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "cea414f0-feaa-4012-9826-9feaf49d3e40",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "finished"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "cf3a1ab6-d5dc-4641-b3d7-7e8471fe502a",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "paused"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "34483eff-4611-4e27-b2b7-071d50427152",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "failed"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "111ba2b2-c3d8-4f46-a8a4-a2e15ad00ad8",
      "name": "Execute Manually",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        656,
        272
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0e13daf1-d832-4bc8-9824-bd2abaf2be60",
      "name": "Send Finishing Message",
      "type": "n8n-nodes-base.slack",
      "position": [
        1360,
        528
      ],
      "parameters": {
        "text": "=The Email extarction for  {{ $json[\"Company url\"] }} is Finished.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09KLV9DJSX",
          "cachedResultName": "all-browseract-workflow-test"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "a049e94d-8bc9-4168-a59c-248e18f5dabc",
      "name": "Domain-Specific Lead Extraction",
      "type": "n8n-nodes-browseract.browserAct",
      "position": [
        1968,
        272
      ],
      "parameters": {
        "type": "WORKFLOW",
        "timeout": 7200,
        "workflowId": "68914748077345770",
        "workflowConfig": {
          "value": {
            "input-Domain": "={{ $('Loop Over Items').item.json[\"Company url\"] }}"
          },
          "schema": [
            {
              "id": "input-Hunter_Link",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "description": "If left blank, the default value defined in BrowserAct will be used.",
              "displayName": "Hunter_Link",
              "defaultMatch": true
            },
            {
              "id": "input-Domain",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "description": "If left blank, the default value defined in BrowserAct will be used.",
              "displayName": "Domain",
              "defaultMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "input-Domain"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "open_incognito_mode": false
      },
      "credentials": {
        "browserActApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f6278bda-71c9-4539-a078-11ff38e4f7d5",
      "name": "Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -288
      ],
      "parameters": {
        "width": 380,
        "height": 504,
        "content": "## \u26a1 Workflow Overview & Setup\n\n**Summary:** This automation iterates through a list of company domains in a Google Sheet, scrapes employee emails using Hunter.io via BrowserAct, and archives the discovered leads into a new database sheet.\n\n### Requirements\n* **Credentials:** BrowserAct, Google Sheets, Slack.\n* **Mandatory:** BrowserAct API (Template: **Company Domain to Email Enrichment**)\n\n### How to Use\n1.  **Credentials:** Set up your BrowserAct, Google Sheets, and Slack credentials in n8n.\n2.  **BrowserAct Template:** Ensure you have the **Company Domain to Email Enrichment** template saved in your BrowserAct account.\n3.  **Google Sheet:** Create a sheet named \"Company URLs\" containing a column with company domains.\n4.  **Execution:** Trigger the workflow manually to start processing the list.\n\n### Need Help?\n[How to Find Your BrowserAct API Key & Workflow ID](https://docs.browseract.com)\n[How to Connect n8n to BrowserAct](https://docs.browseract.com)\n[How to Use & Customize BrowserAct Templates](https://docs.browseract.com)"
      },
      "typeVersion": 1
    },
    {
      "id": "13838b9b-33f5-45e7-9220-e62f8aeb9bd8",
      "name": "Step 1 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        96
      ],
      "parameters": {
        "color": 7,
        "width": 1036,
        "height": 108,
        "content": "### \ud83d\udccb Step 1: Data Preparation\n\nThe workflow reads a list of company domains from a Google Sheet. It then dynamically creates a new sheet to store the results and sets up the necessary column headers (Name, Email, Position)."
      },
      "typeVersion": 1
    },
    {
      "id": "962cd85b-776a-408e-9e6e-52dfa6d825fe",
      "name": "Step 2 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1888,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 1260,
        "height": 124,
        "content": "### \ud83c\udf10 Step 2: Automated Scraping, Parsing & Archiving\n\nFor each domain, BrowserAct executes a targeted search using Hunter.io to find employee contact information. The workflow includes a \"Human Verification Switch\" to pause and alert the user if a CAPTCHA or security check blocks the automation. The raw scraped data is parsed to extract individual employee details. These records are then appended row-by-row into the newly created Google Sheet."
      },
      "typeVersion": 1
    },
    {
      "id": "54c49d47-3ebc-4611-b863-911e5ccf09c8",
      "name": "Step 4 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1104,
        672
      ],
      "parameters": {
        "color": 7,
        "width": 660,
        "height": 116,
        "content": "### \ud83d\udd14 Step 3: Completion Notification\n\nOnce all domains have been processed, the workflow sends a confirmation message to a specific Slack channel, notifying the team that the new lead list is ready."
      },
      "typeVersion": 1
    },
    {
      "id": "d732d5b5-9f32-4bc0-9674-da1c460990ff",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        -288
      ],
      "parameters": {
        "color": 6,
        "width": 608,
        "height": 352,
        "content": "@[youtube](_7FlHGfwzWo)"
      },
      "typeVersion": 1
    },
    {
      "id": "18fabcfd-5080-4931-b52c-bb788efef60a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        256
      ],
      "parameters": {
        "color": 3,
        "width": 576,
        "content": "### \ud83d\udccb Google Sheet Requirements\n**Structure:**\n* **Row 1:** Must contain headers (`Company url`).\n* **Data:** Enter company data starting from Row 2."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "49f5fcfa-9ce6-4e07-84bd-6d530c11aed2",
  "connections": {
    "Add Headers": {
      "main": [
        [
          {
            "node": "Domain-Specific Lead Extraction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Define Headers": {
      "main": [
        [
          {
            "node": "Add Headers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Send Finishing Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Database Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Splitting Items": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Manually": {
      "main": [
        [
          {
            "node": "Reading company data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reading company data": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Database Sheet": {
      "main": [
        [
          {
            "node": "Define Headers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Data From BrowserAct": {
      "main": [
        [
          {
            "node": "Splitting Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Human verification Switch": {
      "main": [
        [
          {
            "node": "Splitting Items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Give Time to Complete Verification",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Failure Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Domain-Specific Lead Extraction": {
      "main": [
        [
          {
            "node": "Human verification Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Give Time to Complete Verification": {
      "main": [
        [
          {
            "node": "Get Data From BrowserAct",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}