I was hoping to use agi to implement a limit on inbound calls. Ideally an inbound would after 9 minutes play a sound recording to inform the user that 9 minutes has elapsed, even better if this can be played to the local user only and not be heard by the caller. After a further 1 minute the call is then hung up.
I have created in extension_override_freepbx.conf a replica of macro-auto-blkvm with a few additions
[macro-auto-blkvm] exten => s,1,Set(__MACRO_RESULT=) exten => s,n,Set(CFIGNORE=) exten => s,n,Set(MASTER_CHANNEL(CFIGNORE)=) exten => s,n,Set(FORWARD_CONTEXT=from-internal) exten => s,n,Set(MASTER_CHANNEL(FORWARD_CONTEXT)=from-internal) exten => s,n,Macro(blkvm-clr,) exten => s,n,ExecIf($[!${REGEX("[^0-9]" ${DIALEDPEERNUMBER})} && "${DB(AMPUSER/${AMPUSER}/cidname)}" != ""]?Set(MASTER_CHANNEL(CONNECTEDLINE(num))=${DIALEDPEERNUMBER})) exten => s,n,ExecIf($[!${REGEX("[^0-9]" ${DIALEDPEERNUMBER})} && "${DB(AMPUSER/${AMPUSER}/cidname)}" != ""]?Set(MASTER_CHANNEL(CONNECTEDLINE(name))=${DB(AMPUSER/${DIALEDPEERNUMBER}/cidname)})) exten => s,n,NoOp("************************************* THIS IS THE MACRO CONTEXT") exten => s,n,NoOp("************************************* CALL ANSWERED") exten => s,n,AGI(callInboundLimit.php) ;--== end of [macro-auto-blkvm] ==--;
I have a quick php script like so:
//Create the AGI Object
$agi = new AGI();
$chan_vars = $agi->request;
writeFile($agi->request);
$agi->Answer();
if($chan_vars['agi_callerid'] == 401)
{
errorLog("************************************** We have 401");
sleep(10);
errorLog("************************************** Beeping");
$this->exec('PLAYBACK','/var/lib/asterisk/sounds/en/beep');
}
The issue I seem to be having is that the AGI script needs to finish executing, for example I dial in and ext 401 picks up the call. Under the current circumstances 401 gets an answered message but on my line I continue to hear it ringing for approx 10 more seconds ie the value of the first sleep. I need to be able to continue with the call with the agi sitting in the background sleeping for 9 minutes until it needs to kick in play its sound file and then sleep for a further 1 minute before hanging up the call.
Can anyone advise if this is possible with agi and what can be done to make the script function as expected.