Help - Voicemail and real live people

I finally figured how to call out.

When I call out to a landline or a mobile phone I want to leave a message with the person I’m calling, however I would like for them to identify themselves before playing the message.

So when I call I will ask them to enter a PIN number, if its correct I will play the message.

However, if they don’t pick up, and their voicemail answers, I would like to leave this message: “you have a message with us, please call us asap”.

So I need to know if a real person is answering the phone, or if their voicemail is picking up, because I need the system to do 2 different things.

So far I don’t see Asterisk allowing me to make this difference, it appears that it responds the same to both a real person and a voicemail and wont let me distinguish between the 2.

Is there a way I can tell the difference using Asterisk or maybe a third-party open source software?

I was reading this site:
marko.net/asterisk/archives/0211/0471.html

And I haven’t been able to find any answers to this.

Please help!

look into machinedetect

Awesome!!! Thanks man, worked out perfectly!!!

[call-out]
exten => s,1,Answer
exten => s,2,Wait
exten => s,3,MachineDetect(700,2,2200)
exten => s,4,GotoIf($[${MACHINE} = 1]?5:7)
exten => s,5,AGI,festival-script.pl|This must be a machine!
exten => s,6,Hangup
exten => s,7,AGI,festival-script.pl|Hey you are a real person!
exten => s,8,Hangup

Now all I need to know is how can I know if the person has no voicemail at all. Like the person doesn’t pick up, they don’t have voicemail, it just keeps ringing or hangs up… How can I add this functionality as well?

Thanks a lot for your help!