Advice on autodialer - detect when dst answers


I have a simple auto-dialer that works fine.
The dialer dials a number through a Zap channel and then playback sound file. The dialer works by placing a call file in /var/spool/asterisk/outgoing.

I have however a problem, I can’t detect when the number dialed actually picks the phone. (When using a call file or manager api).
The problem I encounter is that I am not sure when to start the playback.
Now I use a delay of 8 seconds that works fine, but if the dialed person pick the phone in the first ring then he/she need to wait 1,2 sec, or if they pick the phone after 4 rings then they miss the start of the sound file.
Any idea how to detect when the other party actually picked the call?
(From Asterisk view the channel is up once Zap answered it)
The DIALSTATUS returns null.
Looking at manager events I also could not see an event that corresponds to the event that the called party picked the phone.

Here is the code of the call file and extesnion.conf:
Call file:

Channel: Zap/3/www9542922900
MaxRetries: 5
WaitTime: 30
Set: AUTODIALFILE=/var/lib/asterisk/sounds/PTV/broadcast_msg
Context: autodial-out
Extension: s
Priority: 1


;exten => s,1,Answer
exten => s,1,NoOp(${DIALSTATUS})
exten => s,n,Wait(9)
exten => s,n,NoOp(${DIALSTATUS})
exten => s,n,Background(${AUTODIALFILE})
exten => s,n,Hangup(end-of-auto-dial)


a “popular” problem, and one that plagues ZAP users that don’t get answer supervision.

search the wiki for “Newman Telecom” … you’ll find pages with NVLineDetect etc that you can use to detect tones, talking etc.

or just go here :

using analog channels it is not possible to get answer supervision unless you are using polarity reversal- then i think its answeronpolarityreversal=yes (or something like that). You must call your telco and request answer supervision for this to work. It means they send a CPC signal (same as disconnect supervision) when the call is answered so * knows.

I have heard of some people having decent luck using WaitForSilence() to detect silence (aka not ringing)…

Note that this problem does not happen with VoIP or PRI lines as they provide connect supervision.

for some weird reason, the devs called it ‘answeronpolarityswitch=’ … and i’ve only ever used it with a Sangoma A200 … the Digium cards seem to ignore it.

Thanks all - Will inform status
Update: The WaitForSilence() did help a lot.
It is not 100% but it works fine in many cases.
Thanks again all.