{
  "schema_version": "1.0.0",
  "id": "hubspot-form-lead-score",
  "title": "Score a form lead into HubSpot",
  "category": "lead-gen-crm",
  "difficulty": "intermediate",
  "featured": true,
  "description": "Split the name, score a Typeform lead from 0 to 100 with readable reasons, save it on the HubSpot contact, and DM the owner when it is hot.",
  "tags": [
    "leads",
    "hubspot",
    "typeform",
    "lead-scoring",
    "slack"
  ],
  "apps": [
    "Typeform",
    "Code by Zapier",
    "HubSpot",
    "Filter by Zapier",
    "Slack"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 5 steps after the trigger",
      "Filter by Zapier"
    ]
  },
  "tasks": {
    "typical": 3,
    "max": 4
  },
  "trigger": {
    "app": "Typeform",
    "event": "New Entry",
    "kind": "instant",
    "title": "New enquiry form entry",
    "why": "Fires the moment someone submits the enquiry form. Typeform pushes the entry, so there is no polling delay.",
    "config": {
      "Form": "Project enquiry"
    },
    "outputs": [
      "response_id",
      "submitted_at",
      "full_name",
      "email",
      "company",
      "job_title",
      "company_size",
      "budget",
      "timeline",
      "message",
      "form_title"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "name",
      "kind": "code",
      "app": "Code by Zapier",
      "event": "Run JavaScript",
      "title": "Split the full name",
      "why": "HubSpot wants first and last name in separate properties. One \"Full name\" question is friendlier on the form, so the split happens here.",
      "code": {
        "language": "javascript",
        "module": "split-name",
        "file": "code/split-name.js"
      },
      "input_data": {
        "full_name": "{{trigger.full_name}}"
      },
      "outputs": [
        "first_name",
        "last_name",
        "display_name"
      ]
    },
    {
      "key": "score",
      "kind": "code",
      "app": "Code by Zapier",
      "event": "Run JavaScript",
      "title": "Score the lead",
      "why": "A rule-based score: work email, decision-maker title, company size, budget, timeline, and a penalty for vendor pitches. Each point comes with a reason a rep can read.",
      "code": {
        "language": "javascript",
        "module": "score-lead",
        "file": "code/score-lead.js"
      },
      "input_data": {
        "email": "{{trigger.email}}",
        "company": "{{trigger.company}}",
        "job_title": "{{trigger.job_title}}",
        "company_size": "{{trigger.company_size}}",
        "budget": "{{trigger.budget}}",
        "timeline": "{{trigger.timeline}}",
        "message": "{{trigger.message}}"
      },
      "outputs": [
        "score",
        "tier",
        "reasons",
        "is_work_email"
      ]
    },
    {
      "key": "contact",
      "kind": "action",
      "app": "HubSpot",
      "event": "Create or Update Contact",
      "title": "Save the contact with its score",
      "why": "Creates the contact or updates the one with this email, and writes the score, tier, and reasons into custom properties so HubSpot views and workflows can sort on them.",
      "fields": {
        "Email": "{{trigger.email}}",
        "First Name": "{{name.first_name}}",
        "Last Name": "{{name.last_name}}",
        "Company Name": "{{trigger.company}}",
        "Job Title": "{{trigger.job_title}}",
        "Lead score (custom property lead_score)": "{{score.score}}",
        "Lead tier (custom property lead_tier)": "{{score.tier}}",
        "Score reasons (custom property lead_score_reasons)": "{{score.reasons}}",
        "Lead Status": "NEW",
        "Message": "{{trigger.message}}"
      },
      "outputs": [
        "id",
        "is_new",
        "profile_url"
      ]
    },
    {
      "key": "hot",
      "kind": "filter",
      "app": "Filter by Zapier",
      "event": "Only continue if...",
      "title": "Only hot leads",
      "why": "Most enquiries are warm or cold and stop here; they are already in HubSpot with their score. Only a score of 70 or more interrupts a person.",
      "conditions": [
        [
          {
            "field": "{{score.tier}}",
            "operator": "(Text) Exactly matches",
            "value": "hot"
          }
        ]
      ],
      "usually": false
    },
    {
      "key": "ping",
      "kind": "action",
      "app": "Slack",
      "event": "Send Direct Message",
      "title": "DM the owner about the hot lead",
      "why": "A direct message, not a channel post, so a hot lead is somebody's job straight away.",
      "fields": {
        "To Username": "YOUR_SLACK_USERNAME",
        "Message Text": ":fire: Hot lead ({{score.score}}/100): {{name.display_name}}, {{trigger.job_title}} at {{trigger.company}}. Budget {{trigger.budget}}, timeline {{trigger.timeline}}.\nWhy: {{score.reasons}}\nHubSpot: {{contact.profile_url}}",
        "Send as a bot?": "Yes",
        "Bot Name": "Zap alerts"
      },
      "outputs": [
        "ts"
      ]
    }
  ]
}
