{
  "id": "s2AEb0vJu4kTrA7-OyXNR",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "apollo leads enrichment",
  "tags": [],
  "nodes": [
    {
      "id": "f71d6066-783b-4d78-b40f-3c236065255a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        432
      ],
      "parameters": {
        "color": "#0F4A52",
        "width": 624,
        "height": 336,
        "content": "# MeldFlow Contacts Creation"
      },
      "typeVersion": 1
    },
    {
      "id": "8a2ff32f-2f63-4246-9f6a-35137e896f58",
      "name": "If Apollo Email Verified",
      "type": "n8n-nodes-base.if",
      "position": [
        -208,
        560
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1b56f333-bf1b-4d5c-88d0-40ced704715b",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.emailStatus }}",
              "rightValue": "=verified"
            },
            {
              "id": "80db2d4a-181b-43eb-8b04-661502e7ec48",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.company }}",
              "rightValue": "="
            },
            {
              "id": "d4da6a83-1a39-4ac2-a593-2b5605d557a3",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.profileUrl }}",
              "rightValue": ""
            },
            {
              "id": "e0c026fd-c0a5-462e-95c6-ac079b0501e0",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.companyLinkedinUrl }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "6f3d56c7-b60b-43c4-842b-197b3933a6a0",
      "name": "Update Page Number",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        784,
        544
      ],
      "parameters": {
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "retryOnFail": true,
      "typeVersion": 4.7
    },
    {
      "id": "366271dd-7d6e-4136-b8d1-f726d84c90c4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        112,
        -320
      ],
      "parameters": {
        "color": 6,
        "width": 864,
        "height": 352,
        "content": "# Apollo Leads Fetching"
      },
      "typeVersion": 1
    },
    {
      "id": "4368e6d6-6f02-41b8-a48c-51525effd29e",
      "name": "Apollo-Enrichment1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        128,
        176
      ],
      "parameters": {
        "url": "https://api.apollo.io/v1/people/match",
        "method": "POST",
        "options": {},
        "jsonBody": "={ \"id\": \"{{ $json.apollo_id }}\" }\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Api-Key",
              "value": "YOUR API KEY"
            },
            {
              "name": "Content-type",
              "value": "application/json"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.3
    },
    {
      "id": "aa22a2cb-676e-49e0-842e-db9f3f0ab83a",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        448,
        176
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "0656c388-a03d-48d9-8b36-c21780564b2b",
      "name": "Sticky Note18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        64
      ],
      "parameters": {
        "color": 3,
        "width": 1232,
        "height": 336,
        "content": "# Apollo Leads Enrichment"
      },
      "typeVersion": 1
    },
    {
      "id": "a58b62a0-37fd-4416-b74a-a559cd6a5dff",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        -320
      ],
      "parameters": {
        "color": 4,
        "width": 352,
        "height": 352,
        "content": "# Trigger"
      },
      "typeVersion": 1
    },
    {
      "id": "d79f188f-a568-4530-bc37-fd962bd6070b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        432
      ],
      "parameters": {
        "color": 2,
        "width": 592,
        "height": 336,
        "content": "# Apollo Page Increment"
      },
      "typeVersion": 1
    },
    {
      "id": "124f7da6-06f8-45c7-b9f9-7c4f93fce592",
      "name": "Loop Over for batching limit",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -208,
        160
      ],
      "parameters": {
        "options": {},
        "batchSize": 10
      },
      "typeVersion": 3
    },
    {
      "id": "c4f860ce-38da-4a2c-8840-7153a3e869c4",
      "name": "Meldflow-Contacts",
      "type": "n8n-nodes-base.httpRequest",
      "maxTries": 5,
      "position": [
        144,
        544
      ],
      "parameters": {
        "url": "https://services.leadconnectorhq.com/contacts/upsert",
        "method": "POST",
        "options": {
          "timeout": 300000,
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"firstName\": \"{{ $json.firstName }}\",\n  \"lastName\": \"{{ $json.lastName }}\",\n  \"email\": \"{{ $json.email || '' }}\",\n  \"phone\": \"{{ $json.phone || '' }}\",\n  \"locationId\": \"YOUR MELDFLOW LOCATION ID\",\n  \"companyName\": \"{{ $json.company || '' }}\",\n  \"address1\": \"{{ $json.location || '' }}\",\n  \"source\": \"{{ $json.source }}\",\n  \"tags\": [\n    \"n8n\",\n    \"Apollo Leads\"\n  ],\n  \"customFields\": [\n    {\n      \"key\": \"job_title\",\n      \"field_value\": \"{{ $json.job_title || '' }}\"\n    },\n    {\n      \"key\": \"email_status\",\n      \"field_value\": \"Verified\"\n    },\n    {\n      \"key\": \"linkedin_url\",\n      \"field_value\": \"{{ $json.profileUrl }}\"\n    },\n    {\n      \"key\": \"companylinkedinurl\",\n      \"field_value\": \"{{ $json.companyLinkedinUrl }}\"\n    },\n    {\n      \"key\": \"industry\",\n      \"field_value\": \"{{ $json.industry || '' }}\"\n    }\n  ]\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Version",
              "value": "2021-07-28"
            },
            {
              "name": "Aaccept",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "YOUR PRIVATE INTEGRATION TOKEN"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.3,
      "waitBetweenTries": 5000
    },
    {
      "id": "f3e5c9bc-6c5c-435d-8e8e-a8ce80570424",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        496,
        544
      ],
      "parameters": {
        "unit": "minutes",
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "fbea96cd-931d-4bba-95cc-b3372a495e4e",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -144,
        -208
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "=0 8 * * 1-5"
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "5dbb1dd3-36cf-4c0d-b6ec-63af1ce65f2f",
      "name": "Apollo lead search",
      "type": "n8n-nodes-base.httpRequest",
      "maxTries": 5,
      "position": [
        480,
        -208
      ],
      "parameters": {
        "url": "https://api.apollo.io/api/v1/mixed_people/api_search",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"page\": {{ $json.Apollo_Page }},\n  \"per_page\": 75,\n  \"contact_email_status\": [\"verified\"],\n\n  \"person_titles\": [\n    \"owner\",\n    \"founder\",\n    \"partner\",\n    \"president\",\n    \"principal\",\n    \"ceo\",\n    \"certified public accountant\",\n    \"cpa\",\n    \"tax partner\",\n    \"tax director\",\n    \"accounting firm owner\",\n    \"owner cpa\",\n    \"managing partner cpa\",\n    \"enrolled agent\",\n    \"bookkeeper owner\",\n    \"controller\"\n],\n\n  \"person_locations\": [\"United States\"],\n  \"organization_locations\": [\"United States\"],\n\n  \"organization_industries\": [\n    \"accounting\",\n    \"financial services\",\n    \"audit services\",\n    \"bookkeeping services\",\n    \"tax services\",\n    \"financial services\",\n    \"banking\",\n    \"capital markets\",\n    \"investment management\",\n    \"venture capital & private equity\"\n  ],\n\n  \"organization_num_employees_ranges\": [\"1,25,50\"],\n\n  \"revenue_range\": {\n    \"min\": 150000,\n    \"max\": 5000000\n  },\n\n \"q_organization_keyword_tags\": [\n  \"accounting\",\n  \"accounting firm\",\n  \"tax services\",\n  \"tax preparation\",\n  \"tax consulting\",\n  \"tax advisory\",\n  \"cpa firm\",\n  \"certified public accountant\",\n  \"bookkeeping\",\n  \"bookkeeping services\",\n  \"payroll services\",\n  \"financial services\",\n  \"audit services\",\n  \"auditing\",\n  \"financial advisory\",\n  \"sales tax\",\n  \"irs representation\",\n  \"forensic accounting\"\n],\n\n  \"exclude_organization_industries\": [\n  \"marketing and advertising\",\n  \"information technology & services\",\n  \"computer & network security\",\n  \"transportation/trucking/railroad\",\n  \"automotive\",\n  \"construction\",\n  \"information technology\",\n  \"software\",\n  \"graphics\",\n  \"staffing & recruiting\"\n]\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "X-Api-Key",
              "value": "YOUR API KEY"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.3,
      "waitBetweenTries": 5000
    },
    {
      "id": "93cf6c8d-3d0b-45c7-917e-b2ad6f30c073",
      "name": "Data Filtering & Formatting",
      "type": "n8n-nodes-base.set",
      "position": [
        784,
        144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9e2fca9a-654a-4367-a817-cb901ed8fab7",
              "name": "id",
              "type": "string",
              "value": "={{ $json.person.id }}"
            },
            {
              "id": "e88373b5-2501-42ca-a3b0-7d133456a14e",
              "name": "firstName",
              "type": "string",
              "value": "={{ $json.person.first_name }}"
            },
            {
              "id": "a07431da-e5b3-44fc-86ff-ea50aad7b2d8",
              "name": "lastName",
              "type": "string",
              "value": "={{ $json.person.last_name }}"
            },
            {
              "id": "a5af38c6-46ed-4970-bde1-0decce085c66",
              "name": "name",
              "type": "string",
              "value": "={{ $json.person.name }}"
            },
            {
              "id": "9c1e90ca-e5ca-42cd-bbb4-caaa86be2e93",
              "name": "profileUrl",
              "type": "string",
              "value": "={{ $json.person.linkedin_url }}"
            },
            {
              "id": "93a8943e-e056-4e58-a509-df756261b9c3",
              "name": "job_title",
              "type": "string",
              "value": "={{ $json.person.title }}"
            },
            {
              "id": "fc8fad53-ff06-4935-8257-2a22e48cda4d",
              "name": "country",
              "type": "string",
              "value": "={{ $json.person.country }}"
            },
            {
              "id": "ef1aaf86-3170-4390-ad27-2c47f702bb5e",
              "name": "email",
              "type": "string",
              "value": "={{ $json.person.email }}"
            },
            {
              "id": "4590c4eb-5ccd-4ebe-8352-d86fc3b52a14",
              "name": "emailStatus",
              "type": "string",
              "value": "={{ $json.person.email_status }}"
            },
            {
              "id": "3a2dfd28-bd7a-47e1-87d8-fae34a0afa55",
              "name": "company",
              "type": "string",
              "value": "={{ $json.person.organization.name }}"
            },
            {
              "id": "51de70df-225e-44fa-9914-993fa2bb0dad",
              "name": "phone",
              "type": "string",
              "value": "={{ $json.person.organization.primary_phone.number }}"
            },
            {
              "id": "317c48da-deeb-45ef-abc8-5a1ba13418e9",
              "name": "companyWebsiteUrl",
              "type": "string",
              "value": "={{ $json.person.organization.website_url }}"
            },
            {
              "id": "79b7eba8-b0b1-4bc0-90ef-7b5a72111c11",
              "name": "companyLinkedinUrl",
              "type": "string",
              "value": "={{ $json.person.organization.linkedin_url }}"
            },
            {
              "id": "3d354052-62f4-4df8-8296-4fbb0fcd050b",
              "name": "source",
              "type": "string",
              "value": "Apollo"
            },
            {
              "id": "42b6ddf6-0661-4b4e-9030-7bc0a83a15f9",
              "name": "industry",
              "type": "string",
              "value": "={{ $json.person.organization.industry }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "5604c3eb-759a-4edc-a885-2cbc2a1606b9",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        -528
      ],
      "parameters": {
        "color": 5,
        "width": 528,
        "height": 1536,
        "content": "## Overview\n\nThis workflow automatically:\n\n1. Fetches leads from Apollo based on predefined ICP filters\n2. Enriches each lead using Apollo enrichment endpoint\n3. Filters only verified contacts\n4. Formats lead data\n5. Creates/updates contacts inside MeldFlow / GHL\n6. Increments the Apollo page number for next scheduled execution ( to handle Apollo Pagination )\n---\n\n## Customizing Lead Search\n\nInside:\n\n* Apollo lead search node\n\nYou can modify:\n\n* Job titles\n* Industries\n* Revenue ranges\n* Employee ranges\n* Countries\n* Keywords\n* Excluded industries\n\nThis controls the ICP targeting logic.\n\n---\n\n## Recommended Usage\n\n* Run on schedule (daily/weekday)\n* Keep Apollo rate limits in mind\n* Batch size is currently set to 10\n* Wait nodes help avoid API throttling\n\n---\n\n## Output\n\nVerified enriched leads are automatically created/updated in:\n\n* MeldFlow Contacts\n\nWith:\n\n* Name\n* Email\n* Phone\n* LinkedIn\n* Company\n* Industry\n* Job Title\n* Custom fields\n* Tags\n\n---\n\n## Important Notes\n\n* Only verified Apollo emails are processed\n* Duplicate contacts are handled through GHL upsert\n* Workflow uses page increment logic to continuously fetch new leads\n* Update custom field keys in GHL if your account uses different field IDs\n"
      },
      "typeVersion": 1
    },
    {
      "id": "267f61f3-59af-4bef-a861-d6e6345bbafb",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        -448
      ],
      "parameters": {
        "color": 4,
        "width": 432,
        "height": 1360,
        "content": "## Required Setup Before Using\n\n### 1. Apollo API Key\n\nReplace:\n\n* `YOUR API KEY`\n\nInside:\n\n* Apollo lead search node\n* Apollo-Enrichment node\n\nGet API Key From:\nApollo \u2192 Settings \u2192 Integrations \u2192 API\n\n---\n### 2. MeldFlow / GHL Private Integration Token\n\nReplace:\n\n* `YOUR PRIVATE INTEGRATION TOKEN`\n\nInside:\n\n* Meldflow-Contacts node\n\nGet Token From:\nCRM \u2192 Settings \u2192 Private Integrations\n\n---\n\n### 3. MeldFlow / GHL Location ID\n\nReplace:\n\n* `YOUR MELDFLOW LOCATION ID`\n\nInside:\n\n* Meldflow-Contacts node\n\nThis should be your target sub-account/location ID.\n\n---\n\n### 4. Google Sheets Setup\n\nCreate a Google Sheet with:\n\n* Config_Sheet\n\nRequired Columns:\n\n* Id\n* Apollo_Page\n\nExample:\n\n| Id | Apollo_Page |\n| -- | ----------- |\n| 1  | 1           |\n\nThe workflow automatically increments this page after execution.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2c5b2d80-f04f-46a4-883f-6bb23d76380b",
      "name": "Extract ID",
      "type": "n8n-nodes-base.code",
      "position": [
        768,
        -208
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst ids = [];\n\nfor (const item of items) {\n  const people = item.json.people || [];\n  \n  for (const person of people) {\n    ids.push({\n      apollo_id: person.id,\n      first_name: person.first_name,\n      title: person.title,\n      company_name: person.organization?.name || ''\n    });\n  }\n}\n\nconsole.log(`Found ${ids.length} people to enrich`);\nreturn ids;"
      },
      "typeVersion": 2
    },
    {
      "id": "71bd5212-60df-488e-8f90-443f6f284a8e",
      "name": "Get Apollo Page",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        192,
        -208
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.7
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "513a34ca-a17c-4912-b006-2128e2d66afc",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Update Page Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Loop Over for batching limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract ID": {
      "main": [
        [
          {
            "node": "Loop Over for batching limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Apollo Page": {
      "main": [
        [
          {
            "node": "Apollo lead search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Apollo Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Meldflow-Contacts": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apollo lead search": {
      "main": [
        [
          {
            "node": "Extract ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apollo-Enrichment1": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Apollo Email Verified": {
      "main": [
        [
          {
            "node": "Meldflow-Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Data Filtering & Formatting": {
      "main": [
        [
          {
            "node": "If Apollo Email Verified",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over for batching limit": {
      "main": [
        [
          {
            "node": "Data Filtering & Formatting",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Apollo-Enrichment1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}