{
  "schema_version": "1.0.0",
  "id": "intercom-lead-to-hubspot",
  "title": "Copy Intercom leads into HubSpot with a company guess",
  "category": "lead-gen-crm",
  "difficulty": "intermediate",
  "featured": false,
  "description": "When Intercom captures a lead email, work out the company from the domain and create the HubSpot contact with company and website filled in.",
  "tags": [
    "leads",
    "intercom",
    "hubspot",
    "enrichment"
  ],
  "apps": [
    "Intercom",
    "Code by Zapier",
    "HubSpot",
    "Slack"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 3 steps after the trigger"
    ]
  },
  "tasks": {
    "typical": 3,
    "max": 3
  },
  "trigger": {
    "app": "Intercom",
    "event": "New Lead",
    "kind": "polling",
    "title": "New Intercom lead",
    "why": "Fires when Intercom creates a lead, which happens when an anonymous visitor leaves an email in the chat.",
    "config": {},
    "outputs": [
      "lead_id",
      "name",
      "email",
      "phone",
      "created_at",
      "last_seen_url",
      "city",
      "country"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "domain",
      "kind": "code",
      "app": "Code by Zapier",
      "event": "Run JavaScript",
      "title": "Guess the company from the email",
      "why": "Most chat leads leave only an email. A work domain gives HubSpot a company name and website; a free mailbox gives nothing, and the step says so.",
      "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": "contact",
      "kind": "action",
      "app": "HubSpot",
      "event": "Create or Update Contact",
      "title": "Create the contact with company fields",
      "why": "HubSpot associates the contact with a company by domain when automatic association is on, which is why the website matters.",
      "fields": {
        "Email": "{{trigger.email}}",
        "First Name": "{{trigger.name}}",
        "Phone Number": "{{trigger.phone}}",
        "Company Name": "{{domain.company_guess}}",
        "Website": "{{domain.website}}",
        "City": "{{trigger.city}}",
        "Country/Region": "{{trigger.country}}",
        "Lifecycle Stage": "lead",
        "Chat page (custom property)": "{{trigger.last_seen_url}}"
      },
      "outputs": [
        "id",
        "is_new",
        "profile_url"
      ]
    },
    {
      "key": "post",
      "kind": "action",
      "app": "Slack",
      "event": "Send Channel Message",
      "title": "Post the lead to the team",
      "why": "Shows which page they chatted from and whether the email looks like a business.",
      "fields": {
        "Channel": "#chat-leads",
        "Message Text": "Chat lead {{trigger.email}} (company guess: {{domain.company_guess}}, free mailbox: {{domain.is_free_provider}}) from {{trigger.last_seen_url}}. {{contact.profile_url}}",
        "Send as a bot?": "Yes",
        "Bot Name": "Zap alerts",
        "Include a link to this Zap?": "No"
      },
      "outputs": [
        "ts",
        "permalink"
      ]
    }
  ]
}
