Erlang C in JavaScript: agents, service level and ASA
Erlang C answers the core staffing question for a queue: how many agents do you need on the phones so that a target share of contacts is answered within a target time?
The formulas
A = λ × h ÷ I traffic intensity (Erlangs) P_W = N·B ÷ (N − A·(1 − B)) probability a contact waits (B = Erlang B) SL = 1 − P_W · e^(−(N − A) · T ÷ h) share answered within T seconds ASA = P_W · h ÷ (N − A) average speed of answer sched = ⌈N ÷ (1 − shrinkage)⌉ agents to schedule
λ is contacts per interval, h is average handle time, I is the interval length and N is agents on the phones. The library computes Erlang B with the recursion B = A·B ÷ (j + A·B) instead of AN ÷ N!, so it stays numerically stable for thousands of agents. The tests check it against the factorial form and the published A = 10 table.
Worked example
100 contacts in a 30-minute interval, a 3-minute AHT, a target of 80% answered in 20 seconds and 30% shrinkage.
- Traffic: 100 × 180 ÷ 1800 = 10 Erlangs.
- 13 agents reach 79.56%, just short of the target. Rounding traffic up "plus a few" is how teams end up one agent short.
- 14 agents on the phones give 88.8% in 20 s, an ASA of 7.8 s and 71.4% occupancy.
- After 30% shrinkage, schedule 20 agents.
| Agents | P(wait) | Service level | ASA | Occupancy |
|---|---|---|---|---|
| 12 | 44.9% | 64.0% | 40.4 s | 83.3% |
| 13 | 28.5% | 79.6% | 17.1 s | 76.9% |
| 14 | 17.4% | 88.8% | 7.8 s | 71.4% |
| 15 | 10.2% | 94.1% | 3.7 s | 66.7% |
| 16 | 5.7% | 97.1% | 1.7 s | 62.5% |
Try it
Usage
import { solveStaffing, staffingTable } from 'contact-center-math/erlang-c'
const r = solveStaffing({
contacts: 100, // per interval
intervalSec: 1800, // 30 minutes
ahtSec: 180,
targetSL: 0.8, // 80% …
targetSec: 20, // … in 20 seconds
shrinkage: 0.3,
maxOccupancy: 0.85, // optional cap
aiContainment: 0, // share of contacts an AI agent fully handles first
})
// r.agents, r.scheduled, r.serviceLevel, r.asaSec, r.occupancy, r.feasible
Things Erlang C gets wrong
- No abandonment. Erlang C assumes every caller waits forever. Real queues lose impatient callers, so it slightly overstaffs busy intervals. Erlang A models abandonment if you have patience data.
- Steady arrivals inside the interval. Use 15- or 30-minute intervals, not daily totals. A daily average hides the peaks that drive staffing.
- Chat concurrency. An agent working three chats is not three agents. Model chat separately.
- AI containment changes the mix. If an AI agent resolves the easy contacts, the remaining contacts usually have a longer AHT. Re-measure AHT after rollout instead of keeping the old figure.