Search code examples
phpasteriskagi

DTMF not accepted on PHP Agi


I am trying to grab the DTMF from user, if its equal to zero then transfer call to an extension else hangup. I have written the following, but it directly plays invalid entry and hangs up my call. Would appreciate help over this matter.

$wheretorec = $agi->exec("AGI","googletts.agi,\"To speak to an operator press zero.\",en"); 
$whereto = $agi->get_data($wheretorec, 10000, 1);
$dtmf = $whereto['result'];

if (is_numeric($dtmf ['0'])) 
{
$agi->exec("AGI","googletts.agi,\"Your call is now being transferred\",en");
$agi->exec('transfer',"SIP/[email protected]:5080");   
$agi->hangup();
} 
else 
{
$agi->exec("AGI","googletts.agi,\"Invalid entry. Please try again later.\",en");
$agi->hangup(); 
}
}

Solution

  • Have be like this

    $dtmf = $whereto['result'];
    
    if ($dtmf=="0")
    

    Please read corefully phpagi docs and examples