marcelog/PAGI — pull request #20 by staelche (2014-03-19 10:28:24+00:00)
Title: Added LocalDialDescriptor class

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