How do I deal with answering machine?

Hi –

I have a need to leave an outgoing message on an answering machine or voicemail if no-one picks up. I tried to use BackgroundDetect but I can see the flaw in this as it really doesn’t know when a human answered versuses a recorded message.

Does anyone know how others deal with this situation? Now and then I get messages left on my voicemail so I know it can be done.

Many thanks!

Sorry, what is the problem ?

You need to what ?
You want to record an outgoing message for your VM within Asterisk ?

Is that what you need to know?

You may want to try the MachineDetect app addon.

Also, here is a method where someone is using that backgrounddetect. … 10060.html

Thanks, I had tried those two solutions and both do not really work that well. I tried another called AMD which I believe was written by someone at Digium. This worked well with a couple of voicemails I tried but not all. If anyone has experience with AMD please let me know. It takes about 5 parameters so tweaking them is a real pain.

Thanks a lot.

app_amd(AMD) was written by Aheeva(a proprietary Asterisk-based dialer company). It is a very good and efficient Answering Machine detector, but you need to tune it to your needs. You will see there are several parameters that you can play around with when you call it:
exten => 1234,1,AMD(3500|1500|300|5000|120|50|5|256)

Start changing those around and see what works best for you.

mflorell – thanks for the info, the example you provided is that a working example from your own implementation?

Yes, we have AMD integrated into VICIDIAL and have tested it in production, although we do not use it very often because we only do auto-dial messages very rarely.

Thanks. I will test out your parameters. Can I ask what you use to wait for playback after AMD has returned the status? For example, I currently have mine setup to count the number of words, figuring that the average person has a minium of about 7 words on a recorded message or the system generated voicemail message. AMD returns a status of “AMD_MACHINE” after word 7, then I have a Waitforsilence(2000) (2 seconds) to wait for the silence after the tone. I did try NVBackgroundDetect with the ‘t’ option (ignore voice) hoping that it would detect the tone when the message says “after the tone record your message etc.”, alas that didn’t work either.


We wait a standard 2 seconds after AMD returns a MACHINE status, although we have used several different settings in the AMD() call depending on what kind of campaign we were doing.


Thanks Matt - your settings seemed to work so far so good. The only thing I noticed is that if the recipient does not pick up the call and just let it go to voicemail then asterisk hangsup the line instead of waiting for the voicemail message. Any ideas?


What is the exact extensions.conf dialplan you have for this?

I instigate the call using the API over HTTP and calling a context in extensions_custom. I’m using a hacked version of Teleyapper. It looks something like this:

fputs ($fp, “Action: Originate\r\n”);
fputs ($fp, “Channel: $number\r\n”);
fputs ($fp, “Callerid: xxxxxxxxxx\r\n”);
fputs ($fp, “MaxRetries: 1\r\n”);
fputs ($fp, “RetryTime: 60\r\n”);
fputs ($fp, “WaitTime: 120\r\n”);
fputs ($fp, “Context: broadcast\r\n”);
fputs ($fp, “Extension: s\r\n”);
fputs ($fp, “Data: \r\n”);
fputs ($fp, “Variable: ID=$queueid\r\n”);
fputs ($fp, “Variable: DIAL=$number\r\n”);
fputs ($fp, “Variable: FILE=$file\r\n”);
fputs ($fp, “Data: \r\n”);
fputs ($fp, “Priority: 1\r\n\r\n”);

exten => s,1,Answer
;exten => s,2,Wait(2)
;exten => s,3,Playback(system-status-msg)
;exten => s,3,Wait(2)
exten => s,2,AMD(3500|1500|300|5000|120|50|5|256)
exten => s,3,GotoIf($["${AMDSTATUS}" = “AMD_MACHINE”]?s,6)
exten => s,4,NoOp(AMD Results: Status: ${AMDSTATUS} Cause: ${AMDCAUSE}
exten => s,5,Goto(talk,1)
exten => s,6,WaitForSilence(2000,1)
exten => s,7,Playback(customermessages/${FILE})
exten => s,8,Set(STATUS=‘AnsMachine’|g)
exten => s,9,DeadAGI(teleyapper2.php|${ID}|${STATUS}|${DIAL})
exten => s,10,Hangup
exten => t,1,Goto(talk,1)
exten => i,1,Goto(talk,1)
exten => o,1,Goto(talk,1)
exten => h,1,NoOp(Callee hung up call before menu. Dialed: ${DIAL} ID: ${ID}.)
exten => h,2,Set(STATUS=‘EarlyHangup’|g)
exten => h,3,DeadAGI(teleyapper2.php|${ID}|${STATUS}|${DIAL})
exten => h,4,Hangup
exten => talk,1,Playback(customermessages/${FILE})
exten => talk,2,Goto(broadcast2,s,1)

You got me, You’re already doing all of the things that I was going to suggest. If you figure it out post it please.

This config will leave a complete message for both human answer and answering machine. Message is played after two seconds of silence. Detecting voice or answering machine is another question, of course. I was unable to get backgrounddetect to work, but this seemed to work right away.

exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,waitforsilence(2000,1)
exten => s,4,Goto(talk,1)

exten => talk,1,Playback(custom/broadcast)

You might want to try removing these lines of your code; you have quite a delay.

;exten => s,3,Playback(system-status-msg)
;exten => s,3,Wait(2)

If you can get amd to work, I’d love to know your settings and how you installed it.

Just revisiting this. Can anyone tell me why I can’t just check for the tone that trails every single answering machine/voicemail system? ie. “To leave a message wait for the tone…”.


The big problems are amplitude and frequency with that. Some beeps are very short, some last longer than 2 seconds, some are high pitched and some are lower. That adds to the other issues of background noise and false detection of what would be a leave-message-beep on one system is just being background noise from a person leaving a message on another.

No answers for you, there is no perfect solution and lots of people have worked for years to figure this one out.