I want to be able to pass the extension entered by a caller to the agi script and after it is manupulate I would like the agi script to send the result back to the dial plan as a variable. Can anyone give me an example of how to achive this in any dialplan language
1 Answers
2
votes
If you are using Asterisk dialplan (extensions.conf) to enter AGI, then getting the extension is possible using the ${EXTEN} channel variable. To return information to the dialplan you can set any channel variable, though take some care to avoid channel variables that are used by Asterisk itself.
Here's a quick example using Adhearsion:
In Asterisk extensions.conf:
exten => s,1,Background(enter-your-extension-now)
exten => _X.,1,AGI(agi://localhost/stuff)
exten => _X.,n,NoOp(Returned new extension: ${NewExten})
In Adhearsion's dialplan.rb:
stuff {
exten = get_variable('EXTEN')
# Do stuff to figure out what the new extension should be
newexten = '12345'
set_variable('NewExten', newexten)
}
The above code will set the ${NewExten} channel variable to "12345" and write it to the Asterisk console.