{
  "schema_version": "1.0.0",
  "id": "apollo-enrich-hubspot-contact",
  "title": "Enrich a new HubSpot contact with Apollo company data",
  "category": "scraping-enrichment",
  "difficulty": "intermediate",
  "featured": false,
  "description": "When a contact with a work email lands in HubSpot, look the company up in Apollo and write industry, headcount, and location back to the contact.",
  "tags": [
    "hubspot",
    "apollo",
    "enrichment",
    "crm"
  ],
  "apps": [
    "HubSpot",
    "Code by Zapier",
    "Filter by Zapier",
    "Apollo"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 4 steps after the trigger",
      "Filter by Zapier"
    ]
  },
  "tasks": {
    "typical": 3,
    "max": 3
  },
  "trigger": {
    "app": "HubSpot",
    "event": "New Contact",
    "kind": "polling",
    "title": "New HubSpot contact",
    "why": "Fires for every contact created in HubSpot, from forms, imports, or by hand.",
    "config": {
      "Account": "YOUR_HUBSPOT_ACCOUNT"
    },
    "outputs": [
      "contact_id",
      "email",
      "firstname",
      "lastname",
      "company",
      "lifecyclestage",
      "createdate"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "domain",
      "kind": "code",
      "app": "Code by Zapier",
      "event": "Run JavaScript",
      "title": "Split the email domain",
      "why": "Gets the company domain and says whether it is a free mailbox. Gmail and Outlook addresses have no company to enrich.",
      "code": {
        "language": "javascript",
        "module": "email-domain",
        "file": "code/email-domain.js"
      },
      "input_data": {
        "email": "{{trigger.email}}"
      },
      "outputs": [
        "valid",
        "domain",
        "is_free_provider",
        "is_role_address",
        "company_guess",
        "website"
      ]
    },
    {
      "key": "work",
      "kind": "filter",
      "app": "Filter by Zapier",
      "event": "Only continue if...",
      "title": "Only work email addresses",
      "why": "Free mailboxes stop here, which saves an Apollo credit and avoids enriching \"gmail.com\" as a company.",
      "conditions": [
        [
          {
            "field": "{{domain.valid}}",
            "operator": "(Boolean) Is true"
          },
          {
            "field": "{{domain.is_free_provider}}",
            "operator": "(Boolean) Is false"
          }
        ]
      ],
      "usually": true
    },
    {
      "key": "org",
      "kind": "search",
      "app": "Apollo",
      "event": "Enrich Organization",
      "title": "Look the company up in Apollo",
      "why": "Returns industry, estimated headcount, revenue band, and location for the domain.",
      "fields": {
        "Domain": "{{domain.domain}}",
        "Should this step be considered a \"success\" when nothing is found?": "Yes"
      },
      "outputs": [
        "name",
        "industry",
        "estimated_num_employees",
        "annual_revenue_printed",
        "city",
        "country",
        "linkedin_url",
        "short_description",
        "_zap_search_was_found_status"
      ]
    },
    {
      "key": "contact",
      "kind": "action",
      "app": "HubSpot",
      "event": "Create or Update Contact",
      "title": "Write the company data to the contact",
      "why": "Updates the same contact by email. Empty Apollo fields leave the existing HubSpot values alone.",
      "fields": {
        "Email": "{{trigger.email}}",
        "Company": "{{org.name}}",
        "Industry": "{{org.industry}}",
        "Number of Employees": "{{org.estimated_num_employees}}",
        "Annual Revenue": "{{org.annual_revenue_printed}}",
        "City": "{{org.city}}",
        "Country/Region": "{{org.country}}",
        "Website": "{{domain.website}}"
      },
      "outputs": [
        "id",
        "is_new"
      ]
    }
  ]
}
