Case Study/Voice & Telephony/Architecture, engineering, maintenance

AI Predictive Outbound Dialer

Author
Aryan
Client
US outbound SaaS
Published
2026
Length
7 min · 1524 words

Abstract

Multi-tenant predictive dialer on Telnyx and LiveKit that paces calls under a 3% abandonment cap.

Key outcomes

Abandonment cap
< 3%
Tenancy
DB per tenant
Media bridge
LiveKit WebRTC

Pacing is a queueing problem wearing telephony clothes

A predictive dialer has one job that everything else serves: keep agents talking and never keep them waiting. Waiting is invisible cost, because an agent on the floor is paid whether or not there is a live human on the line. Dialing too early produces abandoned calls when no agent is free. Dialing too late leaves seats idle.

Classic predictive dialers solve this with a fixed over-dial ratio, placing a set multiple of calls per available agent. That number is wrong by construction because it assumes a constant answer rate, and answer rates move by time of day, by list and by caller ID reputation. So the ratio has to be recomputed continuously from what is happening on the floor: how many agents are idle, what fraction of dials are being answered, how long talk and wrap-up are taking. Pacing here is driven by those live signals, and the dialer’s math is not exposed to agents. They choose a named strategy (Careful, Balanced, Fast) and a start mode (Manual or Auto).

The concrete mechanism is that the coordinator wakes on a loop, re-evaluates the floor, and computes a draw from the pacing budget. It does not dial a fixed batch per tick.

The three percent cap is a gate the dialer enforces

Predictive dialing is regulated, and the number that matters is the abandonment rate. The dialer operates under a 3% abandonment budget it will not exceed, and the important word is will not. A cap that is a configurable number in a settings screen is a suggestion; a cap the dialer refuses to cross is a constraint. When the projected abandonment for the next dial would cross the budget, the dialer stops, even if agents are idle and leads are waiting. That is a worse business outcome in the moment and the correct one overall.

The consequence is that the cap has to be measured on something the application trusts. An abandoned call is one that a human answered, that no agent ever spoke on, and that ended for that reason, which means the dialer must know the answer happened, that no agent leg was ever attached, and how the call ended rather than reading a carrier report at the end of the day. The audit path exists because the raw logs are not sufficient on their own: a report pass reconstructs abandonment from the call’s events and compares it against the carrier’s record, and disagreements between the two are treated as bugs, not rounding.

No agent leg exists until a human answers

The dialer is registered-warm rather than merely predictive, and the distinction is structural. A conventional dialer rings the agent and the prospect at once and bridges whatever answers, which burns agent time on voicemail, no-answers and wrong numbers.

Here the lead leg is originated first on the tenant’s Telnyx Call Control connection, carrying a client_state payload of { orgId, callId, legRole, leadId }. That is how every subsequent webhook is attributed to the right tenant and call without a lookup table. On answer, comfort audio starts immediately so the prospect is not left in silence while the system decides what to do.

Then qualification happens. With answering-machine detection on, the offer waits for a human verdict; with AMD off, which is the default, the human is taken straight through. Only at that point is the next free agent committed and their WebRTC leg dialled to sip:<sip_username>@sip.telnyx.com. The two legs are bridged 1:1, never into a conference, and recording follows whatever configuration the tenant set.

Ringing an agent for a dial nobody picked up is therefore not a policy that can be misconfigured. It is impossible, because no agent leg is ever created. The cost is a small amount of dead time on the lead leg while the agent’s browser is dialled in, which comfort audio covers.

The call is an event stream of state changes

Every state change is an event: dialled, ringing, answered, bridged, held, hung up. Telnyx webhooks are Ed25519-verified and deduplicated by event id, and the call lifecycle is event-sourced, so the call record is a projection of durable events rather than a mutable row that handlers edit in place.

That matters because carriers retry webhooks and do not guarantee ordering. A retried hangup that runs twice will double-count a call if handlers are not idempotent. A late ringing arriving after answered will walk a naive state machine backwards. Event-level deduplication plus a guarded transition function makes both of those no-ops instead of corruption.

The database is one datastore, deliberately. MongoDB serves documents, TTL state, change-stream fanout and the job queue, and there is no Redis. That is a real trade with a real cost. Something Redis does in a single command becomes an indexed collection with TTL indexes, and the change-stream fanout only exists because MongoDB runs as a replica set. The benefit is one consistency model and one backup story, and no class of bug where a cache and a database disagree about what is true.

Realtime, and the honest cost of change streams

Sockets are per-replica and interchangeable because fanout comes from MongoDB change streams rather than from in-process state. Topics are scoped to calls, presence, dialer, leads and notifications, and delivery is at-least-once with per-topic sequence numbers.

The client does not treat a WebSocket frame as authoritative. TanStack Query is patched from frames so the UI updates immediately, but any doubt resolves to a REST refetch. The two rules that make this safe are that writes go over REST with a single authorization path, reads come over the socket, and a frame is an optimization over a refetch rather than a replacement for it.

At-least-once means duplicates are expected. A counter driven straight from frames will over-count, so sequence numbers exist to let a consumer detect a gap or a repeat, and the numbers are per topic rather than global because a global sequence would serialize fanout across every tenant.

Credits, cost and two pricing planes

There are two cost views and they must not be confused. The customer sees one combined per-minute rate with no seats and no platform fee, defaulting to a single minute rate billed 60/60, plus a recording surcharge while recording is on. Dial attempts are free, recorded for pacing and analytics and never billed, so a customer is charged for conversations rather than for effort.

The platform sees actual cost. Every Telnyx primitive a call consumes is costed per call: the API leg, the trunk, the browser leg, the recording, answering-machine detection, short-duration calls and abandoned calls. Those estimates are reconciled in the background against the carrier’s usage reports, and margin is measured against those actuals rather than against a model. Credits are issued manually by platform staff and held as an append-only ledger in integer micro-dollars, which removes floating-point drift from the balance and makes every top-up auditable.

The reason metering lives in the dialer rather than in a billing report is pacing. The pre-origination gate checks that the tenant has positive credits, so running out of money stops dialing rather than accumulating debt.

Lead lifecycle, retries and deliverability

A lead import handles header aliasing, E.164 normalisation, in-file and cross-list deduplication and DNC scrubbing, because a list from a customer is never shaped the way the importer expects. Attempts are governed by a retry engine with per-lead daily caps, attempt caps and backoff by outcome, so a busy signal and a wrong number do not wait the same time before the next try.

Deliverability is a first-class concern rather than an afterthought. Calls carry STIR/SHAKEN attestation, DIDs have health and reputation tracked, and number rotation and dial caps limit how hard any single number is worked. The deliverability rule and the pacing rule interact: a number at its cap shrinks the pool the dialer can draw from, and that can bind before the abandonment budget does.

What broke, and what I would change

The pacing loop and the pre-origination gate are the two places where a small bug becomes a compliance event, and the gate is the one that was initially under-specified. Early on, an agent being free was evaluated as a boolean read, which is a race: two dials scheduled in the same tick can both observe the same free agent and both commit them. The fix is a lease on the agent, held until the leg is bridged or the attempt is settled, so the resource is reserved at the moment it is claimed rather than merely checked.

The second change is dull and took a dedicated audit script to catch. Abandonment was originally computed from the application’s own event log alone, and reconciling it against the carrier’s record exposed cases where the two disagreed by seconds. Both were right in their own terms, because one measured answer-to-agent-attach and the other answer-to-hangup, and the definitions had to be written down before the number could be trusted. A compliance number is a specification problem as much as an engineering one, and the specification should have existed before the first dial.

References

  1. [Author]Aryan (Uo1428)

Built with

BunElysiaMongoDBTelnyxLiveKitReact 19

Related production systems from the same category.

All case studies →

Want this kind of system on your side of the table?