The module as currently written requires extensions to be in a custom context in order to dial a URI. This is less than ideal for various reasons, so I have figured out a way to avoid that step. Basically the extension dials the uri with a # in place of the @ such as lenny#itslenny.com. In the dial-trunk-predial-hook context, set a variable with the @ substituted for the # then call up the agi file. The agi file checks the contents of the variable and determines if it meets the format of a SIP URI and if so it sets a dial variable. If the dial variable is set, it is dialed otherwise regular dialplan continues.
#!/usr/bin/php -q
<?php
require('phpagi.php');
error_reporting(0);
$AGI = new AGI();
if (!isset($argv[1])) {
$AGI->verbose('Missing dial string',3);
exit(1);
}
// get dial string passed to agi
$sipuri = $argv[1];
$AGI->verbose('raw dial string: '.$sipuri,3);
$regex = "/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i";
preg_match($regex,$sipuri,$match);
if ( isset($match[0])) {
$AGI->set_variable('sipruidial', $match[0]);
$AGI->verbose("this is the URI: ".$match[0],3);
}
?>
I have rough tested these blocks of code, and everything seems to work. You probably need an outbound route set as any/any so that the URI is not blocked by the outbound route dialing rules.
The module as currently written requires extensions to be in a custom context in order to dial a URI. This is less than ideal for various reasons, so I have figured out a way to avoid that step. Basically the extension dials the uri with a
#
in place of the@
such aslenny#itslenny.com
. In the dial-trunk-predial-hook context, set a variable with the@
substituted for the#
then call up the agi file. The agi file checks the contents of the variable and determines if it meets the format of a SIP URI and if so it sets a dial variable. If the dial variable is set, it is dialed otherwise regular dialplan continues.add to extensions_custom.conf:
/var/lib/asterisk/agi-bin/sipuri.php
I have rough tested these blocks of code, and everything seems to work. You probably need an outbound route set as any/any so that the URI is not blocked by the outbound route dialing rules.