tags:

views:

254

answers:

2

Hello,

I'm new to Asterisk AGI programming. Im trying to create a simple IVR, using asterisk-perl, where a user can enter any extension from 1 to 4. Here is my code so far:

use Asterisk::AGI;

$AGI = new Asterisk::AGI;

for($i = 0 ; $i < 2 ; $i++)
{
    $AGI->exec('Playback','welcome');

    $AGI->exec('WaitExten','5|m');


}

Now, I want to know the extension the user entered and take some action accordingly. How to get the extension entered by the user?

Thank You.

A: 

Well since the WaitExten command changes the user to a new extension, I suppose you can read the special variable ${EXTEN} after calling WaitExten. I'm not familiar with Asterisk::Perl though, I've only used FastAGI from Java, so I don't know the exact command, but there must be some command to read a variable's value.

Chochos
A: 

I believe you want to use get_data, allowing you to play a file and then wait a given time for a given number of digits e.g.:

$AGI->get_data('demo-welcome', 15000, 5);

See here

AdminMyServer