How to Set Up Auto-Calculate Monthly Sales Commissions in n8n
Sales commission calculation is one of those recurring back-office tasks that quietly eats hours every month and breaks trust when it goes wrong. If your sales team closes deals in HubSpot and your fi
Sales commission calculation is one of those recurring back-office tasks that quietly eats hours every month and breaks trust when it goes wrong. If your sales team closes deals in HubSpot and your finance team pays commissions from a spreadsheet, you already know the drill: someone exports closed-won deals, someone else applies the tiered rates, a third person double-checks the math, and payroll waits. This guide shows you how to automate the entire pipeline in n8n — pull HubSpot closed-won deals, apply tiered commission rates, and notify finance by email and sales ops in Slack, automatically on the 3rd of every month.
The Problem: Manual Commission Runs Don't Scale
Commission calculation looks simple until you actually do it at month-end. The reps want their numbers fast. Finance wants them auditable. And the logic is rarely flat — most teams run tiered rates where a rep earns 5% up to quota, 8% above it, and maybe 10% past 150% of target. Do that by hand across 12 reps and hundreds of deals and you get three predictable failures.
First, latency: the report lands days late because it depends on one person having a free afternoon. Second, errors: a mis-dragged formula or a deal counted in the wrong month means someone gets underpaid, files a complaint, and erodes trust in the whole comp plan. Third, no audit trail: when a rep disputes a number, you have a spreadsheet with no history of what was pulled, when, or under which rate table. For a busy founder or ops lead, this is pure operational drag — high-stakes, zero strategic value, and repeated every single month.
The Solution: A Scheduled n8n Workflow
n8n is an open-source workflow automation tool that connects your SaaS stack with visual nodes instead of glue-code scripts. For commissions, the shape of the solution is a single scheduled workflow that runs unattended: it wakes up on the 3rd of the month, queries HubSpot for every deal that closed as won in the previous month, groups those deals by owner, applies your tiered rate logic in code, and pushes the result to the two audiences who need it — finance (via a detailed email) and sales ops (via a Slack summary).
The 3rd of the month matters: it gives late-stage deals a couple of days to settle in HubSpot so your close-won data is stable before you calculate payouts. Because the whole thing lives in n8n, every run is logged, repeatable, and version-controlled. If a rep disputes a figure, you open the execution history and see exactly which deals were counted and which rate applied. That auditability is the real upgrade over a spreadsheet.
Step-by-Step Setup in n8n
Here is the node-by-node build. Five nodes carry the whole workflow.
1. Schedule Trigger node. Add a Schedule Trigger and set it to a Cron expression that fires on the 3rd. Use 0 8 3 * * to run at 08:00 on the 3rd of every month. This is your unattended entry point — no manual kickoff.
2. HubSpot node — fetch closed-won deals. Add a HubSpot node with resource Deal and operation Get All. Authenticate with a Private App token (create one in HubSpot under Settings → Integrations → Private Apps with the crm.objects.deals.read and crm.objects.owners.read scopes). Add a filter so you only pull the right deals: dealstage equals closedwon, and closedate is within the previous calendar month. Compute the month boundaries in an earlier Set or Code node using DateTime so the range always follows the run date. Request the properties you need: amount, closedate, hubspot_owner_id, and dealname. Turn on Return All so pagination is handled for you.
3. Code node — apply tiered rates and group by rep. This is the brain of the workflow. A Code node (JavaScript) iterates the deals, sums each owner's monthly total, and applies your tier table. A minimal version:
const tiers = [{upTo: 20000, rate: 0.05}, {upTo: 50000, rate: 0.08}, {upTo: Infinity, rate: 0.10}]; — then for each owner, walk the tiers and apply each rate to the portion of revenue that falls inside that band (marginal, not cliff-based, so a rep isn't penalized for crossing a threshold). Accumulate {ownerId, dealCount, revenue, commission} per rep and return one item per owner. Keep the tier table at the top of the node so editing the comp plan is a one-line change.
4. HubSpot node — resolve owner names. Owner IDs aren't human-readable, so add a second HubSpot node (resource Owner, operation Get) or a lookup to map hubspot_owner_id to a name and email. Merge that back into your per-rep items so finance sees "Maria Santos — $4,200" instead of an ID.
5a. Send Email node — finance. Add a Send Email (SMTP) or Gmail node addressed to finance. Build the body from your per-rep items — an HTML table with columns for rep, deal count, revenue, and commission, plus a grand total. This is the payable document, so include the reporting month and the run timestamp in the subject line for the audit trail.
5b. Slack node — sales ops. In parallel, add a Slack node (operation Send Message) posting to your #sales-ops channel. Keep this one punchy: total commission pool, top earner, and deal count — a summary the team reads at a glance, not the full ledger. Both notifications fire from the same calculated data, so finance and sales ops never see different numbers.
The Benefits: Time Back and Numbers You Can Trust
Once this workflow is live, month-end commissions become a non-event. The obvious win is time — hours of export, formula-wrangling, and double-checking collapse into a scheduled run nobody has to babysit. But the bigger wins are quieter. Consistency: the same tier logic runs identically every month, so there's no drift from someone editing last month's spreadsheet. Trust: reps get paid on time from data they can trace, which defuses the disputes that poison comp plans. Auditability: every run is stored in n8n's execution log, so a finance audit or a rep question is answered by opening one execution rather than reconstructing a spreadsheet. And because the tier table is a few lines in a Code node, adjusting the plan for a new quarter takes minutes, not a rebuild.
Common Pitfalls to Avoid
Timezone drift on close dates. HubSpot stores closedate in UTC. If you compute month boundaries in local time, deals that closed near midnight on the 1st or last day can slip into the wrong month. Normalize everything to one timezone in your date logic and test around month edges.
Cliff vs. marginal tiers. The single most common comp-plan bug is applying a higher rate to a rep's entire revenue once they cross a threshold, instead of only the portion above it. That produces wild overpayments and destroys trust. Use marginal band logic (apply each rate only to the slice of revenue inside that band) unless your plan genuinely intends a cliff.
Missing pagination. HubSpot returns deals in pages. If you forget Return All and a rep has a big month, you'll silently undercount their deals. Always confirm the total deal count against HubSpot before trusting the first run.
No dry-run. Don't point the very first execution at finance. Run it once with the email and Slack nodes disabled (or routed to yourself), reconcile the output against a manual calculation, and only then enable the real recipients. Also add error handling — an Error Trigger workflow that pings you on Slack — so a failed API call surfaces immediately instead of silently skipping a month's payroll.
Build it once, test it against a known month, and your commission run turns from a monthly fire drill into a line item you never think about again.
Ja construimos isso pra voce
Nao comece do zero. O n8n Lead Starter Kit — 3 No-Code Lead Automations e um workflow n8n pronto para instalar — conecta suas ferramentas em minutos, sem codigo.
Instalar por $9 →