Step 1 — Pull every open deal (read-only)
Pull all open deals: current stage, amount, close date, next step field, and
how long the deal has sat in its current stage (time-in-stage). Read-only —
no field on the deal is changed in this step.
Step 2 — Pull activities per deal (read-only)
Pull logged calls, emails, meetings, and notes per deal, with timestamps.
This is the basis for the staleness check in Step 4.
Step 3 — Pull tasks per deal (read-only)
Pull open tasks tied to each deal, with due dates. A task past its due date
with no completion is overdue.
Step 4 — Apply the four hygiene rules
Evaluate every open deal against all four independently — a deal can trip
more than one:
| Rule | Trip condition |
|---|
| Stale | No logged activity (call, email, meeting, note) in the last {{stale_days}} days |
| Incomplete | Missing next step, missing close date, or both |
| Stalled | No stage change in the last {{stall_days}} days |
| Overdue task | At least one open task past its due date |
Step 5 — Write the hygiene flag (the only write)
For every deal that trips at least one rule, write the internal hygiene-flag
field on the deal noting which rule(s) tripped and the date. This is the
only field the agent ever writes — never the stage, the owner, or the
amount. Deals that trip no rule get their flag cleared if previously set.
Step 6 — Nudge the owning rep in Slack
For each flagged deal, send the owning rep a Slack nudge naming the deal,
which rule(s) tripped, and the concrete action needed:
| Rule tripped | Nudge action |
|---|
| Stale | Log the last touchpoint or make contact today |
| Incomplete | Set the missing next step and/or close date |
| Stalled | Move the deal forward or note why it hasn't |
| Overdue task | Complete or reschedule the task |
Group multiple flagged deals for the same rep into one message rather than
one message per deal.
Step 7 — Escalate the day's worst to {{escalation_channel}}
After all rep nudges are sent, rank flagged deals by:
- Number of rules tripped at once (most rules first).
- Deal amount at risk (largest first, as a tiebreaker).
- Days since last activity (longest first, as a second tiebreaker).
Post the top offenders to {{escalation_channel}} in one message: deal name,
owning rep, amount, which rules tripped, and days since last activity. Post
exactly once per run.