I'm trying to get my php-agi script to dial the next command if the first one is busy or fail in anyway. The way I set it up now won't just work, it just return busy and then died, or if it work, it would send two dial commands. Here's what I got:
$agi->exec('DIAL',"SIP/".$target."@".$ip.",30,g");
$agi->exec('DIAL',"SIP/".$target."@".$ip2.",30,g");
Any kind of help on this is greatly appreciated, thank you in advance!
When you call Dial()
asterisk sets a channel variable called DIALSTATUS.
You can read it from your AGI.
Output from "core show application Dial", from the CLI:
${DIALSTATUS}: This is the status of the call
CHANUNAVAIL
CONGESTION
NOANSWER
BUSY
ANSWER
CANCEL
DONTCALL: For the Privacy and Screening Modes. Will be set if the
called party chooses to send the calling party to the 'Go Away' script.
TORTURE: For the Privacy and Screening Modes. Will be set if the
called party chooses to send the calling party to the 'torture' script.
INVALIDARGS
Ex.
$agi->exec('DIAL',"SIP/".$target."@".$ip.",30,g");
$dialstatus = $agi->get_variable('DIALSTATUS');
if ( $dialstatus != 'ANSWERED' ) {
$agi->exec('DIAL',"SIP/".$target."@".$ip2.",30,g");
}
So the logic is simply to do the call, only if the first call was not answered.