I just have a couple minor comments on the Perl syntax.

Gopal krishnan wrote:
> oh it seems to be very easy.... i though it will be complicated and i am
> trying to read perl books...:(
>
> Thank you very much and i will keep on working on this....
>
> On Fri, Jul 1, 2011 at 8:18 PM, Asterisk - thinking:systems
> <[email protected]
>> wrote:
>
>> **
>>
>> hi again,
>>
>>
>>
>> no, you do not have to think that complicated. Just use the normal
>> asterisk
>> commands and your dialplan!
>>
>>
>>
>> here just a short example:
>>
>>
>>
>> ...answer...
>>
>> #ask for the choice and save it to your var:
>>
>> $choice= $AGI->get_data("$pfad/sounds/bsf-tel1", 5000, 26);

All Perl scripts should be using the strict and warnings pragmas and as
such, $choice should be a lexical var.  i.e.,

my $choice = $AGI->get_data("$pfad/sounds/bsf-tel1", 5000, 26);

>>
>> #play a thank you:
>>
>> $AGI->stream_file("$path/$thankyou");

I'm not sure which is more efficient but, if you exec Playback instead of
stream_file, asterisk will look for the file in its sounds directory if
the path isn't specified.

$AGI->exec('Playback', $thankyou);

>>
>> #do something with the choice:
>>
>> #play Sie werden verbunden
>>
>> if($choice eq '1') {

Since $choice holds an integer, it would be better to test it as such,
rather than forcing perl to stringify it..

if($choice == 1) {

>>
>> #if user pressed 1 stream a file to the user:
>>
>> $AGI->stream_file("$pfad/$bsftransfer");
>>
>> }
>>
>> else {
>>
>> #if the user pressed something else execute an astereisk command
>>
>> #here we do a goto  where the extension is defined in a variable:
>>
>> $AGI->exec('GoTo', $bsgoto);

I need to do some more testing, but so far I haven't been able to get the
GoTo statement to go to an extension in a different context.

I've been having to resort to using:

$AGI->set_context($context)
$AGI->set_extension($extension)
$AGI->set_priority($priority)

>>
>> }#ende if choice
>>
>> exit;
>>
>>
>>
>>
>>
>> I hope this does help you. With this little description you should be
>> able
>> to do quite everything ;-)
>>
>>
>>
>> cheers
>>
>> martin
>>
>>
>>
>>
>>
>> ----- Original Message -----
>> *From:* Gopal krishnan <[email protected]>
>> *To:* Martin Schrott - thinking:systems <[email protected]>
>> *Cc:* [email protected]
>> *Sent:* Thursday, June 30, 2011 7:25 PM
>> *Subject:* Re: Examples of IVR scripts
>>
>> ok thank you let me try and how about the validation with if
>> structures....
>> like if i am pressing 1 it has to play some file or ring some extension.
>> ringing some extension i think i have to do with asterisk perl outgoing
>> module specified in this link
>> http://search.cpan.org/dist/asterisk-perl/lib/Asterisk/Outgoing.pm
>>
>> please correct me if i am wrong.
>>
>> On Wed, Jun 29, 2011 at 12:26 AM, Martin Schrott - thinking:systems <
>> [email protected]> wrote:
>>
>>> **
>>> Gopal,
>>>
>>> your script hangs up, because there is nothing more to do in it.
>>>
>>> you could fetch the userdata via a get command and let this play a
>>> sound
>>> to the user:
>>>
>>>
>>> $userdata= $AGI->get_data("$sounds/please_enter", 5000, 26);
>>>
>>>
>>>
>>> you specifie a soundfile, a timeout and the length of maximum digits to
>>> enter by the user.
>>>
>>>
>>>
>>> all the best,
>>>
>>> Martin
>>>
>>>
>>>
>>> ----- Original Message -----
>>> *From:* Gopal krishnan <[email protected]>
>>> *To:* [email protected]
>>> *Sent:* Tuesday, June 28, 2011 7:45 PM
>>> *Subject:* Examples of IVR scripts
>>>
>>> Hi,
>>>
>>> Is there any example available for basic IVR steps. I tried to find but
>>> I
>>> am not able to get it done.
>>>
>>> My script as follows,
>>>  #!/usr/bin/perl
>>> use Asterisk::AGI;
>>> $agi=new Asterisk::AGI;
>>> $agi->answer();
>>> $agi->stream_file('hello-world','1');
>>> $agi->wait_for_digit('10');
>>>
>>>
>>> In the above script after playing the hello-world if i press 1 the call
>>> is
>>> hanging up, not even waiting for the dtmf input. So any examples please
>>> direct me to there.
>>>
>>> Regards,
>>> Gopal.
>>>
>>>
>>
>

-- 
Ron Bergin
Network Operations Administrator
Fry's Electronics Inc.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to