{
  "name": "Generate Qualified Finance Leads from LinkedIn with Apify, GPT-4, and Airtable",
  "tags": [],
  "nodes": [
    {
      "id": "398b747b-1340-43b7-9c9e-49cd948711b4",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        80,
        520
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "edit-variables-node",
      "name": "Edit Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        260,
        520
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "config_linkedin_urls",
              "name": "linkedinUrls",
              "type": "string",
              "value": "https://www.linkedin.com/jobs/search/?keywords=CFO&location=United%20States"
            },
            {
              "id": "config_max_employees",
              "name": "maxEmployees",
              "type": "number",
              "value": 200
            },
            {
              "id": "config_batch_size",
              "name": "batchSize",
              "type": "number",
              "value": 5
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "87b76690-123f-4bce-ba3f-4752b143276a",
      "name": "Scrape LinkedIn Jobs",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        420,
        520
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/curious_coder~linkedin-jobs-scraper/run-sync-get-dataset-items",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n    \"count\": 750,\n    \"scrapeCompany\": true,\n    \"urls\": [\n        \"{{ $('Edit Variables').item.json.linkedinUrls }}\"\n    ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "apifyApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "1878c155-6e6d-4600-ae4c-defca1acc6a1",
      "name": "Split Job Data",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        600,
        520
      ],
      "parameters": {
        "include": "selectedOtherFields",
        "options": {},
        "fieldToSplitOut": "companyName",
        "fieldsToInclude": "title, link, descriptionText, postedAt, companyLinkedinUrl, jobPosterName, seniorityLevel, industries, companyEmployeesCount, location, jobPosterProfileUrl"
      },
      "typeVersion": 1
    },
    {
      "id": "2dc5487e-dec2-42c6-84fd-96bb8d4c3955",
      "name": "Remove Duplicates",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        820,
        520
      ],
      "parameters": {
        "compare": "selectedFields",
        "options": {},
        "fieldsToCompare": "companyName"
      },
      "typeVersion": 2
    },
    {
      "id": "b8fde371-32bc-473e-be51-9927a5c0d660",
      "name": "Clean Data Format",
      "type": "n8n-nodes-base.set",
      "position": [
        1100,
        520
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7e3c28ee-e9bc-4e13-9615-f6a339d53f40",
              "name": "company_name",
              "type": "string",
              "value": "={{ $json.companyName }}"
            },
            {
              "id": "51697efd-3564-48e8-b7c6-442a819d37a7",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "23ff3936-c963-485c-8576-7aae534f8758",
              "name": "job_link",
              "type": "string",
              "value": "={{ $json.link }}"
            },
            {
              "id": "52ae4935-d361-43ae-aa76-ffc1d8e184ff",
              "name": "description",
              "type": "string",
              "value": "={{ $json.descriptionText }}"
            },
            {
              "id": "e5f9077c-71a3-41dd-91b2-d7e187b56ba1",
              "name": "posted_at",
              "type": "string",
              "value": "={{ $json.postedAt }}"
            },
            {
              "id": "39ef0ce0-718b-47b1-8138-0bf2246fba51",
              "name": "company_link",
              "type": "string",
              "value": "={{ $json.companyLinkedinUrl }}"
            },
            {
              "id": "d4559f9b-e602-42f6-ba8d-05d0e4332a89",
              "name": "job_poster",
              "type": "string",
              "value": "={{ $json.jobPosterName }}"
            },
            {
              "id": "24590a98-f2d3-437a-b656-8538ce961b43",
              "name": "seniority_level",
              "type": "string",
              "value": "={{ $json.seniorityLevel }}"
            },
            {
              "id": "bc1eecff-0570-4c0f-ac5b-a5d7f5c53ec0",
              "name": "industry",
              "type": "string",
              "value": "={{ $json.industries }}"
            },
            {
              "id": "e+1234567890f-9c09-fa54689e7659",
              "name": "company_employees",
              "type": "number",
              "value": "={{ $json.companyEmployeesCount }}"
            },
            {
              "id": "02c838e5-8977-47c0-bdd7-31bbe9166ed9",
              "name": "location",
              "type": "string",
              "value": "={{ $json.location }}"
            },
            {
              "id": "0973a0ab-d251-4ef0-ba71-ad19d8cce744",
              "name": "jobposter_profile",
              "type": "string",
              "value": "={{ $json.jobPosterProfileUrl }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "afda4d35-13d0-4cda-9cb9-4a2286b9b184",
      "name": "Get Existing Leads",
      "type": "n8n-nodes-base.airtable",
      "position": [
        80,
        780
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_AIRTABLE_BASE_ID"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_AIRTABLE_TABLE_ID"
        },
        "options": {
          "fields": [
            "company_name",
            "jobposter_profile",
            "company_link",
            "company_category",
            "job_summary"
          ]
        },
        "operation": "search"
      },
      "executeOnce": true,
      "typeVersion": 2.1
    },
    {
      "id": "677427b0-7d4e-4d9d-b429-c30325737106",
      "name": "Categorize Leads",
      "type": "n8n-nodes-base.code",
      "position": [
        360,
        780
      ],
      "parameters": {
        "jsCode": "// Lead deduplication and categorization logic\nconst existingLeads = $('Get Existing Leads').all().map(i => i.json);\nconst newLeads = $('Clean Data Format').all().map(i => i.json);\n\nreturn newLeads.map(lead => {\n  const match = existingLeads.find(existing =>\n    existing.company_name?.toLowerCase().trim() === lead.company_name?.toLowerCase().trim()\n  );\n\n  const existingSummary = match?.job_summary ?? '';\n  const existingJobPoster = match?.jobposter_profile ?? '';\n\n  const isSummaryMissing = existingSummary.trim() === '';\n  const isJobPosterMissing = existingJobPoster.trim() === '';\n\n  let category;\n  let processingReason = '';\n\n  if (!match || isSummaryMissing) {\n    category = 1;\n    processingReason = !match ? 'New company lead' : 'Existing lead missing AI analysis';\n  } else if (isJobPosterMissing) {\n    category = 2;\n    processingReason = 'Lead ready for enrichment';\n  } else {\n    category = 3;\n    processingReason = 'Complete lead - already processed';\n  }\n\n  return {\n    ...lead,\n    category,\n    processingReason,\n    isExistingLead: !!match\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "9a6b3cde-c69a-44a4-8540-2487aeecfbb2",
      "name": "Route Leads",
      "type": "n8n-nodes-base.switch",
      "position": [
        1080,
        780
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "New Leads",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "e02f6478-e7bf-428c-8350-1f463062743c",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.category }}",
                    "rightValue": 1
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Incomplete Leads",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "02aae098-3b8b-46fa-9917-de8d5d9af1f5",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.category }}",
                    "rightValue": 2
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Existing Leads",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9fbed109-bbcf-455a-bcb4-ef084b2a92da",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.category }}",
                    "rightValue": 3
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "e2e6007c-7516-4cc0-b9fb-95177b325ed6",
      "name": "Filter by Company Size",
      "type": "n8n-nodes-base.filter",
      "position": [
        1560,
        440
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "70a23b0e-95ea-4f8a-97d2-4e99286aee51",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ $json.company_employees }}",
              "rightValue": "={{ $('Edit Variables').item.json.maxEmployees }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2da665f1-7988-4d00-bf3f-27ac773bdbb1",
      "name": "Process in Batches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1980,
        440
      ],
      "parameters": {
        "options": {},
        "batchSize": "={{ $('Edit Variables').item.json.batchSize }}"
      },
      "typeVersion": 3
    },
    {
      "id": "7c5374bf-e25c-4230-bb8d-93003584912c",
      "name": "AI Lead Analyzer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2340,
        460
      ],
      "parameters": {
        "text": "=You are a professional lead qualification assistant specializing in finance and accounting roles.\n\nAnalyze this job posting:\nCompany: {{ $json.company_name }}\nJob Title: {{ $json.title }}\nDescription: {{ $json.description }}\nCompany Link: {{ $json.company_link }}\n\nCategorize according to:\n\n1. Company Category:\n   - \"Consumer\": Companies hiring for their own operations\n   - \"Fractional CFO\": Companies providing fractional CFO services\n   - \"Recruiting\": Recruitment agencies\n   - \"Other\": None of the above\n\n2. Finance Job: Is this truly a finance-related position?\n\n3. Seniority Level: Entry, Mid, Senior, Director, C-Level\n\n4. Summary: One-line role description\n\nReturn JSON format only.",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "executeOnce": false,
      "typeVersion": 1.9
    },
    {
      "id": "a97f82fd-539f-44a5-a377-a39dfc155ee6",
      "name": "OpenAI GPT-4 Mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2340,
        160
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "752cc07b-2148-432f-bef5-f7bf84444d10",
      "name": "Structure AI Output",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2500,
        160
      ],
      "parameters": {
        "jsonSchemaExample": "{\n    \"company_name\": \"TechCorp Inc\",\n    \"company_link\": \"https://linkedin.com/company/techcorp\",\n    \"seniority_level\": \"C-Level\",\n    \"is_finance_job\": true,\n    \"company_category\": \"Consumer\",\n    \"recap\": \"CFO role for financial strategy\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "58e36890-5c35-4ee8-9908-f8bdf5691c2b",
      "name": "Save to Airtable",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2800,
        460
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_AIRTABLE_BASE_ID"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_AIRTABLE_TABLE_ID"
        },
        "columns": {
          "value": {
            "job_summary": "={{ $json.output.recap }}",
            "company_link": "={{ $('Process in Batches').item.json.company_link }}",
            "company_name": "={{ $('Process in Batches').item.json.company_name }}",
            "is_finance_job": "={{ $json.output.is_finance_job }}",
            "seniority_level": "={{ $json.output.seniority_level }}",
            "company_category": "={{ $json.output.company_category }}"
          },
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "company_name"
          ]
        },
        "options": {},
        "operation": "upsert"
      },
      "typeVersion": 2.1
    },
    {
      "id": "d2b3b56f-a0ef-44c2-b73f-5acdb3a51391",
      "name": "Workflow Complete",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1540,
        1140
      ],
      "parameters": {},
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "91825cfc-5906-4257-9f43-4cab81b1f34e",
      "name": "Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 1300,
        "height": 400,
        "content": "## \ud83c\udfaf Qualified Finance Lead Generation\n\n**Generate high-quality finance leads from LinkedIn**\n\n### Required:\n\u2705 Airtable (Free tier OK)\n\u2705 Apify (14-day trial) \n\u2705 OpenAI (Pay-per-use)\n\n### What it does:\n1. Scrapes LinkedIn finance jobs\n2. Filters by company size\n3. AI analyzes & categorizes\n4. Saves qualified leads to Airtable"
      },
      "typeVersion": 1
    },
    {
      "id": "358381b4-7086-45db-a75d-76dec377bb18",
      "name": "Data Collection",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        400
      ],
      "parameters": {
        "color": 5,
        "width": 1300,
        "height": 400,
        "content": "## \ud83d\udcca Data Collection\n\n**LinkedIn Job Scraping**\n- Apify scraper for reliable data\n- Configurable search parameters\n- Company & job information\n\n**Data Processing**\n- Remove duplicates\n- Filter by company size\n- Clean data format"
      },
      "typeVersion": 1
    },
    {
      "id": "83bfb584-0856-4df8-8ad6-68870c9302bf",
      "name": "Lead Intelligence",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        800
      ],
      "parameters": {
        "color": 3,
        "width": 1300,
        "height": 520,
        "content": "## \ud83d\udd04 Lead Intelligence\n\n**Smart Categorization**\n- Category 1: New leads (process with AI)\n- Category 2: Incomplete leads\n- Category 3: Complete leads (skip)\n\n**Benefits**\n- Reduces API costs\n- Avoids re-processing\n- Optimizes workflow efficiency"
      },
      "typeVersion": 1
    },
    {
      "id": "0129e4dc-e119-4db8-9c46-8bb0db273626",
      "name": "AI Qualification",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1300,
        0
      ],
      "parameters": {
        "color": 6,
        "width": 1800,
        "height": 600,
        "content": "## \ud83e\udd16 AI-Powered Qualification\n\n**GPT-4 Mini Analysis**\n- Company categorization\n- Finance role validation  \n- Seniority assessment\n- Job summarization\n\n**Structured Output**\n- JSON schema validation\n- Consistent data format\n- Ready for CRM integration"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "enhanced-linkedin-lead-gen-v2",
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Edit Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Leads": {
      "main": [
        [
          {
            "node": "Filter by Company Size",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Workflow Complete",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Workflow Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Variables": {
      "main": [
        [
          {
            "node": "Scrape LinkedIn Jobs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Job Data": {
      "main": [
        [
          {
            "node": "Remove Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Lead Analyzer": {
      "main": [
        [
          {
            "node": "Save to Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Categorize Leads": {
      "main": [
        [
          {
            "node": "Route Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Airtable": {
      "main": [
        [
          {
            "node": "Process in Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Data Format": {
      "main": [
        [
          {
            "node": "Get Existing Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4 Mini": {
      "ai_languageModel": [
        [
          {
            "node": "AI Lead Analyzer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates": {
      "main": [
        [
          {
            "node": "Clean Data Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Existing Leads": {
      "main": [
        [
          {
            "node": "Categorize Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process in Batches": {
      "main": [
        [],
        [
          {
            "node": "AI Lead Analyzer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structure AI Output": {
      "ai_outputParser": [
        [
          {
            "node": "AI Lead Analyzer",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Scrape LinkedIn Jobs": {
      "main": [
        [
          {
            "node": "Split Job Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter by Company Size": {
      "main": [
        [
          {
            "node": "Process in Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}