{
  "name": "Find & Verify Emails — HubSpot + Apollo + Hunter",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 6,
              "field": "days",
              "daysInterval": 1
            }
          ]
        }
      },
      "id": "schedule-trigger",
      "name": "Daily Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [0, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.hubapi.com/crm/v3/objects/contacts/search",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"filterGroups\": [\n    {\n      \"filters\": [\n        { \"propertyName\": \"email\", \"operator\": \"NOT_HAS_PROPERTY\" },\n        { \"propertyName\": \"firstname\", \"operator\": \"HAS_PROPERTY\" },\n        { \"propertyName\": \"company\", \"operator\": \"HAS_PROPERTY\" }\n      ]\n    }\n  ],\n  \"properties\": [\"firstname\", \"lastname\", \"company\", \"domain\", \"email\"],\n  \"limit\": 50\n}",
        "options": {}
      },
      "id": "search-contacts",
      "name": "Search Contacts",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [220, 0],
      "credentials": {
        "hubspotApi": {
          "id": "credential-id",
          "name": "HubSpot API"
        }
      }
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "id": "loop-contacts",
      "name": "Loop Contacts",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [440, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apollo.io/api/v1/people/match",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $credentials.apolloApi.apiKey }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"first_name\": \"{{ $json.properties.firstname }}\",\n  \"last_name\": \"{{ $json.properties.lastname }}\",\n  \"organization_name\": \"{{ $json.properties.company }}\"\n}",
        "options": {}
      },
      "id": "apollo-lookup",
      "name": "Apollo Lookup",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [660, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.person.email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "isNotEmpty"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "if-email-found",
      "name": "Email Found?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [880, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.person.email_status }}",
              "rightValue": "verified",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "if-verified",
      "name": "Already Verified?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [1100, -100]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://api.hunter.io/v2/email-verifier",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "email",
              "value": "={{ $json.person.email }}"
            },
            {
              "name": "api_key",
              "value": "={{ $credentials.hunterApi.apiKey }}"
            }
          ]
        },
        "options": {}
      },
      "id": "hunter-verify",
      "name": "Hunter Verify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1320, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.data.result }}",
              "rightValue": "deliverable",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "if-deliverable",
      "name": "Is Deliverable?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [1540, 0]
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://api.hubapi.com/crm/v3/objects/contacts/{{ $('Search Contacts').item.json.id }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"properties\": {\n    \"email\": \"{{ $('Apollo Lookup').item.json.person.email }}\",\n    \"email_verification_status\": \"verified\",\n    \"email_source\": \"apollo+hunter\"\n  }\n}",
        "options": {}
      },
      "id": "update-verified",
      "name": "Update Verified Email",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1760, -100],
      "credentials": {
        "hubspotApi": {
          "id": "credential-id",
          "name": "HubSpot API"
        }
      }
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://api.hubapi.com/crm/v3/objects/contacts/{{ $('Search Contacts').item.json.id }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"properties\": {\n    \"email\": \"{{ $('Apollo Lookup').item.json.person.email }}\",\n    \"email_verification_status\": \"verified\",\n    \"email_source\": \"apollo\"\n  }\n}",
        "options": {}
      },
      "id": "update-apollo-verified",
      "name": "Update Apollo-Verified Email",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1320, -200],
      "credentials": {
        "hubspotApi": {
          "id": "credential-id",
          "name": "HubSpot API"
        }
      }
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://api.hubapi.com/crm/v3/objects/contacts/{{ $('Search Contacts').item.json.id }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"properties\": {\n    \"email_verification_status\": \"unverified\",\n    \"email_source\": \"apollo\"\n  }\n}",
        "options": {}
      },
      "id": "update-unverified",
      "name": "Flag Unverified",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1760, 100],
      "credentials": {
        "hubspotApi": {
          "id": "credential-id",
          "name": "HubSpot API"
        }
      }
    },
    {
      "parameters": {
        "amount": 1,
        "unit": "seconds"
      },
      "id": "wait-rate-limit",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [1980, 0]
    }
  ],
  "connections": {
    "Daily Schedule": {
      "main": [[{ "node": "Search Contacts", "type": "main", "index": 0 }]]
    },
    "Search Contacts": {
      "main": [[{ "node": "Loop Contacts", "type": "main", "index": 0 }]]
    },
    "Loop Contacts": {
      "main": [
        [{ "node": "Apollo Lookup", "type": "main", "index": 0 }],
        []
      ]
    },
    "Apollo Lookup": {
      "main": [[{ "node": "Email Found?", "type": "main", "index": 0 }]]
    },
    "Email Found?": {
      "main": [
        [{ "node": "Already Verified?", "type": "main", "index": 0 }],
        [{ "node": "Wait", "type": "main", "index": 0 }]
      ]
    },
    "Already Verified?": {
      "main": [
        [{ "node": "Update Apollo-Verified Email", "type": "main", "index": 0 }],
        [{ "node": "Hunter Verify", "type": "main", "index": 0 }]
      ]
    },
    "Hunter Verify": {
      "main": [[{ "node": "Is Deliverable?", "type": "main", "index": 0 }]]
    },
    "Is Deliverable?": {
      "main": [
        [{ "node": "Update Verified Email", "type": "main", "index": 0 }],
        [{ "node": "Flag Unverified", "type": "main", "index": 0 }]
      ]
    },
    "Update Verified Email": {
      "main": [[{ "node": "Wait", "type": "main", "index": 0 }]]
    },
    "Update Apollo-Verified Email": {
      "main": [[{ "node": "Wait", "type": "main", "index": 0 }]]
    },
    "Flag Unverified": {
      "main": [[{ "node": "Wait", "type": "main", "index": 0 }]]
    },
    "Wait": {
      "main": [[{ "node": "Loop Contacts", "type": "main", "index": 0 }]]
    }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1" },
  "staticData": null,
  "tags": [],
  "triggerCount": 0,
  "active": false,
  "meta": { "instanceId": "", "templateId": "revi-email-finder" }
}
