FW: [asterisk-users] Get dialed numbers in AGI

Yuan LIU yliu11 at hotmail.com
Fri Jan 12 12:22:50 MST 2007


>From: "Ralph Liebessohn" <ralphliebessohn at gmail.com>
>
>On 1/11/07, Mike D'Ambrogia <miked at jamagination.com> wrote:
>>
>>  Ralph
>>
>>Kind of new to asterisk, and really new to AGI but it looks like you were
>>trying to have the AGI script tell asterisk to read and lay the results 
>>into
>>my_var and then regain control in the AGI script, is that correct?
>>
>>If so I don't think that will work since the dialplan variables are only
>>exposed/visible when you start the AGI script, since you are still within
>>the AGI script you'll probably never see my_var if called this way
>>
>>md
>>
>
>Mike,
>
>that's my first agi. Easy to see, ahm?
>What I'm thinking to do is, play a sound, get the numbers dialed, see on a
>db what to do using the dialed numbers, get back to dialplan (go to a queue
>or something else).
>The way started to work is that you said, send dialed as parameter to agi
>and get it with $argv[1]. And I was trying to get it from stdin.
>Things I do not understand well and the documentations I've read are not so
>clear are the way agi work with some things like:
>- How can I fix this agi to work?

Ralph,

Is there a special reason you need to Read() from inside AGI?  If not, the 
following should work:

--- snippet from extensions.conf
exten => s,1,Read(my_var|sound-file|5|||15)
exten => s,2,AGI(MyAGI,${my_var})
--- snippet ends

--- snippet from MyAGI
$conn=odbc_connect('MSSQL', 'USER', 'PASS');
$query = odbc_exec($conn, "INSERT INTO dialed(number) VALUES('$argv[1]')");
fwrite(STDOUT,"exec saydigits $argv[1] \n");
--- snippet ends

Yuan Liu

>AGI Rx << exec read my_var|sound-file|5|||15
>    -- AGI Script Executing Application: (read) Options:
>(my_var|sound-file|5|||15)
>    -- Accepting a maximum of 5 digits.
>    -- Playing 'sound-file' (language 'en')
>    -- User entered '85214'
>AGI Tx >> 200 result=0
>AGI Rx << get variable my_var
>AGI Tx >> 200 result=1 (85214)
>AGI Rx << exec saydigits Resource id #1   // (this is the result of my_var)
>
>All the variables here was my_var, it worked for GET VARIABLE but didn't 
>for
>SAYDIGITS and odbc connection. How can I SAYDIGITS of my_var or insert
>my_var value into a db?
>
>- What I need more to use WAIT FOR DIGIT? Because it didn't stop to wait 
>for
>digits.
>- STDIN shoudn't get the result of READ or GET VARIABLE? Where these values
>go?
>
>--
>Ralph Liebessohn
>ICQ: 74835911
>Skype: liebessohn




More information about the asterisk-users mailing list