MarsalaMarsala
← Back to articles
TutorialJan 12, 2025¡7 min read

Lead Routing with n8n + Attio

Routing leads based on actual capacity, specialization and timezone—no spreadsheets hidden in someone's desk.

Tutorial for building a smart lead router with n8n, Attio and Slack.

By Marsala Engineering Team¡
#Automation#RevOps

Lead Routing with n8n + Attio

The router understands real availability, not just territory copied from an outdated Excel.

Context

In a fast-growing sales organization, efficient lead distribution is paramount. Our previous lead assignment process was, to put it mildly, chaotic. Leads were being assigned almost at random, often without regard for sales representative capacity, specialization, or even their current timezone. This led to a cascade of problems: high-value leads languished uncontacted, reps were either overloaded or underutilized, and the overall customer experience suffered as leads were misrouted or delayed. The lack of transparency meant that when leads "fell through the cracks," it was nearly impossible to pinpoint why or where the breakdown occurred. This manual, spreadsheet-driven approach was not only inefficient but also a significant barrier to scaling our sales efforts effectively.

Recognizing these critical inefficiencies, I embarked on building a dynamic and intelligent lead router. The core objective was to create a system with transparent, rule-based assignments that could adapt to real-time conditions. This router was designed to consider actual sales representative availability, their specific product or industry specializations, and their working hours, ensuring that every lead was directed to the most appropriate and available rep. The result is a system where nothing falls through the cracks, leads are handled promptly and by the right expert, and the entire process is governed by clear, auditable rules. This transformation has not only boosted our sales team's efficiency but also significantly improved our lead conversion rates and overall customer satisfaction.

Stack I leaned on

  • n8n hosted on Railway: n8n serves as the powerful, self-hosted automation engine orchestrating our lead routing logic. Hosting it on Railway provides a scalable and reliable infrastructure, ensuring our workflows execute efficiently and without interruption, even during peak lead volumes.
  • Attio API: Attio, our CRM, is central to our lead management. We leverage its robust API to programmatically update lead records with assignments, create tasks, and retrieve sales representative information (like specialization and current load), ensuring seamless data flow and real-time synchronization.
  • Supabase for load history: To make intelligent routing decisions based on actual sales representative capacity, we use Supabase to store and manage a detailed history of each rep's lead assignments and current workload. This data allows our n8n workflows to dynamically assess availability and prevent over-assigning leads.
  • Slack buttons for accept/reassign: For immediate action and streamlined communication, we integrated Slack. When a new lead is assigned, the sales representative receives a notification in Slack with interactive buttons to either "Accept" the lead or "Reassign" it if they are unavailable, providing a quick and efficient feedback loop.

Playbook

  1. Gathered signals: segment, industry, load and timezone: The first step in building our intelligent router was to meticulously identify and gather all relevant signals for optimal lead assignment. This included the lead's segment (e.g., enterprise, SMB), industry, the current workload or "load" of our sales representatives, and their respective timezones. These signals form the core data points for our routing logic.
  2. Built custom functions in n8n that return the ideal owner: Leveraging n8n's flexibility, we developed custom JavaScript functions within our workflows. These functions take the gathered lead signals as input and, based on a predefined set of rules (e.g., round-robin within a segment, specialization matching, load balancing), dynamically determine and return the "ideal owner" for each incoming lead.
  3. Updated Attio with the assignment and triggered tasks automatically: Once the ideal owner is identified, n8n automatically updates the lead record in Attio, our CRM, assigning the lead to the designated sales representative. Simultaneously, it triggers the creation of relevant follow-up tasks (e.g., "Initial Contact," "Discovery Call Prep") within Attio, ensuring a seamless handoff and immediate action.
  4. Notified Slack with accept/reassign buttons: To ensure rapid response times, the assigned sales representative receives an instant notification in a dedicated Slack channel. This notification includes key lead details and interactive buttons allowing the rep to either "Accept" the lead (confirming they will take ownership) or "Reassign" it (if they are genuinely unavailable or the lead is a mismatch), providing a quick and efficient feedback loop.
  5. Added a Retool dashboard to pause owners on PTO: To maintain the accuracy of our dynamic routing, we built a custom Retool dashboard. This dashboard allows sales managers to easily view and update the availability status of their team members, including pausing lead assignments for reps on PTO, sick leave, or during training. This ensures that leads are never routed to an unavailable rep, preventing delays and improving the overall lead experience.

Key Principles of Smart Lead Routing

  • Dynamic capacity awareness: Route leads based on real-time sales representative availability, current workload, and PTO status, not just static territory assignments.
  • Specialization matching: Align leads with sales reps who possess relevant product, industry, or language expertise to maximize conversion rates.
  • Transparent and auditable rules: Establish clear, documented routing rules that are easily understood by the sales team and can be audited for fairness and effectiveness.
  • Rapid notification and action: Implement instant notifications (e.g., Slack) with actionable options (accept/reassign) to minimize lead response times.
  • Centralized data for decision-making: Consolidate lead data, rep profiles, and historical performance in a central system (CRM, database) to inform routing logic.
  • Continuous optimization: Regularly review routing performance metrics, gather feedback from the sales team, and iterate on rules to improve efficiency and fairness.
  • Automation as the backbone: Leverage robust automation platforms (like n8n) to orchestrate complex routing logic, integrations, and notifications reliably.

Common Failure Modes (and Fixes)

  1. Outdated sales rep availability:
    • Problem: Routing leads to reps who are on PTO, sick leave, or otherwise unavailable leads to delayed follow-ups and frustrated prospects.
    • Fix: Implement an automated system (e.g., Retool dashboard, HR system integration) to update rep availability in real-time. Ensure reps can easily set their status (e.g., "away," "busy") to temporarily pause lead assignments.
  2. Ignoring rep specialization:
    • Problem: Assigning leads without considering a rep's expertise (e.g., product knowledge, industry focus, language skills) can lead to lower conversion rates and inefficient sales cycles.
    • Fix: Clearly define and track rep specializations in the CRM. Incorporate these specializations into the routing logic, ensuring leads are matched with the most qualified rep.
  3. Lack of transparency in routing rules:
    • Problem: If sales reps don't understand how leads are assigned, it can lead to distrust, perceived unfairness, and resistance to the system.
    • Fix: Document all routing rules clearly and make them accessible to the sales team (e.g., in a Notion page). Conduct regular training sessions to explain the logic and benefits of the system.
  4. Slow lead notification and acceptance:
    • Problem: Delays in notifying reps about new leads or slow acceptance times can result in missed opportunities and a poor lead experience.
    • Fix: Implement instant notifications (e.g., Slack, SMS) with actionable buttons (accept/reassign). Set strict SLAs for lead acceptance and escalate unaccepted leads to a manager or a backup queue.
  5. Data quality issues in lead signals:
    • Problem: Inaccurate or incomplete lead data (segment, industry, company size) can lead to incorrect routing decisions.
    • Fix: Implement data validation at lead capture points. Use lead enrichment tools (e.g., Clearbit) to automatically fill in missing information and standardize data. Regularly audit lead data for accuracy.

Metrics & Telemetry

  • Time to first contact: Reduced to less than 15 minutes, significantly accelerating lead engagement.
  • Lead acceptance rate: Achieved a high 93% lead acceptance rate, indicating effective matching and rep satisfaction.
  • Load deviation across owners: Decreased by 41%, ensuring a more equitable distribution of leads among sales representatives.

What stuck with me

  • Automatic pause is critical; otherwise people on PTO keep receiving leads: A seemingly small but profoundly impactful feature was the implementation of an automatic pause mechanism for sales representatives on PTO or otherwise unavailable. Without this, leads would continue to be routed to inactive reps, leading to delayed follow-ups, frustrated prospects, and a negative customer experience. This simple automation ensures that leads are always directed to an available and engaged rep, maintaining our service level agreements and optimizing the lead journey.
  • All rules live in a repo—no secret spreadsheets allowed: The transparency and auditability of our lead routing rules were paramount. Moving all routing logic and configuration from disparate, often outdated, spreadsheets into a version-controlled repository (like Git) was a game-changer. This eliminated "secret spreadsheets" where rules could be arbitrarily changed, ensuring that all routing decisions are based on a single, transparent, and auditable source. This fosters trust within the sales team and simplifies troubleshooting and optimization.

What I'm building next

Building on the success of our dynamic lead router, my next focus is to integrate a sophisticated fairness model. This model will go beyond simple load balancing to ensure equitable distribution of high-quality leads, taking into account factors like rep performance, historical win rates, and lead complexity. The goal is to optimize not just efficiency, but also fairness and motivation across the sales team. If you're interested in piloting this advanced lead routing system within your own sales organization and contributing to its development, please let me know. Your insights would be invaluable.

Want me to help you replicate this module? Drop me a note and we’ll build it together.

Marsala OS

Ready to turn this insight into a live system?

We build brand, web, CRM, AI, and automation modules that plug into your stack.

Talk to our team→