login | register
Sat 17 of May, 2008 [12:52 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.
 
Google Ads
Shoutbox
  • Juan Ortega, Thu 15 of May, 2008 [10:33 UTC]: Hi everybody, I'm Juan, an ITCom student, and I need to know what basic elements I need to create a VoIP network. Can anybody helpme, please?,Thank you very much
  • gineta, Wed 14 of May, 2008 [03:58 UTC]: any here not fine the configuration of firewall juniper -screem for VOIP asterisk????
  • Anoop Prabhakaran, Tue 13 of May, 2008 [12:16 UTC]: I am developing Asterisk IVR, Whenever i make a internation call to the IVR system, the DTMF is not getting detected properly, this happens only for the first time, second call onwards system works fine. why this is happening
  • joe, Mon 12 of May, 2008 [04:27 UTC]: Is there an opensource browser based softphone, or a system like Busta where everything is not manages through their website?
  • Nick Barnes, Fri 09 of May, 2008 [11:36 UTC]: Christopher - yesterday I tried an Asterisk install on a CentOS 5.1 box with stock GUI and it all worked fine. Sorry I can't help.
  • aero, Fri 09 of May, 2008 [08:20 UTC]: can someone help me out on this, i tried to play some sound files on my asterisk box and this is the error message i got. WARNING[4429]: format_wav.c:169 check_header: Unexpected freqency 22050 May 8 11:17:39 WARNING[4433]: codec_gsm.c:194 gsmtolin_fra
  • Christopher Faust, Thu 08 of May, 2008 [14:15 UTC]: I beleive that I may have to change something in the xserver configuration. Please advise
  • Christopher Faust, Thu 08 of May, 2008 [14:14 UTC]: Everything was perfect. In the bios I have increased the memory allocated Still receive input not supported on my display.
  • Christopher Faust, Thu 08 of May, 2008 [14:13 UTC]: This would not be my main box. I am doing some testing to see if I can install zaptel and asterisk 1.4 on a full centos 5.1 box with development software Its bizzare, because before I went through the asterisk and zaptel installation everything was perfe
  • Nick Barnes, Thu 08 of May, 2008 [13:44 UTC]: Christopher - I can't see any way in which an Asterisk installation would muck your GUI, but remember that it is advised not to use a GUI on an Asterisk box anyway.
Server Stats
  • Execution time: 0.41s
  • Memory usage: 2.23MB
  • Database queries: 33
  • GZIP: Disabled
  • Server load: 0.42

Asterisk perl agi

Asterisk::AGI perl module documentation

NAME

      Asterisk::AGI - Simple Asterisk Gateway Interface Class

SYNOPSIS

      use Asterisk::AGI;

      $AGI = new Asterisk::AGI;

      # pull AGI variables into %input

              %input = $AGI->ReadParse();

      # say the number 1984

              $AGI->say_number(1984);

DESCRIPTION

This module should make it easier to write scripts that interact with the asterisk open source pbx via AGI (aster�isk gateway interface)

CALLBACKS

Callbacks provide a handy way receiving events like hangups. To use the callback function, simply define a function to handle the callback and then tell Perl AGI which funtion it is by sending it a reference. Here is an example:


  use Asterisk::AGI;

  # the AGI object
  my $agi = new Asterisk::AGI;
  # send callback reference
  $agi->setcallback(\&callback);

  # our callback function
  sub callback(){
     warn "The call has ended\n";
     set_context($context);

     exit;
  }


AGI COMMANDS

  • $AGI->stream_file($filename, $digits)
Executes AGI Command "STREAM FILE $filename $digits"

This command instructs Asterisk to play the given sound file and listen for the given dtmf digits. The fileextension must not be used in the filename because Asterisk will find the most appropriate file type.

Example: $AGI->stream_file('demo-echotest', '0123');

Returns: -1 on error or hangup, 0 if playback completes without a digit being pressed, or the ASCII numerical value of the digit if a digit was pressed.


  • $AGI->send_text($text)
Executes AGI Command "SEND TEXT "$text"

Sends the given text on a channel. Most channels do not support the transmission of text.

Example: $AGI->send_text('You've got mail!');

Returns: -1 on error or hangup, 0 if the text was sent or if the channel does not support text transmission.


  • $AGI->send_image($image)
Executes AGI Command "SEND IMAGE $image

Sends the given image on a channel. Most channels do not support the transmission of images.

Example: $AGI->send_image('image.png');

Returns: -1 on error or hangup, 0 if the image was sent or if the channel does not support image transmission.


  • $AGI->say_number($number, $digits)
Executes AGI Command "SAY NUMBER $number $digits"

Says the given $number, returning early if any of the $digits are received.

Example: $AGI->say_number('98765');

Returns: -1 on error or hangup, 0 if playback completes without a digit being pressed, or the ASCII numerical value of the digit of one was pressed.


  • $AGI->say_digits($number, $digits)
Executes AGI Command "SAY DIGITS $number $digits"

Says the given digit string $number, returning early if any of the $digits are received.

Example: $AGI->say_digits('8675309');

Returns: -1 on error or hangup, 0 if playback completes without a digit being pressed, or the ASCII numerical value of the digit of one was pressed.


  • $AGI->answer()
Executes AGI Command "ANSWER"

Answers channel if not already in answer state.

Example: $AGI->answer();

Returns: -1 on channel failure, or 0 if successful.


  • $AGI->get_data($filename, $timeout, $maxdigits)
Executes AGI Command "GET DATA $filename $timeout $maxdigits"

Streams $filename and returns when $maxdigits have been received or when $timeout has been reached. Timeout is specified in ms.

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


  • $AGI->set_callerid($number)
Executes AGI Command "SET CALLERID $number"

Changes the callerid of the current channel to <number>.

Example: $AGI->set_callerid('9995551212');

Returns: Always returns 1.


  • $AGI->set_context($context)
Executes AGI Command "SET CONTEXT $context"

Changes the context for continuation upon exiting the agi application.

Example: $AGI->set_context('dialout');

Returns: Always returns 0.


  • $AGI->set_extension($extension)
Executes AGI Command "SET EXTENSION $extension"

Changes the extension for continuation upon exiting the agi application.

Example: $AGI->set_extension('7');

Returns: Always returns 0.


  • $AGI->set_priority($priority)
Executes AGI Command "SET PRIORITY $priority"

Changes the priority for continuation upon exiting the agi application.

Example: $AGI->set_priority(1);

Returns: Always returns 0.


  • $AGI->hangup($channel)
Executes AGI Command "HANGUP $channel"

Hangs up the passed $channel, or the current channel if $channel is not passed. It is left to the AGI script to exit properly, otherwise you could end up with zombies.

Example: $AGI->hangup();

Returns: Always returns 1.


  • $AGI->exec($app, $options)
Executes AGI Command "EXEC $app $options"

The most powerful AGI command. Executes the given application passing the given options.

Example: $AGI->exec('Dial', 'Zap/g2/8005551212');

Returns: -2 on failure to find application, or what ever the given application returns.


  • $AGI->set_variable($variable, $value)
Executes AGI Command "SET VARIABLE $variable $value"

Sets the channel variable <variablename> to <value>.

Example: $AGI->set_variable('status', 'authorized');

Returns: Always returns 1.


  • $AGI->get_variable($variable)
Executes AGI Command "GET VARIABLE $variablename"

Gets the channel variable <variablename>.

Example: $AGI->get_variable('status');

Returns: The value of the variable, or undef if variable does not exist.


  • $AGI->verbose($message, $level)
Executes AGI Command "VERBOSE $message $level"

Logs $message with verboselevel $level.

Example: $AGI->verbose("System Crashed\n", 1);

Returns: Always returns 1.


  • $AGI->database_get($family, $key)
Executes AGI Command "DATABASE GET $family $key"

Example: $var = $AGI->database_get('test', 'status');

Returns: The value of the variable, or undef if variable does not exist.


  • $AGI->database_put($family, $key, $value)
Executes AGI Command "DATABASE PUT $family $key $value"

Set/modifes database entry <family>/<key> to <value>.

Example: $AGI->database_put('test', 'status', 'authorized');

Returns: 1 on success, 0 otherwise.


  • $AGI->database_del($family, $key)
Executes AGI Command "DATABASE DEL $family $key"

Removes database entry <family>/<key>.

Example: $AGI->database_del('test', 'status');

Returns: 1 on success, 0 otherwise.


  • $AGI->database_deltree($family, $key)
Executes AGI Command "DATABASE DELTREE $family $key"

Deletes a family or specific keytree within a family in the Asterisk database.

Example: $AGI->database_deltree('test', 'status');
Example: $AGI->database_deltree('test');

Returns: 1 on success, 0 otherwise.


Documentation on version 0.08
Created by oej, Last modification by Sébastien MONBRUN on Fri 15 of Dec, 2006 [04:10 UTC]

Comments Filter

Re: careful with agi->verbose, agi->get_variable

by popaneals on Friday 04 of January, 2008 [14:08:22 UTC]
You can use agi->verbose() prior to an agi->get_variable() if you do not include a newline character in the verbose statement before an agi->set_variable. For instance $agi->verbose("This is wrong\n");, would cause all of the following set_variables to fail

Re:

by Nabil Sayegh on Saturday 02 of September, 2006 [16:45:39 UTC]
Nguyen, you have to wait until STDIN tells you "200 result=0".

<pre>while(<STDIN>) {
 m/200 result=0/ && last;
}</pre>

Passing Additional Options to the Command Dial via Exec

by A.R Nasir Qureshi on Saturday 25 of March, 2006 [11:11:46 UTC]
To pass additional options like timeout, L(),W,T etc. to a Dial command via the Exec, use | (pipe) as seperator instead of , (comma) as used in extensions.conf.

e.g. $AGI->exec("Dial SIP/1234|100|L(200000,10000,1000)|HT")

by hungerbrother on Wednesday 08 of February, 2006 [20:03:37 UTC]
I've had the same problem as Nguyen running on SVN-branch-1.2-r7497. To get around the problem, I changed my

$this = $AGI->stream_file('this');
$that = $AGI->stream_file('that');

to instead use

$this = $AGI->exec('Playback','this');
$that = $AGI->exec('Playback','that');

and that works 100%.

So basically what I'm saying is: we have the same problem, I don't know how or why it's broken, and here's a kludge to get it to play each file properly.

by Nguyen Nguyen on Sunday 22 of January, 2006 [22:17:43 UTC]
I am new to AGI stuff so please bare with me. When I tried to play 2 sound files back to back, the first one seemed to skip. How can I make sure the first one is finished playing before I the second one plays? I can insert sleep, but that's sound file size dependent. Here is a snippet of my code:

$rc = $AGI->stream_file('welcome');  #will be skipped
$rc = $AGI->stream_file('thankyou');
sleep(8);

Many thanks - Nguyen

Re: callback

by scmason on Sunday 23 of January, 2005 [08:18:34 UTC]
Done!(:biggrin:)
Edit

careful with agi->verbose, agi->get_variable

by Anonymous on Tuesday 20 of July, 2004 [17:36:40 UTC]
I have spent hours looking through the mail archive to see that WHY $agi->get_variable always return undef???
As Nasim said in *-dev list, do not use $agi->verbose before $agi->get_variable.
You still can have debug log in a file, etc....

Edit

callback

by Anonymous on Monday 07 of June, 2004 [18:35:10 UTC]
please add documentation for (set?callback) please

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2008 VOIP-Info.org LLC

Powered by bitweaver