AM Message Length Detect and BackgroundDetect()

I am attempting to use Background Detect() to do answering machine detect coupled with ‘Originate’ requests via the Asterisk Manager API. I am able to detect a person without a problem, but detecting an answering machine is proving elusive.

I have created silence files for 15.gsm, 20.gsm, 25.gsm, 30.gsm to try varying lengths, but it always timesouts with the last NoOp below. I am dialing from one Asterisk server to another where I am both answering and using Voicemail().

Anyone had any reliable experience in doing this? Recommendations on tweaks?

[quote="/etc/asterisk/extensions.ael"]
context test_am_detect {
s => {
Set(TIMEOUT(DIGIT)=5);
Set(TIMEOUT(RESPONSE)=5);
am_detected = 0;
Answer();
BackgroundDetect(silence/5|1000|50);
am_detected = 1;
BackgroundDetect(silence/30|1000|50|30050);
NoOp(Messaging too long, hanging up);
Hangup();
};

    talk => {
            if (${am_detected} = 0) {
                    Playback(demo-congrats);
            } else
                    Playback(this-is-the-voice-mail-system);
    };

};[/quote]

I think the trick may be something like this:

[quote="/etc/asterisk/extensions.ael"]context test_am_detect {
s => {
Set(TIMEOUT(DIGIT)=5);
Set(TIMEOUT(RESPONSE)=5);
am_detected = 0;
Answer();
BackgroundDetect(silence/5|1000|50);
am_detected = 1;
WaitforSilence(2000);
Playback(this-is-a-vmail-box);

Hangup();
};

talk => {
Playback(demo-congrats);
};
};[/quote]

Also going to have a look at this:

thenetbrain.com/files/app_machinedetect.c

Still looking…

PS - I just added this to the Asterisk Wiki:

voip-info.org/wiki/index.php … t%20(addon