Audience: Sales teams, RevOps, growth teams, SMBs with a CRM
The problem
Bad lead data — missing phone numbers, no website, zero reviews — quietly kills conversion rates. A quarterly manual audit is too slow; paying an LLM to evaluate every lead every night is expensive and unpredictable.
The AINL solution
examples/autonomous_ops/lead_quality_audit.lang runs at 2 AM daily, scores every lead for four data completeness signals, tracks the percentage drop vs the previous audit, and alerts when quality degrades beyond a configurable threshold.
# lead_quality_audit.lang (core pattern)
S db cron
Cr L_tick "0 2 * * *"
L_tick:
R db F ->leads
X scored (map leads (lambda l ({
"phone_ok": (core.and l.phone (core.gt (len l.phone) 5)),
"website_ok": l.website,
"rating_ok": (core.and l.Rating (core.gt l.Rating 0)),
"reviews_ok": (core.and l.ReviewCount (core.gt l.ReviewCount 0))
})))
X total (len scored)
X phone_pct (core.div (core.sum (map scored (lambda x (ite x.phone_ok 1 0)))) total)
If (core.lt phone_pct drop_threshold_pct) ->L_alert ->L_ok
L_alert:
R queue Put "notify" { "module": "lead_quality_audit", "phone_pct": phone_pct }
Ret "alerted"
L_ok:
Ret "ok"
The threshold (drop_threshold_pct) is configurable at runtime via the memory adapter — no redeploy needed to tune sensitivity.
What sales teams get
- Nightly data quality baseline — know your CRM health without manual spot-checks
- Configurable sensitivity — set thresholds in memory config, not in code
- Zero LLM cost — scoring is deterministic; the compiled graph decides what to flag
- Audit trail — every nightly run is a JSONL trace; show it to your data team or export for compliance
Extend it
Add per-city breakdowns, a Slack digest, or an auto-tag workflow for "data-poor" leads — all as additional nodes in the same graph.
pip install ainativelang
git clone https://github.com/sbhooley/ainativelang.git
ainl check examples/autonomous_ops/lead_quality_audit.lang --strict
