marcelog / PAGI

PHP AGI ( Asterisk Gateway Interface ) facade, with CDR ( Call Detail Record ), Call spool and schedule auto dial, Send and Receive Fax, Channel Variables, and Caller ID management
http://marcelog.github.com/PAGI
Apache License 2.0
191 stars 76 forks source link

Added LocalDialDescriptor class #20

Closed staelche closed 10 years ago

staelche commented 10 years ago

I added a LocalDialDescriptor class to accomplish using call files to trigger automated outgoing calls + be able to set sip headers before actually placing the call.

I need this since my SIP provider needs the 'P-Preferred-Identity' header to be set to the outgoing number. With this descriptor class I generate a call file, which executes the given context and extension. This adds the sip header and calls a number I added as a custom variable. In the call file I mention the application (AGI) and the AGI script, which should be connected to the call, as well.

extensions.conf:

[test]
exten => 3000,n,SIPAddHeader(P-Preferred-Identity: <sip:0123456789@xxxx.de>)
exten => 3000,n,Dial(SIP/${NUMBER},20,L(60000))
exten => 3000,n,Hangup

Code generating the call file:

$dialDescriptor = new LocalDialDescriptor("test", "3000");  
$callFile = new CallFile($dialDescriptor);  
$callFile->setPriority(1);
$callFile->setApplication('AGI');
$callFile->setApplicationData(array('path to pagi ivr.sh'));
$callFile->setVariable('NUMBER', '9876543210@xxxx.de');

$spool = CallSpoolImpl::getInstance(array(  
    "tmpDir" => "/tmp/temporaryDirForSpool",  
    "spoolDir" => "/var/spool/asterisk"  
));  
$spool->spool($callFile);

Generated call file:

Channel: LOCAL/3000@test
Priority: 1
Application: AGI
Data: path to pagi ivr.sh
Set: NUMBER=9876543210@xxxx.de
staelche commented 10 years ago

Sorry, I forgot to add the test case. I will do this in the next days.

marcelog commented 10 years ago

Looks good, thank you :) I'll be happy to merge when the unit tests are in place :)

staelche commented 10 years ago

Already found some time :-)

marcelog commented 10 years ago

thanks! :)