What This Automation Does 🔧
This workflow gets unassigned deals from HubSpot and sorts them automatically.
It looks at deal regions and company size to pick the right sales rep.
This stops manual work and helps assign deals fast without missing any.
The workflow runs every 2 days early in the morning to keep deal lists clean.
It fetches deal info plus linked contacts and companies to get needed data for assignment.
Then, deals are checked for their country and sorted by region — mainly United States or Germany, with others handled as fallback.
Sales reps get assigned based on how big the company is, using employee count thresholds that differ between US and Germany.
Inputs, Processing Steps, and Output
Inputs
- HubSpot unassigned deals: Deals without a sales rep assigned.
- Contact details: Contacts linked to deals.
- Company info: Company data for linked contacts including country and employee count.
Processing Steps
- Fetch deals from HubSpot API every 2 days at 7 AM.
- Split deals into single items for processing one by one.
- Filter only deals with empty owner field.
- Get contact for each deal with associations from API.
- Get company info for the contact’s company.
- Use switch logic to assign deals by country (US, Germany, fallback).
- Within US and Germany branches, assign deals to sales reps based on company size ranges.
- Update HubSpot deal owner field using respective sales rep IDs.
- Optional fallback or notification for unassigned cases.
Output
Deals in HubSpot get owner assigned correctly by region and company size.
Sales reps receive appropriate deals without manual sorting.
Workflow keeps deals organized, speeds up response, and avoids mistakes.
Who Should Use This Workflow?
This workflow fits sales managers or teams using HubSpot who handle many deals daily.
It helps if deal owners must match both region and company size rules.
Automation reduces manual deal work and human errors while speeding up sales follow-up.
It is good for growing teams needing a simple, repeatable process inside n8n.
Users should have basic HubSpot access and n8n setup with credentials.
Tools and Services Used
- HubSpot CRM API: To fetch and update deals, contacts, and companies.
- n8n platform: For creating automation workflow.
- HubSpot OAuth2 Credentials: Secure API authentication inside n8n.
- self-host n8n: Recommended for stable hosting and control. Learn more here.
Beginner Step-by-Step: How to Use This Workflow in n8n
Step 1: Import Workflow
- Download the workflow file using the Download button on this page.
- Open your n8n editor where you build workflows.
- Use the “Import from File” option to load the workflow.
Step 2: Add Credentials and Configure
- Go to credential setup in n8n and add your HubSpot OAuth2 credentials if not done.
- Check and update any sales rep user IDs for assignments according to your HubSpot users.
- If you want to notify via Slack or email, update those node fields with your channels or emails.
Step 3: Test the Workflow
- Run the workflow manually once to see if deals are fetched and assigned correctly.
- Make sure deal owner fields update in your HubSpot portal.
- Fix any errors like missing credentials or wrong IDs.
Step 4: Activate Workflow for Production
- Switch the workflow to active mode in n8n to run automatically.
- The workflow will now run every 2 days at 7 AM without manual trigger.
- Monitor the executions in the n8n dashboard for any issues.
Edge Cases and Failure Notes
- If some deals have no contacts linked, the workflow may error at contact fetch step.
Add an If node to check for contact presence before proceeding. - Company data might be missing partially.
Include fallback or default assignment to avoid unassigned deals. - API OAuth tokens can expire causing 401 errors.
Reauthorize HubSpot credentials regularly. - Country exact spelling is important in switch nodes.
Use exact strings like “United States” or “Germany”. - Employee number comparisons must compare numbers, not strings.
Wrong types cause switch nodes to fail.
Customization Ideas
- Change run frequency in Schedule Trigger to daily or weekly.
- Add more regions in region switch to cover more countries.
- Modify company size thresholds for your sales team needs.
- Replace fallback assignment with Slack or email notifications to managers.
- Handle missing contacts with an If node or Function node to skip or log.
Workflow Code Snippet Sample
Example dynamic URL to get contact for a deal, with contact ID placeholder:
https://api.hubapi.com/crm/v3/objects/contacts/{{ $json.associations.contacts.results[0].id }}?associations=company
This URL dynamically pulls contact info and their company for the current deal item.
Replace with appropriate ID fields for customization.
Summary
✓ Automates deal assignment based on region and company size.
✓ Fetches enriched data from HubSpot deal, contact, and company info.
✓ Runs every 2 days without manual input.
✓ Reduces manual sorting and human errors.
✓ Keeps sales reps focused on closing deals, not managing assignments.
