Replace AMD() in one line.
The connector puts Voicemail Detector where AMD() was. It takes the same parameters, waits no longer than AMD() did, and sets the same variables, so Vicidial and any dialplan that reads AMDSTATUS keep working.
It works with every Asterisk from 11 to 24, including the builds Vicidial installs. The code is open: github.com/voicemaildetector/connector.
Install
You need an API key from the dashboard and root on the Asterisk server.
curl -fsSL https://voicemaildetector.com/install.sh | sudo sh
sudo voicemaildetector setupsetup asks for the key, finds Asterisk, starts the service and sends a recorded voicemail greeting through it, so the first verdict comes before any call is touched.
Dialplan
Change AMD to EAGI(voicemaildetector,…) and keep its parameters. The fourth, totalAnalysisTime, is the longest the call waits for a verdict; with no parameters, 5 seconds.
-exten => 8369,n,AMD(2000,2000,1000,5000,120,50,4,256)
+exten => 8369,n,EAGI(voicemaildetector,2000,2000,1000,5000,120,50,4,256)Or let the connector do it: sudo voicemaildetector enable changes every AMD() in extensions.conf, and disable puts them back.
Vicidial
Vicidial runs AMD() in extensions 8369, 8373 and 8375 and then reads AMDSTATUS in VD_amd.agi. voicemaildetector enable changes those three lines; campaigns, AMD actions and reports stay as they are.
Variables
VDSTATUSHUMAN, MACHINE, NOTSURE or HANGUP.VDCAUSEThe verdict and the audio heard when it was given, like MACHINE-4500; UNKNOWN-5000 when the audio did not tell; ERROR-… when there was no verdict.VDMSMilliseconds of audio heard when the verdict was given.AMDSTATUS, AMDCAUSEThe same, where AMD() puts them, so everything that reads them keeps working.
When there is no verdict
The call is never held up by a failure. The connector answers at once with the status set by on_error in /etc/voicemaildetector/config, NOTSURE unless you change it, and a cause that says why.
ERROR-NOSERVICEThe local service is not running.ERROR-UNAVAILABLEThe API could not be reached: check outbound HTTPS to api.voicemaildetector.com.ERROR-KEYThe API key was refused.ERROR-PAYMENTThe account has no calls left.ERROR-TOOMANYCALLSThe plan is at its limit of simultaneous calls.ERROR-BUSYThe API is busy; the next call will likely go through.ERROR-TIMEOUTNo verdict in time.
To send those calls your own way, branch on the cause:
exten => 8369,n,EAGI(voicemaildetector,2000,2000,1000,5000,120,50,4,256)
exten => 8369,n,GotoIf($["${VDCAUSE:0:6}" = "ERROR-"]?fallback)Commands
voicemaildetector setupWrites the settings, starts the service and checks it with a recorded voicemail greeting.voicemaildetector enable · disableSwitches every AMD() in extensions.conf to the connector and back, showing the change first, keeping a copy and reloading the dialplan.voicemaildetector test [file.wav]Sends a recording through the service and prints the verdict.voicemaildetector doctorChecks Asterisk, the service, the connection to the API and the dialplan, and says what is missing.voicemaildetector statusShows the connections to the API and the calls counted since the service started.
How it connects
A local service holds the API key and a few encrypted connections to the API that every call shares. For each call, Asterisk starts a short helper that passes the callee's audio to that service and sets the variables when the verdict comes. The key never appears in the dialplan, and a call does not open a connection of its own.
Linux on amd64 or arm64 with kernel 3.2 or later: CentOS 7, Debian 8, Ubuntu 14.04 and anything newer. The server needs outbound HTTPS to api.voicemaildetector.com; audio goes as G.711, 64 kbit/s per call.