Asterisk answering machine detection in one EAGI call
LineVaults delivers Asterisk answering machine detection as a single EAGI application in your dialplan. It takes the place of AMD(), sets the same AMDSTATUS variable plus an AMDCAUSE, and hands the call back to AMD() whenever it can't judge it.
1. Requirements
| Item | Requirement |
|---|---|
| Asterisk | Version 13 or newer; EAGI is built in |
| Python | 3.6 or newer, standard library only |
| Network | Outbound TLS on port 443 to amd.linevaults.com |
| Client | linevaults.agi.py in /var/lib/asterisk/agi-bin/, mode 755 |
| Credentials | An API key from the dashboard; the Sandbox plan is free |
2. The dialplan change
Find the line that runs AMD() after Answer() and swap it for four lines. The first is the detection call; the rest send refused calls to the old detector.
same => n,AMD()
same => n,EAGI(linevaults.agi.py,wss://amd.linevaults.com/,YOUR_KEY,4500)
same => n,GotoIf($["${AMDSTATUS}" = "FALLBACK"]?native:decided)
same => n(native),AMD()
same => n(decided),NoOp(AMD says ${AMDSTATUS} / ${AMDCAUSE})
Whatever follows keeps reading AMDSTATUS as before. The arguments are the WebSocket URL, your key and the timeout in milliseconds; keep 4500, which covers the longest listening window plus network time.
3. What happens at runtime
- EAGI startsEAGI exposes the inbound audio to the script as a readable stream (fd 3).
- Audio streamsThe script sends it in 100 ms frames over TLS, key in the request header.
- One verdictAbout 2 s after answer, or up to 3.2 s for an unclear call.
- Variables set
AMDSTATUSandAMDCAUSE; the dialplan continues.
A refused key or an unreachable service produces FALLBACK straight away, ahead of any audio, and the native label sends the call through AMD(). A timeout after streaming has started sets MACHINE / UNKNOWN, so an uncertain call never lands on an agent.
4. AMD() and LineVaults, call by call
| Situation | Asterisk AMD() | LineVaults |
|---|---|---|
| "Hello? ... Hello?" | Often MACHINE, because a pause follows a short greeting | HUMAN |
| Short personal greeting | Often HUMAN | MACHINE |
| Call screening assistant | Usually HUMAN | MACHINE, cause SCREENING |
| Busy, SIT, fax, ringback | Not identified as tones | MACHINE, cause BUSY or TONE |
| Unclear answer | NOTSURE | Extra listening, to 3.2 s at most, then a firm answer |
| Possible AMDSTATUS values | HUMAN, MACHINE, NOTSURE, HANGUP | HUMAN, MACHINE, FALLBACK |
| Basis of the decision | Counts and durations: pre-greeting silence, greeting time, words | How the answer sounds, backed by tone and recorded-greeting checks |
| Tuning | Nine parameters, set in amd.conf or as dialplan arguments, shared by all calls | None |
| Cost | Free, runs on your server | Sandbox: 50,000 free calls each month; paid plans start at $119 (plans) |
The reasons behind each row are on the technology page, and the error rates are in the benchmark report.
5. Where it is used
- Custom predictive and power dialers built on Asterisk
- FreePBX and Issabel systems that run outbound campaigns
- VICIdial and GoAutoDial, which use Asterisk underneath and have their own guides
Running FreeSWITCH instead? See the FreeSWITCH AMD integration. Other software that streams 8 kHz, 16-bit PCM over a WebSocket can call the AMD WebSocket API directly.
Put a verdict on every answered call
Run it on one campaign next to your current AMD and compare. If the service can't help, your dialer falls back to Asterisk AMD() on its own.