Docs / Asterisk install

Installing AMDY on Asterisk-Based Dialers

For custom Asterisk dialers (not ViciDial/Vicibox). This guide covers the Python EAGI script installation and dialplan integration.

Prerequisites

  • Asterisk 13+ with EAGI support enabled
  • Root/sudo access to the Asterisk server
  • Python 3.4+ installed (the installer will install it if missing)
  • Your AMDY.IO API key (get it from Settings)
  • Outbound internet access to ws://api.amdy.io:2700

Quick Install (one command)

curl -sL https://download.amdy.io/installamd-asterisk.sh | bash

The installer will prompt for your API key, install Python dependencies, and place the EAGI script at /var/lib/asterisk/agi-bin/amdy-amd.py.

Manual Install

If you prefer to install step by step:

1. Install Python dependencies

pip3 install pyst2 websocket-client

2. Download the EAGI script

mkdir -p /var/lib/asterisk/agi-bin
curl -sL https://download.amdy.io/amd.py -o /var/lib/asterisk/agi-bin/amdy-amd.py
chmod 755 /var/lib/asterisk/agi-bin/amdy-amd.py
chown asterisk:asterisk /var/lib/asterisk/agi-bin/amdy-amd.py

3. Verify installation

python3 -c "from asterisk.agi import AGI; from websocket import create_connection; print('OK')"

Dialplan Integration

Add the EAGI call to your dialplan. The script sets three channel variables you can use for routing:

[amd-context]
exten => s,1,Answer()
; Run AMDY EAGI script
exten => s,n,EAGI(amdy-amd.py)

; Route based on result
exten => s,n,GotoIf($["${AMDSTATUS}" = "HUMAN"]?human:machine)

; Machine detected - hangup or voicemail
exten => s,n(machine),NoOp(Machine detected: ${AMDCAUSE})
exten => s,n,Hangup()

; Human detected - route to agent
exten => s,n(human),NoOp(Human detected)
exten => s,n,Queue(sales-queue)
; ... or Dial(SIP/agent-01,30) etc.

Channel Variables

VariableValuesDescription
AMDSTATUSHUMAN or AMDDetection result
AMDCAUSEHUMAN, MACHINE, CONNECTION_ERRORReason code
AMDSTATSJSON stringRaw API response with timing data

How It Works

  1. EAGI call: Asterisk invokes the Python script and passes the audio stream via file descriptor 3.
  2. WebSocket connection: The script connects to ws://api.amdy.io:2700 with your API key.
  3. Audio streaming: 8kHz 16-bit mono PCM audio is streamed in chunks (0.7s, 1s, 2s, 3s intervals).
  4. Detection: The AMDY API analyzes the audio and returns a result (typically within 1-3 seconds).
  5. Variables set: The script sets AMDSTATUS, AMDCAUSE, and AMDSTATS channel variables.
  6. Dialplan routing: Your dialplan uses these variables to route the call (human → agent, machine → hangup/voicemail).

Troubleshooting

Script not found

If Asterisk reports File not found, check:

  • Script is at /var/lib/asterisk/agi-bin/amdy-amd.py
  • Script is executable: chmod 755
  • Asterisk user can read it: chown asterisk:asterisk
  • Check asterisk.conf for astagidir setting

Python import errors

If you see import errors, reinstall the dependencies:

pip3 install --force-reinstall pyst2 websocket-client

WebSocket connection failed

Check that the server can reach api.amdy.io:2700. Test with:

python3 -c "from websocket import create_connection; ws = create_connection('ws://api.amdy.io:2700'); print('Connected'); ws.close()"

AMDSTATUS always HUMAN on error

The script defaults to HUMAN on connection errors for safety (better to route a machine to an agent than hang up on a human). Check Asterisk logs for the actual error.

Support

Need help? Email [email protected] with:

  • Asterisk version (asterisk -V)
  • Python version (python3 --version)
  • Relevant Asterisk log output (asterisk -rvvv | grep AMD)