Work sample
Account prioritisation: which 80 accounts get a call this week, and what happens when the signals run out.
A weekly run for an outbound team of four SDRs selling B2B software. It reads 500 accounts and their buying signals, decides who a rep may call, scores the rest, routes them by territory and capacity, and gives every rep a Monday list with the reason to call, who to call and a first step. Leadership changes the rules in settings, never in the logic.
The answer: the limit is signals, not reps
Picking 80 accounts a week is the easy part. Run two Mondays in a row and the accounts with a real buying signal are used up by the second week. Adding SDR hours does not fix that. More signal sources do, and so does putting capacity where the signals are.
Only a handful of accounts show a first signal between the two Mondays, so at this pace most of week 3 would go to accounts with no reason to call now.
How it works
| Rule, in the order the run applies it | Taken out | Left |
|---|---|---|
| Start: 500 rows, 3 companies stored twice merged | 3 | 497 |
| Owned by an AE: customers, open deals, other AE accounts | 111 | 386 |
| Region with no rep to cover it | 56 | 330 |
| Touched in the last 21 days, or lost less than 120 days ago | 15 | 315 |
| No buying signal in the last 90 days | 165 | 150 |
| Signal too weak, score under 15 | 2 | 148 |
| No room left in the rep's territory this week | 68 | 80 |
Run it in n8n
Every Monday at 06:45 it reads accounts, signals, the reps sheet and the earlier lists, writes one list per rep and the AE alerts, and posts each rep's top three to Slack. The code inside gives the same rows as the Python sample on the same data and date, checked row by row, and the workflow imports and runs in n8n. Counts on the lines are from the sample run.
What a rep sees on Monday
| Rep | Account | Score | Why now | Who to call | First step |
|---|---|---|---|---|---|
| EMEA rep | Fernbridge LtdUnited Kingdom | 72.0 | Contract renewal due; pricing page; complained about current vendor | Head of Procurement | Open with a cost comparison before they renew |
| US senior rep | Hazelgate IncUnited States | 78.1 | Contract renewal due; hiring a platform engineer; whitepaper | Head of Procurement | Open with a cost comparison before they renew |
| US junior rep | Rowanstone IncUnited States | 68.0 | Complained about current vendor; hiring a platform engineer; new VP Engineering | Head of Engineering | Ask what broke and show how it is handled |
| LATAM rep | Junipermark LtdaColombia | 61.5 | Pricing page 3 times; new head of procurement; complained about current vendor | Head of Engineering | Offer a pricing walkthrough for their volume |
What the data was hiding
The synthetic input carries the problems a real CRM export has. Each would put a wrong list in front of a rep without any error message.
- A third of the list can disappear on load. The region code NA (North America) reads as an empty value in pandas by default. Here that is 173 accounts. The run reads it as text and logs it.
- Signal labels are wrong. 34 single blog visits are filed as pricing interest. The score reads what a signal says, not the type it was filed under, so they count for nothing.
- Some competitor renewals are the seller's own. 4 customers carry a renewal signal while their current vendor is the seller. Those go to the AE as retention alerts, not to an SDR.
- The same company twice. 3 companies sit under two records, one with sales history and one that looks new. The run merges each pair into the record with history and logs it, so the cool down holds.
- Demand sits where nobody sells. 26 accounts in a region with no rep show a signal. That is a staffing question for leadership, not a routing rule.
How an account is scored
Score = (signal points + fit points) × leadership boost
| Level | Points | Examples |
|---|---|---|
| High: close to a decision | 18 to 30 | Contract renewal due, three pricing visits, complained about current vendor, API docs |
| Medium: something is changing in their business | 12 to 22 | Hiring a platform engineer, new product launch, new head of procurement, funding, new market |
| Low: weak or early | 8 to 10 | New VP Engineering, webinar, whitepaper |
| Ignored | 0 | A single blog visit |
- Signals fade. Half the points every 21 days, nothing after 90.
- Renewals work the other way. Full points while the date is 1 to 6 months away, half in the final month, nothing once it has passed.
- One per kind, plus a bonus for variety. Ten docs visits count as one. Each extra kind of signal adds 6 points.
- Funding counts double next to a build signal. Money on its own says nothing about a buying decision. Money within 60 days of an engineering hire or a launch says it is going into the product.
- Fit, up to 29 points. Company size, current vendor (an in house build or several vendors scores highest) and industry. A missing value scores a small default, not zero, so a gap does not knock an account out.
What I would decide
Every rule is a setting, so leadership can try a decision and rerun. I tried the obvious one.
- EMEA has the backlog: 35 signal accounts wait for room in week 1, and the only 12 left after week 2 are all there.
- Moving 8 weekly slots from LATAM to EMEA cuts fit only accounts in week 2 from 21 to 15, and 145 signal accounts get worked over two weeks instead of 139.
- No setting gets past 151, because that is every signal account there is.
My call: move rep time to EMEA now, make new signal sources the first build, and set the weekly pace once week 2 replies are in. The sources I would add first are tied to a buying moment rather than another intent feed: a competing product reaching end of support, public tech stack changes, and product sign ups matched to named accounts.
From prototype to production
| Layer | In this sample | In production |
|---|---|---|
| Accounts, owners, stages | CSV | Salesforce as the system of record, read live every Monday |
| Signals | CSV | One signal record per event, keyed on account, type and date, so nothing lands twice |
| Signal sources | Invented | Website and marketing data, plus job posts, funding and launches through Clay, paid for only on accounts that pass the fit gate |
| Weekly run | Python script | n8n every Monday at 06:00, writing score, tier and reason onto the account, with a duplicate check before each write and a Slack alert on failure |
| What the rep sees | A CSV per week | A Slack message at 07:00 and the same list in Salesforce |
| Outcomes | Not modelled | Replies and meetings read back from Salesforce and the sequencer |
How I would know it works: share of each list with a live signal, meetings per 100 accounts worked and pipeline per SDR hour, split by signal type, against a small group of accounts left unprioritised.
How it was built
- I did
- Every decision: which signals count and how much, the gate, the routing rules and the recommendation. I checked every number on this page against the output.
- AI did
- Claude Code wrote both scripts from those decisions. No model scores anything during the run: every signal text maps to a readable rule.
- Checks
- The run stops if anything breaks: a rep over capacity, an account listed twice, an account on both weeks' lists, an AE owned account or an account with no rep on a list, or a signal dated on or after its Monday that scored.
- Not built
- The Clay enrichment and the writes into Salesforce. Designed, not running. The n8n workflow above is built: it reads accounts, signals and the reps sheet from Google Sheets, writes one list per rep and the AE alerts, and posts each rep's top three to Slack.
- Run it
python3 make_synthetic_accounts.pythenpython3 prioritise.py data/accounts.csv data/signals.csv --out output. Standard library only.
Synthetic input. Every company, domain and signal is invented to exercise the rules and says nothing about real companies. Domains end in .example.
Files
The whole folder on GitHub: clone it and run it with plain Python.
The playbook on ModletHub: the same workflow as a step by step guide to set up yourself.
Read prioritise.py here
"""
Account prioritisation: which accounts each SDR works this week, and why.
python3 prioritise.py data/accounts.csv data/signals.csv --out output
Runs two Mondays in a row. Week 2 never repeats an account from week 1.
Steps, every Monday
1. Clean: read the region code NA as North America, merge companies stored
twice, ignore signals whose text says nothing, log every fix.
2. Gate: may a rep call it? AE owned, no rep for the region, touched in the
last 21 days, lost in the last 120 days.
3. Score: (signal points + fit points) x boost. Signals fade, renewals count
as they come closer, one signal per type plus a bonus for variety.
4. Route: territory, then each rep's capacity for new accounts. Free slots
take the best fitting accounts with no signal, marked fit only.
5. Output: one list per rep, best first, with why now and a first step.
Every rule is a setting at the top of this file. Standard library only.
"""
import argparse
import csv
import json
import os
import re
from collections import Counter, defaultdict
from datetime import date, timedelta
# ---- settings ---------------------------------------------------------------
MONDAYS = [date(2026, 10, 5), date(2026, 10, 12)]
REPS = [ # name, territory, new accounts per week, months in role
("EMEA rep", "EMEA", 25, 14),
("US senior rep", "NA", 20, 18),
("US junior rep", "NA", 15, 4),
("LATAM rep", "LATAM", 20, 12),
]
SENIOR_FIRST_EMPLOYEES = 2000 # in NA, accounts this big go to the senior rep first
# points are set on what a signal says, not on the type it was filed under
SIGNAL_POINTS = {
"contract renewal due with current vendor": 30,
"visited pricing page 3 times": 25,
"complained about current vendor in a review": 24,
"read API docs": 20,
"hiring a platform engineer": 22,
"visited pricing page": 18,
"launched a new product line": 18,
"new head of procurement": 15,
"raised a funding round": 12,
"opened an office in a new market": 12,
"new VP Engineering": 10,
"attended a webinar": 8,
"downloaded a whitepaper": 8,
"read one blog post": 0,
}
FIRST_STEP = {
"contract renewal due with current vendor": ("Head of Procurement", "Open with a cost comparison before they renew"),
"visited pricing page 3 times": ("Head of Engineering", "Offer a pricing walkthrough for their volume"),
"visited pricing page": ("Head of Engineering", "Offer a pricing walkthrough for their volume"),
"complained about current vendor in a review": ("Head of Engineering", "Ask what broke and show how it is handled"),
"read API docs": ("Lead developer", "Offer a technical session on the integration"),
"hiring a platform engineer": ("VP Engineering", "Reference the role and the build it is hired for"),
"launched a new product line": ("Head of Product", "Ask what the launch needs from the stack"),
}
HALF_LIFE_DAYS = 21
MAX_SIGNAL_AGE = 90
VARIETY_BONUS = 6
FUNDING_NEAR_BUILD_DAYS = 60 # funding counts double within this many days of a build signal
COOL_DOWN_DAYS = 21
LOST_WAIT_DAYS = 120
MIN_SCORE = 15
BOOSTS = {} # e.g. {"logistics": 1.5}
SIZE_POINTS = [(5000, 15), (2000, 12), (800, 9), (300, 6), (0, 3)]
VENDOR_POINTS = {"in house build": 8, "several vendors": 8, "single vendor": 5}
CORE_INDUSTRIES = {"logistics", "fintech", "energy", "mobility"}
MISSING = {"size": 5, "vendor": 3}
# ---- clean ------------------------------------------------------------------
def norm(name):
n = re.sub(r"\(.*?\)", "", name.lower())
n = re.sub(r"[^a-z0-9 ]", "", n)
return re.sub(r"\s+", " ", n).strip()
def clean(accounts, signals, log):
na = sum(1 for a in accounts if a["region"] == "NA")
log.append(("region NA read as North America, not as empty", na))
# merge companies stored twice into the record with sales history
groups = defaultdict(list)
for a in accounts:
groups[(norm(a["company"]), a["country"])].append(a)
remap, keep = {}, []
for recs in groups.values():
recs.sort(key=lambda a: (a["last_touch"] == "", a["account_id"]))
keep.append(recs[0])
for dup in recs[1:]:
remap[dup["account_id"]] = recs[0]["account_id"]
if remap:
log.append(("companies stored twice, merged into the record with history", len(remap)))
for s in signals:
s["account_id"] = remap.get(s["account_id"], s["account_id"])
blog = sum(1 for s in signals if s["detail"] == "read one blog post" and s["signal_type"] == "web_intent")
log.append(("single blog visits filed as pricing interest, scored 0", blog))
return keep, signals
# ---- score ------------------------------------------------------------------
def days(a, b):
return (a - b).days
def signal_points(sig, monday):
base = SIGNAL_POINTS.get(sig["detail"], 0)
when = date.fromisoformat(sig["signal_date"])
if when >= monday:
return 0.0
if sig["detail"].startswith("contract renewal") and sig["extra"]:
to_go = days(date.fromisoformat(sig["extra"]), monday)
if to_go <= 0 or to_go > 180:
return 0.0
return base / 2 if to_go <= 30 else float(base)
age = days(monday, when)
if age > MAX_SIGNAL_AGE:
return 0.0
return base * 0.5 ** (age / HALF_LIFE_DAYS)
def score_signals(sigs, monday):
best = {}
for s in sigs:
p = signal_points(s, monday)
if p <= 0:
continue
key = s["detail"] # one per kind of signal
if p > best.get(key, (0, None))[0]:
best[key] = (p, s)
if not best:
return 0.0, None, []
build_dates = [date.fromisoformat(s["signal_date"]) for p, s in best.values()
if s["detail"] in ("hiring a platform engineer", "launched a new product line")]
total = 0.0
for key, (p, s) in best.items():
if key == "raised a funding round" and any(
abs(days(date.fromisoformat(s["signal_date"]), d)) <= FUNDING_NEAR_BUILD_DAYS for d in build_dates):
p *= 2
total += p
total += VARIETY_BONUS * (len(best) - 1)
ranked = sorted(best.values(), key=lambda x: -x[0])
return round(total, 1), ranked[0][1], [s["detail"] for _, s in ranked]
def fit_points(a):
if a["employees"]:
n = int(a["employees"])
size = next(p for floor, p in SIZE_POINTS if n >= floor)
else:
size = MISSING["size"]
vendor = VENDOR_POINTS.get(a["current_vendor"], MISSING["vendor"])
industry = 6 if a["industry"] in CORE_INDUSTRIES else 4
return size + vendor + industry
# ---- gate -------------------------------------------------------------------
def gate(a, monday, has_rep):
if a["owner_type"] == "AE" or a["stage"] in ("customer", "open_deal"):
return "owned by an AE"
if a["region"] not in has_rep:
return "region with no rep"
if a["last_touch"] and days(monday, date.fromisoformat(a["last_touch"])) < COOL_DOWN_DAYS:
return "touched in the last 21 days"
if a["lost_date"] and days(monday, date.fromisoformat(a["lost_date"])) < LOST_WAIT_DAYS:
return "lost less than 120 days ago"
return None
# ---- one Monday -------------------------------------------------------------
def run_week(accounts, by_acc, monday, already):
has_rep = {t for _, t, _, _ in REPS}
rows, out, alerts = [], Counter(), []
for a in accounts:
if a["account_id"] in already:
continue
sig, top, kinds = score_signals(by_acc.get(a["account_id"], []), monday)
reason = gate(a, monday, has_rep)
if reason == "owned by an AE":
if sig > 0:
kind = "retention" if a["current_vendor"] == "us" else ("open deal" if a["stage"] == "open_deal" else "expansion")
alerts.append({"monday": monday.isoformat(), "account_id": a["account_id"], "company": a["company"],
"alert": kind, "signals": "; ".join(kinds)})
out[reason] += 1
continue
if reason:
out[reason] += 1
if reason == "region with no rep" and sig > 0:
out["region with no rep, with a signal"] += 1
continue
fit = fit_points(a)
boost = BOOSTS.get(a["industry"], 1.0)
score = round((sig + fit) * boost, 1)
rows.append({"a": a, "signal": sig, "fit": fit, "score": score, "top": top, "kinds": kinds})
signal_rows = [r for r in rows if r["signal"] > 0]
out["no buying signal in the last 90 days"] = len(rows) - len(signal_rows)
weak = [r for r in signal_rows if r["score"] < MIN_SCORE]
out["signal too weak, score under 15"] = len(weak)
strong = sorted([r for r in signal_rows if r["score"] >= MIN_SCORE], key=lambda r: -r["score"])
fit_only = sorted([r for r in rows if r["signal"] == 0], key=lambda r: -r["fit"])
lists = {name: [] for name, _, _, _ in REPS}
cap = {name: c for name, _, c, _ in REPS}
def place(r, label):
terr = r["a"]["region"]
reps = [n for n, t, _, _ in REPS if t == terr and len(lists[n]) < cap[n]]
if not reps:
return False
if terr == "NA":
big = r["a"]["employees"] and int(r["a"]["employees"]) >= SENIOR_FIRST_EMPLOYEES
if big and "US senior rep" in reps:
reps = ["US senior rep"]
else:
reps.sort(key=lambda n: len(lists[n]) / cap[n])
lists[reps[0]].append(dict(r, kind=label))
return True
waiting = Counter()
for r in strong:
if not place(r, "signal"):
waiting[r["a"]["region"]] += 1
out["no room left in the rep's territory"] = sum(waiting.values())
for r in fit_only:
if all(len(lists[n]) >= cap[n] for n in lists):
break
place(r, "fit only")
return lists, out, alerts, waiting
def tier(r):
hi_fit, hi_sig = r["fit"] >= 20, r["signal"] >= 30
return 1 if hi_fit and hi_sig else (2 if hi_fit or hi_sig else 3)
def as_rows(lists, monday):
rows = []
months = {n: m for n, _, _, m in REPS}
for rep, items in lists.items():
for i, r in enumerate(sorted(items, key=lambda x: (x["kind"] != "signal", -x["score"])), start=1):
a, top = r["a"], r["top"]
who, step = FIRST_STEP.get(top["detail"], ("Head of Engineering", "Lead with the signal")) if top else (
"Head of Engineering", "Fit only: open on their stack and size, no trigger yet")
note = "Manager joins the first call" if months[rep] < 6 and tier(r) == 1 else ""
rows.append({
"monday": monday.isoformat(), "rep": rep, "rank": i, "account_id": a["account_id"],
"company": a["company"], "country": a["country"], "kind": r["kind"], "tier": tier(r),
"signal_points": r["signal"], "fit_points": r["fit"], "score": r["score"],
"why_now": "; ".join(r["kinds"]) if r["kinds"] else "no signal yet",
"who_to_call": who, "first_step": step, "note": note,
})
return rows
# ---- checks -----------------------------------------------------------------
def checks(weeks, accounts_by_id, signals):
seen = set()
for monday, rows in weeks:
per_rep = Counter(r["rep"] for r in rows)
for name, _, c, _ in REPS:
assert per_rep[name] <= c, f"{name} over capacity"
ids = [r["account_id"] for r in rows]
assert len(ids) == len(set(ids)), "an account is listed twice"
assert not seen & set(ids), "an account is on both weeks' lists"
seen |= set(ids)
for r in rows:
a = accounts_by_id[r["account_id"]]
assert a["owner_type"] != "AE" and a["stage"] not in ("customer", "open_deal"), "AE account on a list"
assert a["region"] != "APAC", "APAC account on a list"
for s in signals:
if s["account_id"] in ids and date.fromisoformat(s["signal_date"]) >= monday:
# allowed in the file, but it must not have scored: verified by signal_points returning 0
assert signal_points(s, monday) == 0
return "all checks passed"
# ---- main -------------------------------------------------------------------
def main():
ap = argparse.ArgumentParser()
ap.add_argument("accounts")
ap.add_argument("signals")
ap.add_argument("--out", default="output")
ap.add_argument("--capacity", default="", help='change capacity, e.g. "LATAM rep=12,EMEA rep=33"')
args = ap.parse_args()
if args.capacity:
change = dict(x.split("=") for x in args.capacity.split(","))
REPS[:] = [(n, t, int(change.get(n, c)), m) for n, t, c, m in REPS]
with open(args.accounts, newline="") as f:
accounts = list(csv.DictReader(f)) # csv keeps "NA" as text; pandas would not by default
with open(args.signals, newline="") as f:
signals = list(csv.DictReader(f))
log = []
accounts, signals = clean(accounts, signals, log)
by_acc = defaultdict(list)
for s in signals:
by_acc[s["account_id"]].append(s)
os.makedirs(args.out, exist_ok=True)
already, weeks, summary_weeks, all_alerts = set(), [], [], []
for n, monday in enumerate(MONDAYS, start=1):
lists, out, alerts, waiting = run_week(accounts, by_acc, monday, already)
rows = as_rows(lists, monday)
weeks.append((monday, rows))
all_alerts += alerts
already |= {r["account_id"] for r in rows}
sig_rows = [r for r in rows if r["kind"] == "signal"]
summary_weeks.append({
"week": n, "monday": monday.isoformat(), "listed": len(rows),
"with_signal": len(sig_rows), "fit_only": len(rows) - len(sig_rows),
"tier_1": sum(1 for r in rows if r["tier"] == 1),
"avg_signal_points": round(sum(r["signal_points"] for r in sig_rows) / max(len(sig_rows), 1), 1),
"avg_fit_points": round(sum(r["fit_points"] for r in sig_rows) / max(len(sig_rows), 1), 1),
"gate": dict(out), "signal_accounts_waiting_by_region": dict(waiting),
"ae_alerts": len(alerts),
})
with open(os.path.join(args.out, f"week{n}_lists.csv"), "w", newline="") as f:
w = csv.DictWriter(f, fieldnames=list(rows[0].keys()))
w.writeheader()
w.writerows(rows)
result = checks(weeks, {a["account_id"]: a for a in accounts}, signals)
with open(os.path.join(args.out, "ae_alerts.csv"), "w", newline="") as f:
w = csv.DictWriter(f, fieldnames=["monday", "account_id", "company", "alert", "signals"])
w.writeheader()
w.writerows(all_alerts)
with open(os.path.join(args.out, "data_quality.csv"), "w", newline="") as f:
w = csv.writer(f)
w.writerow(["fix", "rows"])
w.writerows(log)
lines = ["# Monday lists, week 1", ""]
for rep in [r[0] for r in REPS]:
top = [r for r in weeks[0][1] if r["rep"] == rep][:3]
lines.append(f"## {rep}")
lines.append("| # | Account | Score | Why now | Who to call | First step |")
lines.append("| --- | --- | --- | --- | --- | --- |")
for r in top:
lines.append(f"| {r['rank']} | {r['company']}, {r['country']} | {r['score']} | {r['why_now']} | {r['who_to_call']} | {r['first_step']} |")
lines.append("")
with open(os.path.join(args.out, "monday.md"), "w") as f:
f.write("\n".join(lines))
summary = {"accounts_after_merge": len(accounts), "data_quality": dict(log),
"weeks": summary_weeks, "checks": result}
with open(os.path.join(args.out, "summary.json"), "w") as f:
json.dump(summary, f, indent=2)
print(json.dumps(summary, indent=2))
if __name__ == "__main__":
main()