Repository
Modelling who gets the next lead
How SalesCandy used a simulator to explore why lead distribution felt uneven and what choosing a routing policy could change.
Why did one salesperson keep getting the next lead while a teammate was still waiting? Salespeople brought us that question. We used the simulator to see how different rules could produce the same streak and to explore what customers would gain from choosing their own assignment strategy.
Why the next few leads mattered
On 11 March 2020, Reza Rosli added a JavaScript model to the routing simulation repository. It implements several policies, including round robin, weighted round robin, and random assignment. Its output reports simulated availability and lead responses. An April commit from another contributor added an HTML view.
Repository record. Local SalesCandy archive, Analytics/routing-simulations, commits df7720f and b65d236.
Route leads live
Each available salesperson can take one lead per tick. Leads that aren’t accepted stay in the queue.
Card changes apply to the next tick, even while running. Changing policy starts a new session.
0 waiting
Testing customer choice
Routing weights gave managers a way to adjust how much new work each salesperson received. A manager could give a lower weight to someone with a full follow-up list or to someone who wanted to handle fewer leads. A weight of zero could pause new offers for a while. In the live simulator, zero pauses offers under weighted policies and leaves the salesperson’s availability setting visible.
We wanted managers to try a routing strategy, change its settings, and see the effect in Manager Portal before applying it. The April 2020 prototype already had a strategy selector, profile parameters, and a results chart (Analytics/routing-simulations, index.html at b65d236). Manager Portal had a per-salesperson routing-chance control (Portals/manager-portal, salesteam-view.component.html at 732eacdff). No archived plan or rollout record was found for the proposed portal simulator or strategy selector.
The first view follows one policy lead by lead. The columns show how many leads each salesperson has accepted, and the availability indicators show who was in a position to receive an offer. Changing a weight runs the same archived model with a fixed seed. Run it with the original weights first to get a baseline for that experiment.
The comparison below holds the salesperson settings constant across four policies. Scrub through the early offers, then look at the end of the run. In the original recording, Least Routes finished at 36 leads each despite Chong’s early streak. Weighted Round Robin finished at 51 for Badrul and 17 for Elina. The first pattern raises a question about what feels fair while people are waiting. The second raises a question about how much customers want weights to shape the final distribution.
Compare assignment strategies
Four strategies share the same salesperson settings and lead volume. Change the settings, then scrub to compare how the cumulative distributions change.
Compares cumulative results through the selected tick. Every bar accounts for all arrivals.
Could not run the model. Try a smaller number of ticks or iterations.
Three saved comparisons
Mean leads accepted across 100 seeded runs of 180 leads. Counts are ordered Aina, Badrul, Chong, Devi, Elina.
Everyone available, equal weights
- Round robin · 36 / 36 / 36 / 36 / 36
- Weighted round robin · 36 / 36 / 36 / 36 / 36
- Least routes · 36 / 36 / 36 / 36 / 36
- Weighted least routes · 36 / 36 / 36 / 36 / 36
Staggered starts, original weights
- Round robin · 32 / 38 / 35 / 38 / 37
- Weighted round robin · 43.25 / 51.92 / 46.85 / 25.37 / 12.61
- Least routes · 36 / 36 / 36 / 36 / 36
- Weighted least routes · 36.15 / 36.71 / 36.32 / 36.22 / 34.6
Only Elina is available, weight 25
- Round robin · 0 / 0 / 0 / 0 / 180
- Weighted round robin · 0 / 0 / 0 / 0 / 44.91 · 135.09 unassigned
- Least routes · 0 / 0 / 0 / 0 / 180
- Weighted least routes · 0 / 0 / 0 / 0 / 180
Patterns in the run logs
With equal weights and everyone available, all four strategies finish with the same distribution. With staggered starts and different weights, Weighted Round Robin gives Badrul about 52 leads per run and Elina about 13. When only Elina is available at weight 25, Weighted Round Robin makes one pass and often produces no offer. Weighted Least Routes keeps drawing and reaches her on every tick. These are simulator outcomes for a single available candidate. Production could assign directly on a one-person roster.
The 9 a.m. backlog
At 9 a.m., routing hours open and the overnight enquiries become eligible to route together. Imagine that Aina and Badrul are available at opening, Chong comes online a few minutes later, and Devi is already following up with yesterday’s leads. Every overnight enquiry is waiting, but each salesperson starts the morning from a different position.
Run it around a table. Write each overnight enquiry on a slip of paper, number it by arrival order, and put the slips in a tray labelled Waiting. Give each salesperson a cup for accepted leads and a paper card with Available on one side and Away on the other. At the 9 a.m. bell, the dispatcher takes slips from the front of the tray. Every bell is one tick. Add the next batch of arrivals and give each available person room for one slip. Slips nobody takes stay in the tray.
Play one round by passing a marker around the table and skipping anyone who is away. For Least Routes, tally offers on a sheet and start with the available person who has had the fewest. For Weighted Round Robin, draw a numbered slip from 1 to 100 at each eligible person’s turn and pass the offer on if the draw exceeds their weight. Stop after one pass for that lead. Photograph or write down who got the first few slips and how many are still in the tray. Reset to the same opening queue, switch rules, and let players decide when to flip their cards. Ask which round felt fairest while they were waiting, then compare the cups.
Replay the same morning. Give each policy the same overnight queue, availability timeline, existing workload and scheduled arrivals. Keep the original submission times so managers can see both how long the customer has waited and how quickly the queue clears after opening. Where the policy uses random draws, repeat the comparison across runs. Track time to first offer, accepted leads, open follow-ups, and each salesperson’s longest wait between offers. Two salespeople can receive the same number of new leads and still have very different workloads.
Ask what the team would call fair. Pause at 9:05 and ask salespeople and managers to choose among equal offers, offers proportional to time available, and room for people to catch up after their shift starts. Ask again at the end of the run. The early timeline shows who got an opportunity while others watched. The final totals show whether the morning’s lead distribution stayed uneven. People may also care whether the rule was clear and whether managers can explain an exception.
Let people play the same morning. Give each participant control of a salesperson’s availability and let them accept or decline offers. Run one policy, show everyone their results, switch policies, and replay the same backlog. Would they go available just before 9, take the first offer, or wait for a different one? Would someone with open follow-ups stay available for the burst? These are hypotheses to test with customers. Give salespeople and managers a turn in each other’s role, and ask what behavior they would reward.
This workshop extends the archived model. Its tick-by-tick playback illustrates who was eligible and who got the lead. A morning-load comparison would also need an opening backlog, follow-up workload, and a model of how long that work occupies a salesperson. Call-center research provides a useful precedent for comparing customer wait against how work is divided among people. Research on rank-based rewards gives teams a separate way to ask whether competing for leads is encouraging the behavior they want.
Related research
Colquitt’s study distinguishes fairness of outcomes, procedures, treatment, and explanations. Read Colquitt on organizational justice.
The authors used role-playing games to help participants see how model rules work. Read Barreteau, Bousquet and Attonaty on role-play.
The call-center model balances customer wait with how work is divided among agents. Read Armony and Ward on fair dynamic routing.
The paper examines how rewards tied to rank shape effort. Read Lazear and Rosen on rank-order incentives.
From prototype to data science
The routing simulator became a data science team project. The team included Azraf, an intern, Jonathan, and Muhammad Anwaar, SalesCandy’s data scientist. Reza worked with Anwaar on extracts, customer-facing reports, and modelling. The Git history credits Azraf with adding the browser view in April 2020. Firsthand context: customer feedback, the proposed portal simulator, and the data science team’s ownership and roster.
In June 2021, Jeffry Chan said SalesCandy had formed its data science team at the end of 2020 and was developing a model to route leads to salespeople with a higher chance of closing them. Chan described work in progress. Jeffry Chan on predictive routing, 4:28 · Interview notes.
The interactive comparison uses the five original salesperson profiles from df7720f and runs round robin and least routes, each with and without weighting. A rejected offer ends that tick in the model. A lead can also receive no offer if nobody is eligible or if a weighted round-robin pass makes no match.
What the model showed
A separate rerun of the archived model from b65d236 used a fixed random seed. Three salespeople stayed available and accepted every offer. Each algorithm got the same 180 incoming leads and salesperson weights of 100, 60, and 25.
| Strategy | How offers are selected | Leads accepted by A, B, C |
|---|---|---|
| Round robin | Cycle through the roster, skipping anyone unavailable. | 60, 60, 60 |
| Least routes | First try the available salesperson with the fewest previous offers. | 60, 60, 60 |
| Random | Pick uniformly from available salespeople. | 51, 63, 66 |
| Weighted round robin | Follow roster order and apply each candidate’s weight as a chance of selection. | 99, 61, 20 |
| Weighted least routes | Try candidates in fewest-offers order and apply their weights. | 73, 69, 38 |
| Weighted least routes with auto-offer | Use weighted least routes and offer immediately when only one candidate is available. | 73, 69, 38 |
The two unweighted ordered policies split leads evenly with everyone available. Both weighted policies favored the higher-weight salesperson, though least-routes ordering kept the split closer to even. The two least-routes weighting variants matched because the auto-offer condition never came up. The simulator also lets you vary when people become available, how often they go away, and how often they reject an offer. In a second rerun, only C was available. Both weighted least-routes variants assigned all 180 leads to C. The original variant evaluated C 852 times because it kept drawing against a weight of 25. Auto-offer evaluated C 180 times, once per lead. These counts come from the model.
How this relates to Carousel
Carousel received leads from CandyMuncher. In the archived CarouselMatcher implementation, the usual weighted draw considered eligible salespeople in order of routing attempts and time of availability. Two pre-routing rules could decide who got the lead before that draw:
- Sole salesperson. With the single-candidate option enabled, CarouselMatcher assigned the lead directly when the designated team had exactly one salesperson. For a lead without a valid team, it checked the project roster instead. The optimization removed a wait that could never change the recipient.
- Related leads. With preferential assignment enabled for the project, CarouselMatcher could keep a lead with a salesperson already matched to a related lead. That salesperson had to belong to the current project and could be excluded for that specific lead. For example, when CandyMuncher rerouted a lead, it excluded the previous assignee from the next match.
Both rules are outside the simulator. A separate production rule offered the lead immediately when exactly one eligible candidate remained and the single-candidate option was enabled. The simulator does model that shortcut in Weighted least routes with auto-offer. The distinction matters when interpreting a streak of offers: a production assignment could follow from the team roster or an existing lead relationship before the weighted policy came into play. See the production rules and source revision in CarouselMatcher.
Routing memorabilia
Original model at
df7720f, run from the archive. The five rows show the first 30 ticks of Least Routes.doLeastRoutes
# Leads: 180
# Leads routed: 180
# Leads remaining: 0
1: ○○○○○○○○○○○○○○○○○○○▓▓▓▓•▓••••▓
2: ▓••▓••▓•••••▓•••▓••••••••▓••••
3: ○○○○○○○○○▓▓▓•••▓•••••••▓••••▓•
4: •▓••▓••▓•••••▓•••▓••••••••▓•••
5: ••▓••▓••▓•••••▓•••▓••••••••▓••
○ Away · • Available · ▓ Accepted · ¡ Rejected
Local run of
Matcher.js at 6a3368f. The inputs are fictional, the rolls are fixed, and Redis and CandyBase are stubbed.--- Auto-routing demo-001
Validating candidates
Candidate @Devi id: 4
Candidate @Badrul id: 2
2 candidates for Lead
ROLL: 75 vs routingChance: 50; Result: FAIL
ROLL: 20 vs routingChance: 100; Result: PASS
--- Pre-routing demo-002 { assignTo: {} }
Auto-assign to solo salesperson { userId: '2', username: 'Badrul' }
--- Auto-routing demo-003
Validating candidates
Candidate @Elina id: 5
1 candidates for Lead
Only 1 candidate, MATCH
Archive location. Analytics/routing-simulations. Purpose based on README.md at b65d236.
Development history
-
2020
Development milestones
-
Simulation Structure Setup
The repository gained structure with `index.html` and sample HTML files, building upon the core simulation logic established in `routingAlgorithmModels.js`.
b65d23672a16b65d23672a16
-
When contributors were active
Authored commits per quarter through Q1 2023, oldest first. Rows are ordered by the first quarter with activity. Brighter cells show more commits. Scroll across to see later quarters.
| Contributor | 2020 Q1 | 2020 Q2 |
|---|---|---|
| Reza Rosli 2 commits · 2020 Q1 | 2 | 0 |
| Azraf 1 commit · 2020 Q2 | 0 | 1 |