Route HubSpot leads by territory and company size using Zapier

medium complexityCost: $20-50/mo

Prerequisites

Prerequisites
  • Zapier account (Professional plan or higher for Code by Zapier and Paths)
  • HubSpot account connected to Zapier via OAuth
  • Slack workspace connected to Zapier
  • Enriched company data in HubSpot (state, country, employee count)

Step 1: Set up the HubSpot trigger

Create a new Zap. Choose HubSpot as the trigger:

  • Trigger event: New Contact
  • Additional Properties to Retrieve: firstname, lastname, email, jobtitle, company, state, country, numberofemployees, hubspot_owner_id, associatedcompanyid
Company data on the contact

HubSpot's Zapier trigger returns contact properties. To get company data (employee count, state), either ensure those fields are synced to the contact record, or add a second step to look up the associated company.

Step 2: Look up the associated company (optional)

If company data isn't on the contact record, add a HubSpot action:

  • Action event: Get Company
  • Company ID: {{associatedcompanyid}}
  • Additional Properties: numberofemployees, state, country, hubspot_owner_id

Step 3: Check for existing account owner

Add a Paths step with two paths:

Path A: Existing account owner

  • Condition: Company hubspot_owner_id → Exists
  • Route to Step 5 (assign contact to existing owner)

Path B: No existing owner

  • Condition: Company hubspot_owner_id → Does not exist
  • Continue to territory routing logic

Step 4: Route by territory and size with Code by Zapier

On Path B, add a Code by Zapier step:

  • Language: JavaScript
  • Input Data:
    • state -> {{state}} (from company or contact)
    • country -> {{country}}
    • employees -> {{numberofemployees}}
const state = (inputData.state || '').toUpperCase();
const employees = parseInt(inputData.employees || '0');
 
// Territory mapping
const territories = {
  'NY': { ownerId: '111111', slackId: 'U01AAAA', rep: 'Alice' },
  'MA': { ownerId: '111111', slackId: 'U01AAAA', rep: 'Alice' },
  'CT': { ownerId: '111111', slackId: 'U01AAAA', rep: 'Alice' },
  'CA': { ownerId: '222222', slackId: 'U02BBBB', rep: 'Bob' },
  'WA': { ownerId: '222222', slackId: 'U02BBBB', rep: 'Bob' },
  'FL': { ownerId: '333333', slackId: 'U03CCCC', rep: 'Carol' },
  'GA': { ownerId: '333333', slackId: 'U03CCCC', rep: 'Carol' },
  'TX': { ownerId: '333333', slackId: 'U03CCCC', rep: 'Carol' },
};
 
// Enterprise override
const ENTERPRISE_THRESHOLD = 1000;
const enterpriseRep = { ownerId: '444444', slackId: 'U04DDDD', rep: 'Dave (Enterprise)' };
const defaultRep = { ownerId: '555555', slackId: 'U05EEEE', rep: 'Eve (Catch-all)' };
 
let assigned;
let reason;
 
if (employees >= ENTERPRISE_THRESHOLD) {
  assigned = enterpriseRep;
  reason = `Enterprise (${employees} employees)`;
} else if (territories[state]) {
  assigned = territories[state];
  reason = `Territory: ${state}`;
} else {
  assigned = defaultRep;
  reason = `Fallback (state: ${state || 'unknown'})`;
}
 
output = [{
  ownerId: assigned.ownerId,
  slackId: assigned.slackId,
  repName: assigned.rep,
  reason: reason,
}];

Step 5: Update the contact owner in HubSpot

Add a HubSpot action:

  • Action event: Update Contact
  • Contact: Use the contact ID from the trigger step
  • Contact Owner: {{ownerId}} (from Path A: company's existing owner, from Path B: Code step output)

Step 6: Send a Slack DM

Add a Slack action:

  • Action event: Send Direct Message
  • User: {{slackId}}
  • Message Text:
🆕 *New Lead Routed to You*
*{{firstname}} {{lastname}}* at {{company}} ({{numberofemployees}} employees)
📍 {{state}}
Routing: {{reason}}
<https://app.hubspot.com/contacts/YOUR_PORTAL_ID/contact/{{hs_object_id}}|View in HubSpot>

Step 7: Test and publish

  1. Test each path with contacts from different territories
  2. Test with an enterprise-size company to verify the size override
  3. Test with a contact whose company already has an owner
  4. Turn the Zap On

Limitations

  • Paths require the Professional plan or higher.
  • Code by Zapier requires the Professional plan.
  • Polling delay: 1-15 minutes depending on plan.
  • Complex Zap: This is a 6-8 step Zap, which uses more tasks per execution.

Cost

  • Professional plan: $29.99/mo minimum. Each new lead = 6-8 tasks.
  • Team plan: $69.99/mo if you need higher task volume or faster polling.

Need help implementing this?

We build and optimize automation systems for mid-market businesses. Let's discuss the right approach for your team.