WORKFLOW TEARDOWN
Lead Routing: MQL Task Engine
Every 15 minutes, a 39-node n8n engine picks up new marketing-qualified-lead tasks in Salesforce and assigns each one to the right owner using rule maps the ops team edits in Google Sheets.
- Scale
- 39 nodes
- Context
- Built for a PE-backed enterprise software group
// stage.on.canvas
// stage.it.does
A schedule trigger fires every 15 minutes, with a manual trigger for on-demand runs. A SOQL query pulls the day’s open MQL tasks, and a batch loop processes them one at a time with a wait between iterations, so Salesforce API limits never see a burst.
Each task resolves to a Lead or a Contact, and the branch matters: Contacts carry an Account, Leads may not. Leads without an account get a name-match SOQL lookup, so an existing account’s owner can claim the lead instead of the round-robin scattering it.
Routing rules live in ten Google Sheets maps: product-to-persona, title-to-persona, country-to-subregion, revenue segment, BDR alignment, partner routing, and a round-robin state sheet. The routing engine reads them all and applies the cascade: direct persona match first, then regional fallbacks (an APAC lead with no APAC owner routes to the NAM owner), then round-robin. The chosen owner writes back to the Salesforce task.
Every decision appends a row to an audit-log sheet: which lead, which owner, which rule fired, when. When a rep asks why they got a lead, the answer is a row, not a recollection. The rule set is versioned with numbered change requests, and 8 retired nodes stay disabled in the export as visible version history.
// stage.engineering.decision
Config in Google Sheets, logic in code
Chose: Routing maps in Sheets the ops team edits; the cascade in one versioned code node
Over: Hardcoding assignment rules inside the workflow
Territory maps and round-robin rosters change monthly; the rule cascade rarely does. Splitting them means ops edits a spreadsheet and the change is live on the next 15-minute run, with no workflow deploy. The engine version and its change-request numbers live in code, where they are reviewable.
// stage.results
- Assignment logic that lived in a RevOps manager’s head now runs every 15 minutes, documented in rule maps and an audit log.
- Regional fallbacks keep leads moving when a region has no assigned owner instead of parking them in a queue.
- Staged rollout: task-owner writeback runs in production; lead-owner writeback is built but gated off until validated.