{
  "id": "isdhCChy6Ms90ATQ",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Enrich company leads and extract decision-maker contacts using Linkfinder AI",
  "tags": [],
  "nodes": [
    {
      "id": "fff0a652-fce3-4116-b507-7ac959e48917",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -864
      ],
      "parameters": {
        "width": 480,
        "height": 592,
        "content": "## Company Enrichment Lead Generation\n\n### How it works\n\nThe workflow fetches data from Google Sheets to identify new status entries.\nIt extracts domains from existing data or utilizes AI to process domain information.\nA web scraping module scrapes websites to gather HTML content.\nAI agencies process the scraped content to classify them as an employer or agency.\nIdentified employers undergo further enrichment through API calls and saved back to Google Sheets.\nContacts information is processed, emails and LinkedIn profiles are amended, and results are stored.\n\n### Setup steps\n\n- [ ] Set up Google Sheets API credentials for access to existing spreadsheets.\n- [ ] Configure OpenAI API credentials for AI processing nodes.\n- [ ] Ensure Apify and LinkFinder AI API keys are configured for data scraping nodes.\n- [ ] Customize domain extraction logic to suit specific data patterns.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "eeabe911-5d0f-41a0-840d-fcb0d37371af",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        -672
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 304,
        "content": "## Workflow trigger and initialization\n\nInitial trigger to start the workflow, fetching initial data from Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "c6f55328-5d3c-40b1-beb1-14b19b844c84",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        -704
      ],
      "parameters": {
        "color": 7,
        "height": 320,
        "content": "## Filter new status\n\nFilter rows to find entries with a new status for processing."
      },
      "typeVersion": 1
    },
    {
      "id": "c68d61a7-3c36-4148-a215-105dc478ba82",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1488,
        -672
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 320,
        "content": "## Batch and read companies\n\nSplit data into batches and read existing companies from the sheet."
      },
      "typeVersion": 1
    },
    {
      "id": "78a75e98-49f8-4ebf-b515-84b86974b347",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1936,
        -656
      ],
      "parameters": {
        "color": 7,
        "width": 1360,
        "height": 400,
        "content": "## Domain handling process\n\nDecision-making for domain existence and extraction from email; AI domain prediction if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "59cf3930-ba08-4a41-8818-00df3b566b94",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3344,
        -976
      ],
      "parameters": {
        "color": 7,
        "width": 1024,
        "height": 464,
        "content": "## Website scraping\n\nScrape website based on processed domain and evaluate website content with AI."
      },
      "typeVersion": 1
    },
    {
      "id": "8d10e786-106b-4c1f-a868-df5aeb8619e4",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4400,
        -896
      ],
      "parameters": {
        "color": 7,
        "width": 1056,
        "height": 528,
        "content": "## AI classification and action\n\nClassify content using AI and determine actions (e.g., enrich with data or skip)."
      },
      "typeVersion": 1
    },
    {
      "id": "fbe694f9-94e5-4de3-a277-9d30d8b13b15",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3328,
        -480
      ],
      "parameters": {
        "color": 7,
        "height": 320,
        "content": "## Mark entities\n\nMark entries as required or not for enrichment within Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "92793d1f-cc19-42bc-8b00-6f5029a96535",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        1056
      ],
      "parameters": {
        "color": 7,
        "width": 672,
        "height": 240,
        "content": "## Initialization and status filters"
      },
      "typeVersion": 1
    },
    {
      "id": "98f9fb4d-8a61-4ed5-99cc-c57de38741cc",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1904,
        896
      ],
      "parameters": {
        "color": 7,
        "width": 1632,
        "height": 384,
        "content": "## Employer process branching\n\nDecide on further processing based on employer classification (e.g., API actions, contact enrichment)."
      },
      "typeVersion": 1
    },
    {
      "id": "7c90f243-f423-4d45-b69b-ae31ba3f25ef",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2656,
        512
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 352,
        "content": "## AI and contact data merge\n\nExecute AI to select top contacts, parse the result, and handle missing information."
      },
      "typeVersion": 1
    },
    {
      "id": "ce051e61-6e93-4723-b6b0-8c7b33599508",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1632,
        304
      ],
      "parameters": {
        "color": 7,
        "height": 720,
        "content": "## HR employee scraping\n\nUse API calls to gather HR employee data from an external source."
      },
      "typeVersion": 1
    },
    {
      "id": "4eeb25db-a12e-40ee-93ee-6537c68e37f6",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2208,
        1312
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 304,
        "content": "## Employer enrichment\n\nRun external data actor and process the dataset for potential employer data enrichment."
      },
      "typeVersion": 1
    },
    {
      "id": "bccaf798-5419-4f42-adcd-cc1cd617b4a0",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3904,
        800
      ],
      "parameters": {
        "color": 7,
        "width": 880,
        "height": 528,
        "content": "## Contact processing and saving\n\nParse selected contact information and save enriched results to Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "9debd6e0-2cda-490d-9064-e980870371d8",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3648,
        1360
      ],
      "parameters": {
        "color": 7,
        "width": 912,
        "height": 624,
        "content": "## LinkedIn processing\n\nEvaluate LinkedIn presence and scrape profile data if available."
      },
      "typeVersion": 1
    },
    {
      "id": "55dd9e1c-6b1e-4bd8-b385-917e06117b44",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1936,
        1328
      ],
      "parameters": {
        "color": 7,
        "height": 304,
        "content": "## Agency marking\n\nMark entries as agency-related within Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "e19594b6-d02d-4401-8b75-940d000e4778",
      "name": "Filter New Status Rows",
      "type": "n8n-nodes-base.filter",
      "position": [
        1264,
        -544
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "NEW"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "0e857b2b-b0e8-478d-84d0-bb7df7a63c00",
      "name": "Mark as No Domain",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3376,
        -320
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "NOT_ENRICHED",
            "company_id": "={{ $json.company_id }}"
          },
          "schema": [
            {
              "id": "company_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "company_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_location",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_emails",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_emails",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_count",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "job_count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intent_score",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "intent_score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "industry",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "industry",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_linkedin",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_linkedin",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "total_contacts_found",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "total_contacts_found",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "last_job_detected_at",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "last_job_detected_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website_content",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_website_content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enriched_at",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "enriched_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "company_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_SHEET_ID_1451193517}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "7ffeded1-9afd-4629-a1e7-71c3bffd25bb",
      "name": "Update with Company Domain",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3392,
        -688
      ],
      "parameters": {
        "columns": {
          "value": {
            "company_id": "={{ $json.company_id }}",
            "company_website": "={{ \n  $json.company_website || $node[\"Loop Over Items1\"].json.company_website \n}}",
            "company_linkedin": "={{ $json.company_linkedin }}"
          },
          "schema": [
            {
              "id": "company_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "company_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_location",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_emails",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_emails",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_count",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "job_count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intent_score",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "intent_score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "industry",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "industry",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_linkedin",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_linkedin",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_type",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "total_contacts_found",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "total_contacts_found",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "last_job_detected_at",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "last_job_detected_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website_content",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_website_content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enriched_at",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "enriched_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "company_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_SHEET_ID_1451193517}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "6648fbe9-e695-4492-a61c-86df5958f0b2",
      "name": "Fetch Website Data",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        3568,
        -688
      ],
      "parameters": {
        "url": "={{ $json.company_website.startsWith('http') ? $json.company_website : 'https://' + $json.company_website }}",
        "options": {
          "timeout": 15000,
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        },
        "jsonHeaders": "{\n  \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/122.0.0.0 Safari/537.36\",\n  \"Accept\": \"text/html,application/xhtml+xml\",\n  \"Accept-Language\": \"en-US,en;q=0.9\"\n}",
        "sendHeaders": true,
        "specifyHeaders": "json"
      },
      "notesInFlow": true,
      "typeVersion": 4.4,
      "alwaysOutputData": true
    },
    {
      "id": "cfd2f385-e93e-48d7-9390-e7b466f663b5",
      "name": "Extract HTML from Response",
      "type": "n8n-nodes-base.html",
      "position": [
        4016,
        -672
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "body_text",
              "cssSelector": "body"
            },
            {
              "key": "headings",
              "cssSelector": "headings",
              "returnArray": true
            },
            {
              "key": "paragraphs",
              "cssSelector": "p",
              "returnArray": true
            },
            {
              "key": "links",
              "attribute": "href",
              "cssSelector": "a",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "meta_description",
              "attribute": "content",
              "cssSelector": "meta[name=\"description\"]",
              "returnValue": "attribute"
            },
            {
              "key": "title",
              "cssSelector": "title",
              "skipSelectors": "script, style, noscript, svg, img, header, footer, nav"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e98399e7-7209-4b55-80c9-d3c9b36491e2",
      "name": "Clean Extracted Text",
      "type": "n8n-nodes-base.code",
      "position": [
        4224,
        -672
      ],
      "parameters": {
        "jsCode": "const data = $json;\n\nconst cleanText = (arr) => {\n  if (!arr) return '';\n  return Array.isArray(arr)\n    ? arr.join(' ').replace(/\\s+/g, ' ').trim()\n    : arr;\n};\n\nreturn [{\n  json: {\n    ...data,\n    clean_content: [\n      cleanText(data.title),\n      cleanText(data.meta_description),\n      cleanText(data.headings),\n      cleanText(data.paragraphs)\n    ].join(' ').slice(0, 5000) // prevent token explosion\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "17dbe5ce-871f-4c7c-8761-61ba3df5a3e2",
      "name": "AI Classifier for Type",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        4448,
        -672
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {
          "textFormat": {
            "textOptions": {
              "type": "json_object"
            }
          }
        },
        "responses": {
          "values": [
            {
              "content": "=Here is your **same prompt with ONLY the industry classification added (no other changes):**\n\n---\n\nYou are a company classifier.\n\nDetermine if this company is a REAL EMPLOYER or a RECRUITMENT/STAFFING AGENCY.\n\nCompany name: {{ $node[\"\ud83c\udf10 AI Domain Found?\"].json.company_name }}\n\nWebsite URL: {{ $node[\"Save Domain to Companies\"].json.company_website }}\n\nWebsite content (first 3000 chars): {{\n($json.clean_content && $json.clean_content.length > 0\n? $json.clean_content\n: $json.data?.markdown || ''\n).slice(0, 3000)\n}}\n\nCLASSIFICATION RULES:\n\n* Staffing/recruitment/manpower supply/HR outsourcing/placing candidates \u2192 AGENCY\n* Job board, job aggregator, employment portal \u2192 AGENCY\n* \"We provide manpower\", \"recruitment solutions\", \"staffing services\" \u2192 AGENCY\n* Real operating business (hotel, hospital, logistics, construction, oil company, restaurant, factory) \u2192 EMPLOYER\n* Unclear or website unavailable \u2192 EMPLOYER (benefit of doubt)\n\nINDUSTRY CLASSIFICATION:\nClassify the company into exactly ONE of these industries:\n\n* Oil & Gas\n* Construction\n* Services (Banking & Insurance)\n* Logistics & Supply Chain\n* Manufacturing\n* Hospitality\n* Telecommunications & IT\n* Facility Management\n* Aviation / Airport\n* Retail\n* Shipbuilding\n* Automobile\n* Drivers & Operators\n* Furniture & Interiors\n* Garments & Furnishing\n* Agriculture\n* Community Services\n* Education\n* Healthcare\n* Other\n\nRETURN ONLY VALID JSON:\n\n```json\n{\n  \"classification\": \"EMPLOYER\",\n  \"industry\": \"Hospitality\",\n  \"reason\": \"one sentence explanation\"\n}\n```\n"
            }
          ]
        },
        "builtInTools": {}
      },
      "typeVersion": 2.1
    },
    {
      "id": "5f6e2bbf-1538-49fd-acd5-2f4dd0ad5fd5",
      "name": "Parse AI Classification",
      "type": "n8n-nodes-base.code",
      "position": [
        4784,
        -672
      ],
      "parameters": {
        "jsCode": "const raw = $input.first().json;\n\n// \u2705 SAFE reference to previous node item\nconst job = $item(0).$node[\"\ud83c\udf10 AI Domain Found?\"].json;\n\n// \u2705 Current node data\nconst website_body = $json.clean_content || '';\n\nlet classification = 'EMPLOYER';\nlet industry = 'Other';\nlet reason = '';\n\ntry {\n  const content = raw.output?.[0]?.content?.[0]?.text;\n\n  if (content && typeof content === 'object') {\n    classification = content.classification || 'EMPLOYER';\n    industry = content.industry || 'Other';\n    reason = content.reason || '';\n  }\n\n} catch (e) {\n  reason = 'parse_error';\n}\n\nreturn [{\n  json: {\n    ...job,\n    company_site_body: website_body,\n    company_type: classification,\n    industry: industry, // \u2705 NEW FIELD\n    classification_reason: reason\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "e3a8164b-9ff8-473a-909d-2a86f0542d81",
      "name": "Check Employer Type",
      "type": "n8n-nodes-base.if",
      "position": [
        5008,
        -672
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.company_type }}",
              "rightValue": "EMPLOYER"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "d4ef3b0b-40cf-448e-8bc3-212bd2d19fc8",
      "name": "Flag for Enrichment",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        5296,
        -784
      ],
      "parameters": {
        "columns": {
          "value": {
            "reason": "={{ $json.classification_reason }}",
            "status": "ENRICHMENT_REQUIRED",
            "industry": "={{ $json.industry }}",
            "company_id": "={{ $json.company_id }}",
            "company_type": "={{ $json.company_type }}"
          },
          "schema": [
            {
              "id": "company_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "company_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_location",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_emails",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_emails",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_count",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "job_count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intent_score",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "intent_score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "industry",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "industry",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_linkedin",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_linkedin",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "company_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "total_contacts_found",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "total_contacts_found",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "last_job_detected_at",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "last_job_detected_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website_content",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_website_content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enriched_at",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "enriched_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "company_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_SHEET_ID_1451193517}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "6a9224d6-5b42-4dcf-bb6b-aaaa25f0f80c",
      "name": "Flag as Agency",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        5312,
        -528
      ],
      "parameters": {
        "columns": {
          "value": {
            "reason": "={{ $json.classification_reason }}",
            "company_id": "={{ $json.company_id }}",
            "company_type": "={{ $json.company_type }}"
          },
          "schema": [
            {
              "id": "company_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "company_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_location",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_emails",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_emails",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_count",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "job_count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intent_score",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "intent_score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "industry",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "industry",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_linkedin",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_linkedin",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "total_contacts_found",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "total_contacts_found",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "last_job_detected_at",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "last_job_detected_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website_content",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_website_content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enriched_at",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "enriched_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "company_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_SHEET_ID_1451193517}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "bf242443-7314-4000-ba20-39a10d2142be",
      "name": "Batch Process Items 1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1536,
        -544
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "d82c3882-f100-4257-95b1-c01cec225597",
      "name": "Check AI Domain Found",
      "type": "n8n-nodes-base.if",
      "position": [
        3152,
        -544
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ai-domain-check",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.company_website}}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "8653ca39-7755-46c8-82aa-829054e1e5df",
      "name": "Extract Domain from Email",
      "type": "n8n-nodes-base.code",
      "position": [
        2240,
        -432
      ],
      "parameters": {
        "jsCode": "const job = $json;\n\n// Parse original_json safely\nlet parsed = {};\ntry {\n  parsed = typeof job.original_json === 'string'\n    ? JSON.parse(job.original_json)\n    : job.original_json || {};\n} catch (e) {\n  parsed = {};\n}\n\n// Extract emails from original_json\nlet emails = Array.isArray(parsed.emails) ? parsed.emails : [];\n\n// Generic email providers to skip\nconst genericDomains = new Set([\n  'gmail.com','yahoo.com','hotmail.com','outlook.com','live.com',\n  'aol.com','icloud.com','mail.com','protonmail.com','zoho.com',\n  'yandex.com','gmx.com','inbox.com','fastmail.com',\n  'yahoo.co.uk','hotmail.co.uk','outlook.co.uk',\n  'yahoo.in','rediffmail.com','msn.com','me.com',\n  'googlemail.com','yahoo.co.in','outlook.in'\n]);\n\nlet domain = '';\n\nfor (const email of emails) {\n  if (!email || typeof email !== 'string' || !email.includes('@')) continue;\n\n  const emailDomain = email.split('@')[1]?.toLowerCase().trim();\n\n  if (\n    emailDomain &&\n    !genericDomains.has(emailDomain) &&\n    emailDomain.includes('.')\n  ) {\n    domain = emailDomain;\n    break;\n  }\n}\n\nreturn {\n  json: {\n    ...job,\n    email_found: emails.length > 0,\n    company_website: domain,\n    domain_source: domain ? 'email_extraction' : ''\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "e059cda9-4021-4226-bbf1-389a504b47f6",
      "name": "Check Email Domain Presence",
      "type": "n8n-nodes-base.if",
      "position": [
        2480,
        -432
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "email-domain-check",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.company_website }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "5a3c33ab-9efc-441c-9c84-9de00be5321e",
      "name": "Verify Domain Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        1984,
        -528
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "has-domain",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $('Loop Over Items1').item.json.company_website }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "e091d329-1d9b-4c6e-b8b6-c8f23c53337c",
      "name": "Fetch Actor Dataset 4",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        2736,
        -416
      ],
      "parameters": {
        "memory": 8192,
        "actorId": {
          "__rl": true,
          "mode": "id",
          "value": "x7ZcMWQrMLWiMN46e"
        },
        "operation": "Run actor and get dataset",
        "customBody": "={\n  \"country\": \"{{ $json.country }}\",\n  \"name\": \"{{ $json.company_name }}\"\n}",
        "actorSource": "store"
      },
      "typeVersion": 1
    },
    {
      "id": "5f931f13-c10b-4d4e-88cd-5162aa0931ec",
      "name": "Parse AI Domain Response",
      "type": "n8n-nodes-base.code",
      "position": [
        2944,
        -416
      ],
      "parameters": {
        "jsCode": "const raw = $input.first().json;\nconst job = $('\ud83c\udf10 Has Domain?').item.json;\n\nlet domain = '';\nlet linkedin_url = '';\nlet domainSource = '';\n\n// \u2705 Extract domain\nif (raw.official_website) {\n  domain = raw.official_website\n    .replace(/^https?:\\/\\//, '')\n    .replace(/^www\\./, '')\n    .split('/')[0]\n    .trim();\n}\n\n// \u2705 Extract LinkedIn\nif (Array.isArray(raw.social_links)) {\n  const linkedin = raw.social_links.find(link =>\n    link.includes('linkedin.com/company')\n  );\n\n  if (linkedin) {\n    linkedin_url = linkedin;\n  }\n}\n\n// \ud83d\udeab Filter invalid domains\nconst invalidDomains = ['linkedin', 'indeed', 'glassdoor', 'google'];\n\nif (\n  !domain ||\n  invalidDomains.some(d => domain.includes(d))\n) {\n  domain = '';\n  domainSource = 'invalid';\n} else {\n  domainSource = 'apify';\n}\n\nreturn [{\n  json: {\n    ...job,\n    company_website: domain,\n    company_linkedin: linkedin_url,\n    domain_source: domainSource\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "9658dc48-48dc-4424-ac0d-483d9bc320bc",
      "name": "Read Current Company Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1760,
        -528
      ],
      "parameters": {
        "options": {
          "outputFormatting": {
            "values": {
              "date": "FORMATTED_STRING",
              "general": "UNFORMATTED_VALUE"
            }
          }
        },
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.company_id }}",
              "lookupColumn": "company_id"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_SHEET_ID_1726393267}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5,
      "alwaysOutputData": true
    },
    {
      "id": "8ed8195f-2a35-426a-905a-35a5acbd4e9f",
      "name": "Initiate Firecrawl Scraping",
      "type": "@mendable/n8n-nodes-firecrawl.firecrawl",
      "position": [
        4064,
        -864
      ],
      "parameters": {
        "url": "={{ \n  $item(0).$node[\"Save Domain to Companies\"].json.company_website?.startsWith('http') \n    ? $item(0).$node[\"Save Domain to Companies\"].json.company_website \n    : 'https://' + $item(0).$node[\"Save Domain to Companies\"].json.company_website \n}}",
        "operation": "scrape",
        "requestOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "b029bf5a-af13-4c79-9af5-6f606eafe3da",
      "name": "If Website Fetch Success",
      "type": "n8n-nodes-base.if",
      "position": [
        3712,
        -688
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c74d3ec7-ea4a-486f-b92a-6e9b0f48a6ed",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ \n  !$json ||\n  $json.error ||\n  $json.status >= 400 ||\n  $json.error?.status >= 400 ||\n  !$json.data && !$json.body && !$json.clean_content ||\n  ($json.error?.message && $json.error.message.includes('Just a moment')) ||\n  (typeof $json.data === 'string' && $json.data.includes('Just a moment')) ||\n  (typeof $json.body === 'string' && $json.body.includes('Just a moment'))\n}}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "56f794b2-ad89-4550-96ff-eed2c36d86ad",
      "name": "Manual Execution Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        816,
        -544
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "100b0fee-978d-4e0f-9ed9-5597355464f3",
      "name": "Read Google Sheet Rows",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1040,
        -544
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "NEW",
              "lookupColumn": "status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_SHEET_ID_1451193517}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "196654ff-433e-4645-98d9-22314061ca5e",
      "name": "Filter New Status Rows 1",
      "type": "n8n-nodes-base.filter",
      "position": [
        1408,
        1136
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "ENRICHMENT_REQUIRED"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "06e69db3-8dc1-45e0-af7f-bccd44cc95e5",
      "name": "Read Google Sheet Rows 1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1184,
        1136
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "ENRICHMENT_REQUIRED",
              "lookupColumn": "status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_SHEET_ID_1451193517}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "6b14b29b-4110-4620-a448-84917b53c55a",
      "name": "Batch Process Items 2",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1664,
        1136
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "ab1ef6e6-5651-4087-b3dc-48d54cf05fb6",
      "name": "Determine Company Type",
      "type": "n8n-nodes-base.if",
      "position": [
        1952,
        1120
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "is-employer",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.company_type }}",
              "rightValue": "EMPLOYER"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c712069e-6db2-4b47-badc-c53c07490154",
      "name": "Flag as Agency Type",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1984,
        1456
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "NOT_ENRICHED",
            "company_id": "={{ $node[\"\ud83d\udcbe Save Domain to Sheet2\"].json.company_id }}",
            "company_type": "AGENCY"
          },
          "schema": [
            {
              "id": "company_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "company_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_location",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "industry",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "industry",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_linkedin",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_linkedin",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "company_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "total_contacts",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "total_contacts",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website_content",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_website_content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enriched_at",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "enriched_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "company_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_SHEET_ID_75755771}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "6d271d2b-47e8-435d-90a8-84e6e3826c59",
      "name": "Fetch HR Employees Links",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        1680,
        464
      ],
      "parameters": {
        "url": "https://api.linkfinderai.com",
        "method": "POST",
        "options": {
          "timeout": 60000
        },
        "jsonBody": "={\n  \"type\": \"company_domain_to_employees\",\n  \"input_data\": \"{{ $json.company_website }}\",\n  \"department\": \"human_resources\",\n  \"seniority\": \"all\",\n  \"employee_count\": 5\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$env.LINKFINDER_API_KEY}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "2756af40-988c-4f74-81e7-3a855ac88a29",
      "name": "AI Select Top Contacts",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2880,
        688
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are an outbound targeting engine for a manpower recruitment agency.\n\nYour goal is to ALWAYS return 1\u20132 contacts WITH VALID EMAILS ONLY.\n\n-------------------------------------\nCONTEXT:\nWe supply manpower (hospitality, logistics, healthcare, oil & gas, construction).\nWe help companies fill urgent hiring needs with international candidates.\n\nEMPLOYEE DATA:\n{{ JSON.stringify($input.all().map(item => item.json)) }}\n\nJOB CONTEXT:\n- Job Role: {{ $('\ud83d\udd04 Loop: Each Job2').item.json.job_title }}\n- Job Location: {{ $('\ud83d\udd04 Loop: Each Job2').item.json.job_location }}\n- Company: {{ $('\ud83d\udd04 Loop: Each Job2').item.json.company_name }}\n\n-------------------------------------\nSTEP 1: HARD FILTER (EMAIL REQUIRED)\n\nONLY keep contacts where:\n- Email EXISTS and is valid\n\nREMOVE ALL contacts without email immediately.\n\n-------------------------------------\nSTEP 2: ROLE FILTER (FLEXIBLE)\n\nPrefer roles in this order:\n\n1. Recruiter / Talent Acquisition\n2. HR Manager / HRBP\n3. Operations Manager / Operations roles\n4. ANY senior-level role (Director, VP, Head, Manager)\n\n\ud83d\udc49 If ideal roles are not available:\n\u2192 ALLOW less-perfect but still senior roles WITH email\n\n-------------------------------------\nSTEP 3: COMPANY MATCH\n\n- MUST match same company (or very close variation like Weatherford vs Weatherford International)\n\n-------------------------------------\nSTEP 4: FINAL SELECTION\n\n- Select MAXIMUM 2 contacts\n- MUST return at least 1 if any email exists\n- If multiple valid \u2192 pick best 2 by relevance\n\n- If NO contacts with email exist:\n  \u2192 return empty array\n\n-------------------------------------\nOUTPUT RULES\n\n- DO NOT hallucinate emails\n- DO NOT include contacts without email\n- Output STRICT JSON only\n\n-------------------------------------\nOUTPUT FORMAT:\n\n{\n  \"total_selected\": 2,\n  \"selected_contacts\": [\n    {\n      \"name\": \"John Doe\",\n      \"role\": \"Senior Recruiter\",\n      \"email\": \"john@company.com\",\n      \"linkedinUrl\": \"https://linkedin.com/in/johndoe\",\n      \"companylinkedinUrl\": \"https://linkedin.com/company/company-name\",\n      \"location_match\": true,\n      \"needs_enrichment\": false,\n      \"priority\": \"HIGH\",\n      \"reason\": \"Relevant role with confirmed email\"\n    }\n  ],\n  \"strategy\": \"Prioritize contacts with email for immediate outreach\"\n}"
            }
          ]
        },
        "jsonOutput": true
      },
      "executeOnce": true,
      "typeVersion": 1.8
    },
    {
      "id": "a510a8a3-e64b-44ba-91fe-9ee916fb4bc1",
      "name": "Process Selected Contacts",
      "type": "n8n-nodes-base.code",
      "position": [
        3200,
        1008
      ],
      "parameters": {
        "jsCode": "const raw = $input.first().json;\nconst job = $('\ud83d\udd04 Loop: Each Job2').item.json;\nconst company = $(\"\ud83d\udcbe Save Domain to Sheet2\").item.json;\nlet contacts = [];\nlet strategy = '';\n\nfunction safeParse(input) {\n  try {\n    // Case 1: Already parsed JSON\n    if (typeof input === 'object' && input !== null) {\n\n      // \u2705 HANDLE YOUR CURRENT STRUCTURE\n      if (input.message?.content) {\n        const content = input.message.content;\n\n        // If content is already an object \u2192 use directly\n        if (typeof content === 'object') {\n          return content;\n        }\n\n        // If content is string \u2192 clean + parse\n        if (typeof content === 'string') {\n          const cleaned = content.replace(/```json\\n?|```/g, '').trim();\n          return JSON.parse(cleaned);\n        }\n      }\n\n      // Fallback (other AI formats)\n      if (input.output?.[0]?.content?.[0]?.text) {\n        return JSON.parse(input.output[0].content[0].text);\n      }\n\n      return input;\n    }\n\n    // Case 2: Raw string\n    if (typeof input === 'string') {\n      return JSON.parse(input);\n    }\n\n    return null;\n\n  } catch (err) {\n    return null;\n  }\n}\n\nconst parsed = safeParse(raw);\ntotal_contacts_found: contacts.length;\n// \u2705 Extract safely\nif (parsed && Array.isArray(parsed.selected_contacts)) {\n  contacts = parsed.selected_contacts;\n  strategy = parsed.strategy || '';\n} else {\n  contacts = [];\n  strategy = parsed?.strategy || 'Parse error or invalid structure';\n}\n\n// \u2705 No contacts fallback\nif (contacts.length === 0) {\n  return [{\n    json: {\n      ...job,\n      no_contacts_found: true,\n      strategy\n    }\n  }];\n}\n\n// \u2705 Map ALL contacts (1, 2, 3... scalable)\nreturn contacts.map(contact => ({\n  json: {\n    ...job,\n    ...company,\n    total_contacts_found: contacts.length,\n    contact_name: contact.name || '',\n    contact_role: contact.role || '',\n    contact_email: contact.email || '',\n    contact_linkedin: contact.linkedinUrl || '',\n    location_match: contact.location_match ?? false,\n    needs_enrichment: contact.needs_enrichment ?? !contact.email,\n    contact_priority: contact.priority || 'medium',\n    selection_reason: contact.reason || '',\n    strategy\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "0160e892-96b4-4d09-9d33-cc5f6de1405d",
      "name": "Check Email Presence",
      "type": "n8n-nodes-base.if",
      "position": [
        3392,
        1008
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "has-email",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ !!$json.contact_email || !!$json.company_emails }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "d749835b-f1e5-46e8-9d03-5a4122e406e2",
      "name": "Save Contact with Email",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3808,
        1472
      ],
      "parameters": {
        "columns": {
          "value": {
            "name": "={{ $json.contact_name }}",
            "email": "={{ $json.contact_email }}",
            "company": "={{ $json.company_name }}",
            "strategy": "={{ $json.strategy }}",
            "job_title": "={{ $json.contact_role }}",
            "unique_id": "={{ $now }}",
            "company_id": "={{ $json.company_id }}",
            "linkedinUrl": "={{ $json.contact_linkedin }}",
            "contact_priority": "={{ $json.contact_priority }}",
            "selection_reason": "={{ $json.selection_reason }}"
          },
          "schema": [
            {
              "id": "unique_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "unique_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "company_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "job_title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "linkedinUrl",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "linkedinUrl",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "companyLinkedin",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "companyLinkedin",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "location",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "contact_priority",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "contact_priority",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "selection_reason",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "selection_reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "strategy",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "strategy",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "useAppend": true
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_SHEET_ID_451639006}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "9c60f03e-3929-4023-b1e9-398201d602a6",
      "name": "Check LinkedIn Presence",
      "type": "n8n-nodes-base.if",
      "position": [
        3696,
        1760
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "has-linkedin",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.contact_linkedin }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "f95b3519-1ec5-4daa-8e6b-3eef1d3b3520",
      "name": "Scrape LinkedIn Profile",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        3952,
        1168
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/curious_coder~linkedin-profile-scraper/run-sync-get-dataset-items",
        "method": "POST",
        "options": {
          "timeout": 120000
        },
        "jsonBody": "={\n  \"profileUrls\": [\"{{ $json.contact_linkedin }}\"]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "3ba6403c-f97a-4c22-8814-691d1bb20f3c",
      "name": "Process LinkedIn Data",
      "type": "n8n-nodes-base.code",
      "position": [
        4176,
        1168
      ],
      "parameters": {
        "jsCode": "const response = $input.first().json;\nconst contact = $('\ud83d\udce7 Has Email?').item.json;\n\n// LinkedIn scraper returns array, get first result\nlet profile = Array.isArray(response) ? response[0] : response;\n\n// Extract email from profile\nlet email = '';\nif (profile) {\n  // Check various email fields\n  if (profile.email) {\n    email = profile.email;\n  } else if (profile.emails && profile.emails.length > 0) {\n    email = profile.emails[0];\n  } else if (profile.contactInfo?.email) {\n    email = profile.contactInfo.email;\n  }\n}\n\nreturn [{\n  json: {\n    ...contact,\n    contact_email: email,\n    contact_name: profile?.fullName || profile?.firstName + ' ' + profile?.lastName || contact.contact_name,\n    contact_role: profile?.headline || contact.contact_role,\n    enrichment_source: 'linkedin_scraper',\n    linkedin_enriched: true\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "a8bbb51b-1a02-483d-b892-839e7d58d05d",
      "name": "Save Enriched Contact Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        4400,
        1168
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "={{ $json.contact_email ? 'ready_for_outreach' : 'needs_manual_enrichment' }}",
            "job_title": "={{ $json.job_title }}",
            "created_at": "={{ $now.toISO() }}",
            "send_email": "FALSE",
            "company_name": "={{ $json.company_name }}",
            "contact_name": "={{ $json.contact_name }}",
            "contact_role": "={{ $json.contact_role }}",
            "job_location": "={{ $json.job_location }}",
            "contact_email": "={{ $json.contact_email }}",
            "job_unique_id": "={{ $json.unique_id }}",
            "company_website": "={{ $json.company_website }}",
            "outreach_status": "",
            "contact_linkedin": "={{ $json.contact_linkedin }}",
            "contact_priority": "={{ $json.contact_priority }}",
            "selection_reason": "={{ $json.selection_reason }}",
            "enrichment_source": "={{ $json.enrichment_source }}"
          },
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Contacts"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "7e345128-d39a-4d22-ba20-b7a8a0b48eef",
      "name": "Save Without LinkedIn",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        4416,
        1824
      ],
      "parameters": {
        "columns": {
          "value": {
            "status": "needs_manual_enrichment",
            "job_title": "={{ $json.job_title }}",
            "created_at": "={{ $now.toISO() }}",
            "send_email": "FALSE",
            "company_name": "={{ $json.company_name }}",
            "contact_name": "={{ $json.contact_name }}",
            "contact_role": "={{ $json.contact_role }}",
            "job_location": "={{ $json.job_location }}",
            "contact_email": "",
            "job_unique_id": "={{ $json.unique_id }}",
            "company_website": "={{ $json.company_website }}",
            "outreach_status": "",
            "contact_linkedin": "={{ $json.contact_linkedin }}",
            "contact_priority": "={{ $json.contact_priority }}",
            "selection_reason": "={{ $json.selection_reason }}",
            "enrichment_source": "linkfinder_only"
          },
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Contacts"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "2bcae06a-e62f-459f-b3b6-fbf1bf08fe9c",
      "name": "Update Job Status 4",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        4640,
        912
      ],
      "parameters": {
        "columns": {
          "value": {
            "reason": "={{ $node[\"All Info\"].json[\"classification_reason\"] }}",
            "status": "ENRICHED",
            "company_id": "={{ $json.company_id }}",
            "enriched_at": "={{ $now }}",
            "company_type": "={{ $item(0).$node[\"All Info\"].json[\"company_type\"] }}",
            "total_contacts": "={{ $('\ud83d\udce7 Has Email?').item.json.total_contacts_found }}",
            "company_website_content": "={{ $node[\"All Info\"].json[\"company_site_body\"] }}"
          },
          "schema": [
            {
              "id": "company_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "company_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_location",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "industry",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "industry",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_linkedin",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "company_linkedin",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "total_contacts",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "total_contacts",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reason",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "reason",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company_website_content",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company_website_content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enriched_at",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "enriched_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "company_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_SHEET_ID_75755771}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{$env.GOOGLE_SHEETS_DOCUMENT_ID}}"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "ceb2c8ca-161e-434a-b8a9-29dd92fc54c7",
      "name": "Fetch Actor Dataset 6",
      "type": "@apify/n8n-nodes-apify.apify",
      "onError": "continueRegularOutput",
      "position": [
        2256,
        1440
      ],
      "parameters": {
        "memory": 8192,
        "actorId": {
          "__rl": true,
          "mode": "id",
          "value": "Vb6LZkh4EqRlR0Ka9"
        },
        "operation": "Run actor and get dataset",
        "customBody": "={\n    \"companies\": [\n        \"{{ $json.company_name }}\"\n    ],\n    \"functionIds\": [\n        \"12\",\n        \"18\",\n        \"20\",\n        \"21\",\n        \"4\",\n        \"9\"\n    ],\n    \"locations\": [\n        \"{{ $json.company_location }}\"\n    ],\n    \"maxItems\": 5,\n    \"profileScraperMode\": \"Full + email search ($12 per 1k)\",\n    \"recentlyChangedJobs\": false,\n    \"seniorityLevelIds\": [\n        \"120\",\n        \"210\",\n        \"220\",\n        \"300\",\n        \"320\",\n        \"130\",\n        \"310\"\n    ]\n} ",
        "actorSource": "store"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "d94474d4-a486-4b1a-8bec-438c73cca8d3",
      "name": "Process in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        2480,
        1440
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst job = $('\ud83c\udf10 Has Domain?2').item.json;\n\nconst results = items.map(item => {\n  const profile = item.json;\n\n  // \u2705 Name\n  const name = `${profile.firstName || ''} ${profile.lastName || ''}`.trim();\n\n  // \u2705 Job title (from experience or headline fallback)\n  let job_title = '';\n  if (Array.isArray(profile.experience) && profile.experience.length > 0) {\n    job_title = profile.experience[0].position || '';\n  }\n\n  // fallback\n  if (!job_title) {\n    job_title = profile.headline || '';\n  }\n\n  // \u2705 Email (safe extraction)\n  let email = '';\n  if (Array.isArray(profile.emails) && profile.emails.length > 0) {\n    email = profile.emails[0].email || '';\n  }\n\n  // \u2705 Company LinkedIn\n  let companyLinkedin = '';\n  if (profile.currentPosition?.[0]?.companyLinkedinUrl) {\n    companyLinkedin = profile.currentPosition[0].companyLinkedinUrl;\n  }\n\n  // \u2705 Location\n  const location = profile.location?.linkedinText || '';\n\n  return {\n    company: job.company_name || '',\n    name,\n    job_title,\n    job_headline: profile.headline || '',\n    email,\n    linkedinUrl: profile.linkedinUrl || '',\n    companyLinkedin,\n    location\n  };\n});\n\nreturn [{\n  json: {\n    contacts: results\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "82ff63cb-f39b-410e-9fd8-d9a6299dcc1e",
      "name": "Merge Employee Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        2704,
        672
      ],
      "parameters": {
        "numberInputs": 4
      },
      "typeVersion": 3.2
    },
    {
      "id": "c88248d1-c9bc-4522-ae98-59bff7eed8e2",
      "name": "Consolidate Job Info",
      "type": "n8n-nodes-base.code",
      "position": [
        4048,
        992
      ],
      "parameters": {
        "jsCode": "const job = $('\ud83d\udd04 Loop: Each Job2').item.json;\nconst company = $(\"\ud83d\udcbe Save Domain to Sheet2\").item.json;\nconst domain_extraction = $(\"\ud83d\udcdd Parse Classification\").item.json;\n\nreturn [{\n  json: {\n    ...job,\n    ...company,\n    ...domain_extraction\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "26aa2797-df52-4654-83ef-1018a8b59ddd",
      "name": "Fetch HR Links 5",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        1680,
        688
      ],
      "parameters": {
        "url": "https://api.linkfinderai.com",
        "method": "POST",
        "options": {
          "timeout": 60000
        },
        "jsonBody": "={\n  \"type\": \"company_domain_to_employees\",\n  \"input_data\": \"{{ $json.company_website }}\",\n  \"department\": \"operations\",\n  \"seniority\": \"all\",\n  \"employee_count\": 5\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$env.LINKFINDER_API_KEY}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "bcd2d604-dbc6-4006-b762-5f27d7073cbd",
      "name": "Fetch HR Links 6",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        1680,
        864
      ],
      "parameters": {
        "url": "https://api.linkfinderai.com",
        "method": "POST",
        "options": {
          "timeout": 60000
        },
        "jsonBody": "={\n  \"type\": \"company_domain_to_employees\",\n  \"input_data\": \"{{ $json.company_website }}\",\n  \"department\": \"c-suite\",\n  \"seniority\": \"all\",\n  \"employee_count\": 5\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{$env.LINKFINDER_API_KEY}}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "40109ac1-2339-4e22-950b-4bc188ef285c",
  "connections": {
    "Flag as Agency": {
      "main": [
        [
          {
            "node": "Batch Process Items 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch HR Links 5": {
      "main": [
        [
          {
            "node": "Merge Employee Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Fetch HR Links 6": {
      "main": [
        [
          {
            "node": "Merge Employee Data",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Mark as No Domain": {
      "main": [
        [
          {
            "node": "Batch Process Items 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Website Data": {
      "main": [
        [
          {
            "node": "If Website Fetch Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Employer Type": {
      "main": [
        [
          {
            "node": "Flag for Enrichment",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Flag as Agency",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Flag as Agency Type": {
      "main": [
        [
          {
            "node": "Batch Process Items 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Flag for Enrichment": {
      "main": [
        [
          {
            "node": "Batch Process Items 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Employee Data": {
      "main": [
        [
          {
            "node": "AI Select Top Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Email Presence": {
      "main": [
        [
          {
            "node": "Save Contact with Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check LinkedIn Presence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Extracted Text": {
      "main": [
        [
          {
            "node": "AI Classifier for Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Consolidate Job Info": {
      "main": [
        [
          {
            "node": "Update Job Status 4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verify Domain Exists": {
      "main": [
        [
          {
            "node": "Update with Company Domain",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Domain from Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Process Items 1": {
      "main": [
        [],
        [
          {
            "node": "Read Current Company Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Process Items 2": {
      "main": [
        [],
        [
          {
            "node": "Determine Company Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check AI Domain Found": {
      "main": [
        [
          {
            "node": "Update with Company Domain",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mark as No Domain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Actor Dataset 4": {
      "main": [
        [
          {
            "node": "Parse AI Domain Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Actor Dataset 6": {
      "main": [
        [
          {
            "node": "Process in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process LinkedIn Data": {
      "main": [
        [
          {
            "node": "Save Enriched Contact Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process in JavaScript": {
      "main": [
        [
          {
            "node": "Merge Employee Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Save Without LinkedIn": {
      "main": [
        [
          {
            "node": "Update Job Status 4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Classifier for Type": {
      "main": [
        [
          {
            "node": "Parse AI Classification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Select Top Contacts": {
      "main": [
        [
          {
            "node": "Process Selected Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Determine Company Type": {
      "main": [
        [
          {
            "node": "Fetch Actor Dataset 6",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch HR Employees Links",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch HR Links 5",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch HR Links 6",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Flag as Agency Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter New Status Rows": {
      "main": [
        [
          {
            "node": "Batch Process Items 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Google Sheet Rows": {
      "main": [
        [
          {
            "node": "Filter New Status Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check LinkedIn Presence": {
      "main": [
        [
          {
            "node": "Scrape LinkedIn Profile",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Save Without LinkedIn",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Classification": {
      "main": [
        [
          {
            "node": "Check Employer Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Contact with Email": {
      "main": [
        [
          {
            "node": "Consolidate Job Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape LinkedIn Profile": {
      "main": [
        [
          {
            "node": "Process LinkedIn Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch HR Employees Links": {
      "main": [
        [
          {
            "node": "Merge Employee Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter New Status Rows 1": {
      "main": [
        [
          {
            "node": "Batch Process Items 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Website Fetch Success": {
      "main": [
        [
          {
            "node": "Initiate Firecrawl Scraping",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract HTML from Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Execution Trigger": {
      "main": [
        [
          {
            "node": "Read Google Sheet Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Domain Response": {
      "main": [
        [
          {
            "node": "Check AI Domain Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Google Sheet Rows 1": {
      "main": [
        [
          {
            "node": "Filter New Status Rows 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Domain from Email": {
      "main": [
        [
          {
            "node": "Check Email Domain Presence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Selected Contacts": {
      "main": [
        [
          {
            "node": "Check Email Presence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Current Company Data": {
      "main": [
        [
          {
            "node": "Verify Domain Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract HTML from Response": {
      "main": [
        [
          {
            "node": "Clean Extracted Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Enriched Contact Data": {
      "main": [
        [
          {
            "node": "Update Job Status 4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update with Company Domain": {
      "main": [
        [
          {
            "node": "Fetch Website Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Email Domain Presence": {
      "main": [
        [
          {
            "node": "Check AI Domain Found",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fetch Actor Dataset 4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initiate Firecrawl Scraping": {
      "main": [
        [
          {
            "node": "AI Classifier for Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}