DTMF Signal

is there any way of capturing DTMF Signals in AGI

for example if user enters 123 from keypad and we capture these DTMF signals with AGI and then perform certain actions e.g: playing sound files making user feel that s/he is playing a piano.

if some one can help me find way to capture DTMF signals in AGI weather a user pressed nothing or presses combination of keys.

thanks

voip-info.org/wiki/view/get+data

here’s my code

$stream_file: says following
press 1 to create a Peer Asterisk account
press 2 to create a Friend Asterisk account
press 3 to create an User Asterisk account
press # to know abt Peer, Friend, User
press * to Repeat this menu again

for($a=0;$a=2;a++ ) {
$opts = $agi->get_data($stream_file, 10000, 1);
if(($a==2) && ($opts ==NULL){
$agi->hangup($channel)
}
elsif(($a!=2) && ($opts !=NULL)) {
$a == 2;
while( ! (($opts == 1) || ($opts == 2) || ($opts == 3) || ($opts == ‘#’) || ($opts == ‘*’)) ) {
$AGI->exec(‘Playback’,‘invalid’);
$opts = $agi->get_data($stream_file, 10000, 1);
}
if ($opts == 1) {
# create a peer
}
elsif ($opts == 2) {
# create a friend
}
elsif ($opts == 3) {
# create a user
}
elsif ($opts == *) {
#repeate menu
}
else {
$AGI->stream_file($about,“0”);
}
}
}

Now the problem comes when user presses pound ‘#’ … $opts gets NULL value and that becomes similar for the timeout because the $opts value is initially NULL and that is set to repeat the menu on timeout. so the two different actions could not be performed with one input.

Is it possible to get timeout with following so the issue can be solved

failure: 200 result=-1
timeout: 200 result= (timeout)
success: 200 result=

hope U get my point …Thankx

$menu = array(‘4’=>‘MIBorg_to.call.your.correspondant’, ‘2’=>‘MIBorg_to.save.your.msg’, ‘3’=>‘MIBorg_to.delete.it’, ‘#’=>‘MIBorg_to.listen.to.the.next.msg’, ‘8’=>’’
, ‘1’=>’’, ‘5’=>’’, ‘6’=>’’, ‘7’=>’’, ‘9’=>’’, ‘0’=>’’);

$PRESS = $AGI->menu($menu, $timeout = 5000);

$PRESS = trim($PRESS);
switch($PRESS)
{
case ‘4’ : //call your correspondent

returnSenderCall($myPath, $AGI, $msg, $user, $sex_of_message);
$flag = 0;
break;

case ‘#’ : //Go to next message ~ skip message
break;

case ‘’ : //CATCH no key pressed/timeout

sleep(4);
$flag = 1;
break;

same issue as gtcleaves . ‘#’ is not recognised as a DTMF digit. I also use ’ ’ to recognised no input entered.