All work

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
n8nSalesforceSOQLGoogle Sheets
Workflow · MQL task to assigned owner (39 nodes)
Scheduleevery 15 min+ manual runSOQL queryopen MQL taskscreated todayBatch loopone task at atime + waitLead or Contact?account matchvia SOQL10 Sheets mapspersona · regionsegment · partnerround-robin stateRouting enginepersona match →regional fallback →round-robinconfig readTaskownerupdateAuditlog rowlead-owner writeback: built, gated off

// stage.on.canvas

Personal / lead-routing-mql-engine (production)EditorExecutions39 nodes. 8 stay disabledas visible version history.Ops edits the Sheets, not the workflow.Live on the next 15-minute run.Schedule Triggerevery 15 minGet MQL TasksSOQLFilter TaskscodeProcess Each Taskbatch + waitLead or Contact?IFMatch AccountSOQLLoad Rule Maps10 Google SheetsV2 Routing Enginecode · versionedUpdate Task OwnerWrite Audit LogsheetsLead-owner writebackPhase B(deactivated)Execute workflow
CANVAS RECREATED FROM THE PRODUCTION EXPORT · NODE LABELS GENERALIZED

// 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.