[asterisk-users] HELP - Client wants to reverse Asterisk Functionality
Steve Edwards
asterisk.org at sedwards.com
Wed Jul 20 20:44:19 CDT 2011
> On Wed, 20 Jul 2011, Danny Nicholas wrote:
>
>> I?m putting Asterisk in to replace an existing IVR and that PBX system
>> uses * to terminate number input instead of #.
On Wed, 20 Jul 2011, Steve Edwards wrote:
> How about an AGI executing some mix of get data, get option, stream
> file, or wait for digit and accumulate the digits yourself.
On Wed, 20 Jul 2011, Danny Nicholas wrote:
> I modified the agi-test.agi that comes in the can to do just this, it
> just doesn't terminate when the user presses * (still have to wait for
> the timeout)
On Wed, 20 Jul 2011, Steve Edwards wrote:
I was thinking more like (in PHP, sorry -- my Perl skills suck):
#!/usr/bin/php -q
<?php
// initialize the AGI environment
require('phpagi.php');
$agi = new AGI();
// extract our parameters
$idx = 1;
$variable = $argv[$idx++];
$filename = $argv[$idx++];
$max_digits = $argv[$idx++];
$timeout = $argv[$idx++];
$terminator = $argv[$idx++];
// play the file and get the first digit
$dtmf = '';
$result = $agi->get_data($filename, $timeout, 1);
$key = $result['result'];
// loop for the remaining digits
while ((strlen($dtmf) < $max_digits)
&& ($key != $terminator))
{
$dtmf .= $key;
$result = $agi->wait_for_digit($timeout);
$key = chr($result['result']);
}
// set the channel variable
$agi->set_variable($variable, $dtmf);
?>
And then, in your dialplan:
exten = *,n,agi(read-with-terminator.php,RESPONSE,demo-congrats,10,10000,*)
exten = *,n,verbose(1,${RESPONSE})
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
More information about the asterisk-users
mailing list