{
  "name": "Form Enrichment + Waterfall Fallback",
  "nodes": [
    {
      "id": "f3c6c975-06cc-4e41-a18f-955709b5091b",
      "name": "\ud83d\udccb Form Enrichment with Waterfall Fallback",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        -540
      ],
      "parameters": {
        "width": 900,
        "height": 520,
        "content": "## Enrich Form Leads with Lusha and Waterfall Fallback Provider\n\n**Who it's for:** Growth & Ops teams who need maximum data coverage\n\n**What it does:** Enriches form leads first with Lusha, then calls a fallback provider only if key fields (email or phone) are missing. Merged data is synced to HubSpot and an SDR is alerted on Slack. Reduces costs while maximizing coverage.\n\n### How it works\n1. Receives form submission via webhook and validates the email\n2. Enriches with Lusha (primary provider)\n3. If email or phone is missing \u2192 calls a fallback HTTP enrichment provider\n4. Merges all data from both sources into one clean record\n5. Creates/updates HubSpot contact and notifies SDR on Slack\n6. Returns the enriched record to the form\n\n### Setup\n1. Install the [Lusha community node](https://www.npmjs.com/package/@lusha-org/n8n-nodes-lusha)\n2. Add your Lusha API, HubSpot OAuth2, and Slack credentials\n3. Configure the fallback HTTP node with your secondary provider's API endpoint and key\n4. Point your form's action URL to the webhook endpoint"
      },
      "typeVersion": 1
    },
    {
      "id": "33f8b565-a875-4154-9e33-4290a9066b9d",
      "name": "\u26a1 1. Receive & Validate",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -30,
        50
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 270,
        "content": "Webhook receives the form POST. A code node validates the email format before enrichment.\n\n**Nodes:** Webhook \u2192 Validate Email\n\n\ud83d\udca1 Add more validation rules (e.g., block free email domains) in the code node."
      },
      "typeVersion": 1
    },
    {
      "id": "6bbff01a-2c40-4578-b926-dbab003962ea",
      "name": "\ud83e\udd47 2. Lusha (Primary Enrichment)",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        50
      ],
      "parameters": {
        "color": 7,
        "width": 500,
        "height": 270,
        "content": "Lusha is always called first as the primary enrichment provider. If both email and phone are found, the fallback provider is skipped entirely \u2014 saving API credits.\n\n**Nodes:** Lusha Enrich \u2192 Missing Email or Phone? (IF)\n\n\ud83d\udcd6 [Lusha API docs](https://www.lusha.com/docs/)"
      },
      "typeVersion": 1
    },
    {
      "id": "6f67ef59-2f0c-4e9f-a60c-6d2944e2a188",
      "name": "\ud83e\udd48 3. Fallback + Merge",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        950,
        50
      ],
      "parameters": {
        "color": 7,
        "width": 500,
        "height": 270,
        "content": "When Lusha data is incomplete, a fallback HTTP provider fills the gaps. Both paths merge into a single clean record. If Lusha data is complete, the fallback is skipped.\n\n**Nodes:** Fallback HTTP \u2192 Merge (Fallback) / Merge (Lusha Complete)\n\n\ud83d\udca1 Replace the fallback URL with your secondary provider's API."
      },
      "typeVersion": 1
    },
    {
      "id": "7ba12faf-efee-4d8a-ab52-632f817c2cac",
      "name": "\ud83d\udcbe 4. CRM + Slack + Response",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1500,
        50
      ],
      "parameters": {
        "color": 7,
        "width": 500,
        "height": 270,
        "content": "The merged record is synced to HubSpot (create or update), an SDR alert is sent to Slack, and the enriched data is returned to the form as a JSON response.\n\n**Nodes:** Upsert HubSpot \u2192 Slack Alert \u2192 Webhook Response"
      },
      "typeVersion": 1
    },
    {
      "id": "631823aa-513d-4ff8-8194-8250668e9e99",
      "name": "Receive Form Submission",
      "type": "n8n-nodes-base.webhook",
      "position": [
        0,
        400
      ],
      "parameters": {
        "path": "form-enrichment-waterfall",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "46488728-9407-4f7a-9768-071b4bdb7e32",
      "name": "Validate Email",
      "type": "n8n-nodes-base.code",
      "position": [
        280,
        400
      ],
      "parameters": {
        "jsCode": "// Validate email from form\nconst body = $json.body || $json;\nconst email = (body.email || '').trim().toLowerCase();\nif (!email || !email.includes('@')) {\n  throw new Error('Invalid or missing email');\n}\nreturn { json: { email, firstName: body.firstName || '', lastName: body.lastName || '', company: body.company || '', source: body.source || 'web-form' } };"
      },
      "typeVersion": 2
    },
    {
      "id": "357e40a4-90b7-49f7-ae60-d16f993908b0",
      "name": "Enrich with Lusha",
      "type": "@lusha-org/n8n-nodes-lusha.lusha",
      "position": [
        560,
        400
      ],
      "parameters": {
        "email": "={{ $json.email }}",
        "searchBy": "email",
        "operation": "enrichSingle",
        "contactEnrichAdditionalOptions": {}
      },
      "credentials": {
        "lushaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "88759d34-a61f-4f36-bed5-c749f439d9a8",
      "name": "Missing Email or Phone?",
      "type": "n8n-nodes-base.if",
      "position": [
        840,
        400
      ],
      "parameters": {
        "conditions": {
          "combinator": "or",
          "conditions": [
            {
              "id": "f5f99359-21c7-4085-986b-e41ea4823598",
              "operator": {
                "type": "string",
                "operation": "empty"
              },
              "leftValue": "={{ $json.primaryEmail }}",
              "rightValue": ""
            },
            {
              "id": "1c0c85fb-ce51-45a0-b037-d127963c004a",
              "operator": {
                "type": "string",
                "operation": "empty"
              },
              "leftValue": "={{ $json.primaryPhone }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e22d27e7-5687-40c7-9d9f-8ccf09f1ef8f",
      "name": "Fallback Provider Enrichment",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1120,
        280
      ],
      "parameters": {
        "url": "https://api.fallback-provider.com/enrich",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "email",
              "value": "={{ $('Validate Email').first().json.email }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4
    },
    {
      "id": "0866c973-0d7c-4069-94c9-1c859a7c7e86",
      "name": "Merge All Data (Fallback)",
      "type": "n8n-nodes-base.code",
      "position": [
        1400,
        280
      ],
      "parameters": {
        "jsCode": "// Merge Lusha + fallback data, preferring Lusha where available\nconst form = $('Validate Email').first().json;\nconst lusha = $('Enrich with Lusha').first().json;\nconst fb = $json;\n\nreturn { json: {\n  email: form.email,\n  firstName: form.firstName || lusha.firstName || fb.firstName || '',\n  lastName: form.lastName || lusha.lastName || fb.lastName || '',\n  company: form.company || lusha.companyName || fb.company || '',\n  jobTitle: lusha.jobTitle || fb.jobTitle || '',\n  seniority: lusha.seniority || fb.seniority || '',\n  phone: lusha.primaryPhone || fb.phone || '',\n  verifiedEmail: lusha.primaryEmail || fb.email || '',\n  companyDomain: lusha.companyDomain || fb.domain || '',\n  companySize: lusha.companySize || fb.companySize || '',\n  industry: lusha.companyMainIndustry || fb.industry || '',\n  revenueRange: lusha.revenueRange || '',\n  linkedinUrl: lusha.linkedinProfile || '',\n  enrichmentSource: lusha.primaryEmail ? 'lusha+fallback' : 'fallback',\n  source: form.source,\n  enrichedAt: new Date().toISOString()\n} };"
      },
      "typeVersion": 2
    },
    {
      "id": "0d581bdc-fe15-4878-9337-d52d81948110",
      "name": "Merge Data (Lusha Complete)",
      "type": "n8n-nodes-base.code",
      "position": [
        1120,
        540
      ],
      "parameters": {
        "jsCode": "// Lusha data was complete \u2014 merge with form data\nconst form = $('Validate Email').first().json;\nconst lusha = $json;\n\nreturn { json: {\n  email: form.email,\n  firstName: form.firstName || lusha.firstName || '',\n  lastName: form.lastName || lusha.lastName || '',\n  company: form.company || lusha.companyName || '',\n  jobTitle: lusha.jobTitle || '',\n  seniority: lusha.seniority || '',\n  phone: lusha.primaryPhone || '',\n  verifiedEmail: lusha.primaryEmail || '',\n  companyDomain: lusha.companyDomain || '',\n  companySize: lusha.companySize || '',\n  industry: lusha.companyMainIndustry || '',\n  revenueRange: lusha.revenueRange || '',\n  linkedinUrl: lusha.linkedinProfile || '',\n  enrichmentSource: 'lusha',\n  source: form.source,\n  enrichedAt: new Date().toISOString()\n} };"
      },
      "typeVersion": 2
    },
    {
      "id": "02eca794-e000-4f7f-993d-c93b0e72b44f",
      "name": "Upsert HubSpot Contact",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1700,
        300
      ],
      "parameters": {
        "email": "={{ $json.email }}",
        "resource": "contact",
        "operation": "upsert",
        "additionalFields": {
          "phone": "={{ $json.phone }}",
          "company": "={{ $json.company }}",
          "website": "={{ $json.companyDomain }}",
          "industry": "={{ $json.industry }}",
          "jobtitle": "={{ $json.jobTitle }}",
          "lastName": "={{ $json.lastName }}",
          "firstName": "={{ $json.firstName }}"
        }
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "d1a765d2-aa76-4a61-8390-42be765ff1d8",
      "name": "SDR Slack Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        1700,
        500
      ],
      "parameters": {
        "text": "=\ud83d\udce5 *Enriched Lead (Waterfall)*\n\n*{{ $('Upsert HubSpot Contact').item.json.firstName }} {{ $('Upsert HubSpot Contact').item.json.lastName }}*\n{{ $('Upsert HubSpot Contact').item.json.jobTitle }} at {{ $('Upsert HubSpot Contact').item.json.company }}\n\ud83d\udce7 {{ $('Upsert HubSpot Contact').item.json.verifiedEmail }}\n\ud83d\udcf1 {{ $('Upsert HubSpot Contact').item.json.phone || 'N/A' }}\nSource: {{ $('Upsert HubSpot Contact').item.json.enrichmentSource }}",
        "channel": "#inbound-leads",
        "otherOptions": {}
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "42cb0de4-9902-429d-b46f-f9bacf111e69",
      "name": "Return Enriched Lead",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2000,
        400
      ],
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "respondWith": "json",
        "responseBody": "={{ $json }}"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Validate Email": {
      "main": [
        [
          {
            "node": "Enrich with Lusha",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enrich with Lusha": {
      "main": [
        [
          {
            "node": "Missing Email or Phone?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert HubSpot Contact": {
      "main": [
        [
          {
            "node": "SDR Slack Alert",
            "type": "main",
            "index": 0
          },
          {
            "node": "Return Enriched Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Missing Email or Phone?": {
      "main": [
        [
          {
            "node": "Fallback Provider Enrichment",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge Data (Lusha Complete)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive Form Submission": {
      "main": [
        [
          {
            "node": "Validate Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge All Data (Fallback)": {
      "main": [
        [
          {
            "node": "Upsert HubSpot Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Data (Lusha Complete)": {
      "main": [
        [
          {
            "node": "Upsert HubSpot Contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fallback Provider Enrichment": {
      "main": [
        [
          {
            "node": "Merge All Data (Fallback)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}