[asterisk-users] AGI - calling functions, CHANNEL STATUS broken?

Steve Edwards asterisk.org at sedwards.com
Wed Mar 12 11:53:18 CDT 2008


On Wed, 12 Mar 2008, Kevin DeGraaf wrote:

>> I am writing an AGI script that needs to check on the idle/busy status
>> of a number of SIP peers (mostly SPA9xx phones, with a few Polycoms and
>> Snoms thrown in for fun).
>
> I ended up grabbing this info from the manager interface, within an AGI
> script.  A little back-asswards, but it works.
>
> I still would like to know whether it's possible to call Asterisk
> functions from within AGI scripts...

The AGI executes as a separate process and does not have full access to 
the Asterisk memory or code. Since the only interface between Asterisk and 
the AGI is through STDIN and STDOUT (and STDERR), you can only execute 
functions defined in the AGI API. For 1.2 this means:

fs> show agi
               answer   Answer channel
       channel status   Returns status of the connected channel
         database del   Removes database key/value
     database deltree   Removes database keytree/value
         database get   Gets database value
         database put   Adds/updates database value
                 exec   Executes a given Application
             get data   Prompts for DTMF on a channel
    get full variable   Evaluates a channel expression
           get option   Stream file, prompt for DTMF, with timeout
         get variable   Gets a channel variable
               hangup   Hangup the current channel
                 noop   Does nothing
         receive char   Receives one character from channels supporting it
         receive text   Receives text from channels supporting it
          record file   Records to a given file
            say alpha   Says a given character string
           say digits   Says a given digit string
           say number   Says a given number
         say phonetic   Says a given character string with phonetics
             say date   Says a given date
             say time   Says a given time
         say datetime   Says a given time as specfied by the format given
           send image   Sends images to channels supporting it
            send text   Sends text to channels supporting it
       set autohangup   Autohangup channel in some time
         set callerid   Sets callerid for the current channel
          set context   Sets channel context
        set extension   Changes channel extension
            set music   Enable/Disable Music on hold generator
         set priority   Set channel dialplan priority
         set variable   Sets a channel variable
          stream file   Sends audio file on channel
  control stream file   Sends audio file on channel and allows the listner to control the stream
             tdd mode   Toggles TDD mode (for the deaf)
              verbose   Logs a message to the asterisk verbose log
       wait for digit   Waits for a digit to be pressed

For 1.4 or 1.6, use the obtuse replacement for "show agi" to see your 
options.

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