API reference / Voice and AI
Replace VICIdial AMD
VICIdial runs answering machine detection when a campaign's Routing Extension is 8369, or 8373 for surveys. This page adds three more routing extensions that do the same thing with Drop Cowboy® Detection. A campaign switches by changing its Routing Extension, and switches back the same way. VICIdial's own scripts read the result and route the call, so agents, statuses and messages work as they do now.
| Extension | Copy of | Use it for |
|---|---|---|
| 8378 | 8369 | Answering machine detection, then the agents |
| 8379 | 8369 | The same, but a machine result waits for the voicemail beep |
| 8380 | 8373 | Answering machine detection, then the survey |
Each extension is the stock one with one line changed, from AMD(...) to
EAGI(dc-amd,...) with the same arguments. dc-amd is the Asterisk drop-in
described in Replace Asterisk AMD; this page covers
what is specific to VICIdial.
Before you start
- A Detection key. See
Create a Detection key. If the key has
allowed_cidrs, include the public address of every dialer server. - Outbound access from each dialer server to
detect.dropcowboy.comon port 443. - Root access on each server that places calls.
- Permission to edit the dialplan in VICIdial. The system setting Allow
Custom Dialplan Entries (
allow_custom_dialplan) must be on, and your admin user needs Modify Custom Dialplans (modify_custom_dialplans). Without them the Custom Dialplan Entry field shows Disabled.
Install
Run this on every server that places calls:
curl -fsSL https://github.com/Drop-Cowboy/pbx-connect/releases/latest/download/install.sh | sudo bash
The installer:
- checks that 8378, 8379 and 8380 are free in the running dialplan, in
/etc/asterisk/extensions*.confand in VICIdial's phones. If one is taken, it stops and changes nothing; - downloads
dc-connectfor the server's CPU and checks it against the release'sSHA256SUMS; - installs it in
/var/lib/asterisk/agi-binand linksdc-amdto it; - asks for your Detection key without showing it, and writes it to
/etc/dc-amd/dc-amd.conf, mode 0640; - adds a
[beep]profile to that file, for 8379; - runs
dc-amd check, which opens a short session with Detection; - prints the block to paste into VICIdial.
Your key lives only in /etc/dc-amd/dc-amd.conf. The installer never takes it
as a command-line argument and never prints it. Run the installer again to
upgrade: it keeps the config file and says when the block is already loaded.
| Option | Use it when |
|---|---|
--key-file PATH |
You install from a script. The file holds only the key. DC_AMD_KEY in the environment works too. |
--non-interactive |
Nothing may prompt. The install fails if it needs a key and has none. |
--binary PATH |
The server can't download. Copy dc-connect-linux-amd64 or dc-connect-linux-arm64 and SHA256SUMS into one directory and pass the binary. |
--extensions A,B,C |
8378 to 8380 are taken. Pass three free extensions from 8378 to 8399, and use them wherever this page says 8378, 8379 and 8380. |
To pass options through the pipe, use sudo bash -s -- --key-file /root/dc.key.
The installer exits with 3 when it refuses, and changes nothing. It exits with
4 when it installed but dc-amd check failed; calls then fail open until the
check passes. See Common problems.
Paste the block
The installer prints this block. It is also custom-dialplan.conf in the
release.
exten => 8378,1,AGI(agi://127.0.0.1:4577/call_log)
exten => 8378,n,Playback(sip-silence)
exten => 8378,n,EAGI(dc-amd,2000,2000,1000,5000,120,50,4,256)
exten => 8378,n,ExecIf($["${AMDSTATUS}" = ""]?MSet(AMDSTATUS=NOTSURE,AMDCAUSE=TOOLONG))
exten => 8378,n,AGI(VD_amd.agi,${EXTEN})
exten => 8378,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB-----${CONNECTEDLINE(name)})
exten => 8378,n,Hangup()
exten => 8379,1,AGI(agi://127.0.0.1:4577/call_log)
exten => 8379,n,Playback(sip-silence)
exten => 8379,n,EAGI(dc-amd,2000,2000,1000,5000,120,50,4,256,profile=beep)
exten => 8379,n,ExecIf($["${AMDSTATUS}" = ""]?MSet(AMDSTATUS=NOTSURE,AMDCAUSE=TOOLONG))
exten => 8379,n,AGI(VD_amd.agi,${EXTEN})
exten => 8379,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB-----${CONNECTEDLINE(name)})
exten => 8379,n,Hangup()
exten => 8380,1,AGI(agi://127.0.0.1:4577/call_log)
exten => 8380,n,Playback(sip-silence)
exten => 8380,n,EAGI(dc-amd,2000,2000,1000,5000,120,50,4,256)
exten => 8380,n,ExecIf($["${AMDSTATUS}" = ""]?MSet(AMDSTATUS=NOTSURE,AMDCAUSE=TOOLONG))
exten => 8380,n,AGI(VD_amd.agi,${EXTEN})
exten => 8380,n,AGI(agi-VDAD_ALL_outbound.agi,SURVEYCAMP-----LB-----${CONNECTEDLINE(name)})
exten => 8380,n,Hangup()
- Open Admin > Servers, pick the server, and paste the block into Custom
Dialplan Entry. To load it on every server at once, paste it into Admin >
System Settings > Custom Dialplan Entry instead. Either way, install
dc-amdon every server first. - On the server, set Rebuild conf files to Y and submit. VICIdial rebuilds the dialplan within a minute.
- Confirm it loaded:
asterisk -rx "dialplan show 8378@default"
The ExecIf line runs only if dc-amd couldn't start, for example on a
server where it isn't installed. It sets the same result as any other
fail-open call, so the call still reaches an agent.
To use different AMD settings, change the numbers on the EAGI line. They are
the nine AMD() arguments in the same order; see
Arguments.
Choose the routing extension
In Campaigns, open the campaign's Detail view and set Routing Extension
(campaign_vdad_exten):
| Campaign now uses | Change it to | What changes |
|---|---|---|
| 8369 | 8378 | Detection decides; VICIdial routes as before. |
| 8369, and leaves a message on machines | 8379 | The machine result arrives at the end of the greeting. See Leave a message at the beep. |
| 8373 (survey) | 8380 | Detection decides; people go to the survey. |
The change applies to the next call the campaign places. Move one campaign first and watch its results before you move the rest.
Leave a message at the beep
VICIdial can play a recorded message to answering machines. With 8379,
dc-amd returns MACHINE when the greeting ends, at the beep or at the end of
a greeting without one, so VICIdial can start the message right away. A person
still comes back as HUMAN as soon as they're heard.
Set these on the campaign:
| Setting | Value |
|---|---|
Routing Extension (campaign_vdad_exten) |
8379 |
AMD send to Action (amd_send_to_vmx) |
Y |
Answering Machine Message (am_message_exten) |
Your message |
WaitForSilence Options (waitforsilence_options) |
Empty, or NONE |
Clear WaitForSilence Options. VICIdial runs it before the message to wait for the greeting to end, and on 8379 the greeting has already ended, so it only adds silence on the recipient's voicemail.
On 8379 the time limit is beep_timeout_sec, 30 seconds by default, in place
of the 5 seconds on the EAGI line. To change it, set beep_timeout_sec in
the [beep] section of /etc/dc-amd/dc-amd.conf.
A full mailbox or one that isn't set up also comes back as MACHINE, with
AMDCAUSE starting FULLMAILBOX or NOTSETUP. VICIdial plays the message to
those too.
Modes
Set mode in /etc/dc-amd/dc-amd.conf. It applies from the next call, with
no rebuild.
| Mode | What happens on the call | Use it to |
|---|---|---|
replace |
Detection decides. | Run on Drop Cowboy Detection. This is the default. |
shadow |
AMD() decides with the arguments on the EAGI line, so the campaign behaves as it did on 8369. dc-amd also records the audio and, after the call, sends it to Detection and saves both answers. |
Compare before you switch. |
off |
AMD() decides. Nothing goes to Detection. |
Turn Detection off without touching VICIdial. |
In Shadow mode, see how often the two answers agree with:
/var/lib/asterisk/agi-bin/dc-amd stats --since 24h
The config file is per server, so set the same mode on every server.
What VICIdial sees
dc-amd sets AMDSTATUS and AMDCAUSE, which VICIdial's VD_amd.agi reads.
VICIdial compares the part of AMDCAUSE before the first dash, shown here as
the cause, with its agent route options and status maps.
| Result | AMDSTATUS |
AMDCAUSE |
Cause | With stock VICIdial settings |
|---|---|---|---|---|
| A live person | HUMAN |
HUMAN-<ms>-0 |
HUMAN |
An agent |
| A voicemail greeting | MACHINE |
GREETING-<ms>-0 |
GREETING |
Machine handling |
| The greeting ended with a beep | MACHINE |
BEEP-<ms>-<beep end ms> |
BEEP |
Machine handling |
| The greeting ended without a beep | MACHINE |
GREETINGEND-<ms>-0 |
GREETINGEND |
Machine handling |
| A full mailbox | MACHINE |
FULLMAILBOX-<ms>-0 |
FULLMAILBOX |
Machine handling |
| A mailbox that isn't set up | MACHINE |
NOTSETUP-<ms>-0 |
NOTSETUP |
Machine handling |
| A carrier message | MACHINE |
INTERCEPT-<ms>-0 |
INTERCEPT |
Machine handling |
| A phone menu | MACHINE |
IVR-<ms>-0 |
IVR |
Machine handling |
| A fax machine | MACHINE |
FAX-<ms>-0 |
FAX |
Machine handling |
| A call screener | NOTSURE |
CALLSCREEN-<ms>-0 |
CALLSCREEN |
An agent |
| Nobody spoke | MACHINE |
INITIALSILENCE-<ms>-2000 |
INITIALSILENCE |
Machine handling |
| No decision in time | NOTSURE |
TOOLONG-<ms> |
TOOLONG |
An agent |
| The person hung up | HANGUP |
Empty | Empty | VICIdial ends the call |
<ms> is the time to the decision in milliseconds. Machine handling means
VICIdial sets the machine status and hangs up, or plays the campaign's message
when AMD send to Action is Y.
If your agent route options or status maps match on AMD()'s own cause names,
such as MAXWORDS or LONGGREETING, either rewrite them with the causes above
or set cause_names = stock in the config file. See
Stock cause names.
To route call screeners, or calls where nobody spoke, another way, set
screener_status or silence_status in the config file.
dc-amd also sets AMDSTATS, which VICIdial stores in its AMD log. The
installer sets amd_stats = yes in the config file, because VICIdial's
Asterisk 13.29.2 build doesn't name itself in its version string.
DC_AMD_* variables
VICIdial doesn't read these, but they're on the channel for your own dialplan and for support:
| Variable | Value |
|---|---|
DC_AMD_TYPE |
Detection's answered_by, such as human or machine_end_beep. Empty when Detection didn't decide. |
DC_AMD_BEEP, DC_AMD_BEEP_MS |
1 when the greeting ended with a beep, and when the beep ended. |
DC_AMD_SCREENER, DC_AMD_FAX |
1 for a call screener or a fax machine. |
DC_AMD_MS |
The time to the result, in milliseconds. |
DC_AMD_SESSION |
The Detection session ID, for support. |
DC_AMD_SOURCE |
detection, native when AMD() decided, or failopen. |
DC_AMD_ERROR |
Why Detection wasn't used. Empty otherwise. |
Fail open
dc-amd never hangs up a call and never holds it past the time limit on the
EAGI line, 5 seconds in the block, or beep_timeout_sec on 8379. If
Detection can't answer, dc-amd sets AMDSTATUS=NOTSURE and
AMDCAUSE=TOOLONG-<ms>, and VICIdial sends the call to an agent.
DC_AMD_SOURCE is failopen and DC_AMD_ERROR says why; the full list is in
Fail open.
If dc-amd can't start at all, the ExecIf line sets NOTSURE and
TOOLONG, and the call goes to an agent the same way.
To run AMD() instead when Detection can't answer, set fail_open = native in
the config file.
VICIdial settings to check
AMD agent route options and status maps
With AMD Agent Route Options (amd_agent_route_options) off, VD_amd.agi
sends HUMAN, NOTSURE, HANGUP and call screeners to an agent, and
everything else to machine handling.
With them on, a call reaches an agent only if the campaign's
AMD_AGENT_OPT_<campaign> settings container has a line for its status and
cause. Include NOTSURE,TOOLONG, or every fail-open call takes machine
handling and hangs up. A container for dc-amd looks like this:
HUMAN,HUMAN
NOTSURE,TOOLONG
NOTSURE,CALLSCREEN
FAX-Hangup-ENABLED
If System Settings or the campaign sets an AMD Status Map (amd_status_map),
turn on AMD Agent Route Options for every campaign that uses 8378 to 8380, and
create its container. Without one, VD_amd.agi reads the status map in place
of the container, matches no agent line, and sends every call to machine
handling, people included.
No audio and fax
NOAUDIODATA-Hangup-ENABLEDhas no effect.dc-amdnever returns theNOAUDIODATAcause. A call that sends no audio comes back asNOTSUREandTOOLONGand reaches an agent. Remove the line, or leave it; it changes nothing.FAX-Hangup-ENABLEDworks. A fax machine comes back asMACHINEwith the causeFAX, and VICIdial hangs up with theFAXHUstatus.
Switch back
- One campaign: set its Routing Extension back to 8369, or 8373 for a survey. The next call uses VICIdial's own detection.
- Every campaign, with no VICIdial change: set
mode = offin/etc/dc-amd/dc-amd.confon each server. 8378 to 8380 then runAMD()with the same arguments. - For good: move every campaign back to 8369 or 8373, remove the block from Custom Dialplan Entry, then run the installer's uninstall on each server:
curl -fsSL https://github.com/Drop-Cowboy/pbx-connect/releases/latest/download/install.sh | sudo bash -s -- uninstall
Uninstall refuses while a campaign still routes to 8378 to 8380, because those
calls would lose detection. Add --purge to remove the config file and logs as
well.
GOautodial
GOautodial runs on VICIdial, so the steps are the same. Paste the block in
VICIdial's admin, at /vicidial/admin.php, and set the Routing Extension
there.
GOautodial sets the Routing Extension itself, to 8368 or 8369, from its
answering machine detection choice. Creating or editing a campaign in
GOautodial can write one of those back, which moves the campaign off dc-amd
and can turn answering machine detection off. After you change a campaign in
GOautodial, check its Routing Extension in VICIdial's admin.
Common problems
- The installer stops with "already in use". Another entry uses 8378, 8379
or 8380. Remove it, or rerun with
--extensionsand three free numbers from 8378 to 8399. - The installer exits with 4.
dc-amd checkfailed. Run/var/lib/asterisk/agi-bin/dc-amd checkto see why. The usual causes are a firewall blocking port 443 todetect.dropcowboy.comand a key whoseallowed_cidrsleave out the server's address. - Custom Dialplan Entry shows Disabled. Turn on Allow Custom Dialplan Entries in System Settings, and give your user Modify Custom Dialplans.
- Calls on 8378 get dead air. The block isn't loaded on that server. Set
Rebuild conf files to Y, wait a minute, then run
asterisk -rx "dialplan show 8378@default". - People are treated as machines. An AMD Status Map is set and the campaign has no AMD Agent Route Options container. See AMD agent route options and status maps.
- Calls hang up when Detection is unreachable. AMD Agent Route Options are
on and the container has no
NOTSURE,TOOLONGline. Add it. - Every call is
NOTSURE. Detection isn't being used. CheckDC_AMD_ERRORin/var/log/dc-amd/dc-amd.log, and see the Asterisk common problems. - Messages start over the greeting. The campaign uses 8378. Use 8379.
- Messages start after a long silence. WaitForSilence Options is set on a campaign using 8379. Clear it.
- A campaign is back on 8368 or 8369. It was saved in GOautodial. Set the Routing Extension again in VICIdial's admin.