is it possible to pass variables / arguments and use them in dialplan? I am calling an extension with originate call using asterisk-php-api (http://code.google.com/p/asterisk-php-api/) like this
I would expect to have those variables available in my dialplan:
[outgoing]
exten => 1000,1,Background(/data/sounds/beep)
same => n,Background(/data/sounds/${FOO})
same => n,Background(/data/sounds/${BAR})
same => n,Hangup()
Using call files you usually use the SET keyword and then the variables are availables in the dialplan. Check if the way you are generating the call support it, if not you may change the way you send the call.
[quote]set_variable
AGI::set_variable() in phpagi.php
Sets a variable to the specified value. The variables so created can later be used by later using ${} in the dialplan. phpagi.sourceforge.net/phpagi22/api-docs/
[/quote]
He’s doing an originate, and the handling of variables for that is likely to be complicated. I assume that this third party PHP library calls the originate application. That application doesn’t pass the incoming channel to the Asterisk core when creating the new channel, so I don’t think any variables can propagate, even if you made them inheritable.
Thank you, I managed to install phpagi. So now I am, able to run php scripts inside my dialplan and pass variables from dialplan to scripts. That’s fine.
But still, I need to first trigger a call (using origionate at the moment) from my web application and at that moment also pass information (variables) to dialplan so it can be passed to agiscripts. Obviously I am missing something here…
My use case: I need to make automated phone call when user makes action in php app, to external number and when picked up, a message containing information (numbers) would be read to user.
you can not use $agi->set_variable because you want to originate a new call and the variable will unset . I have the same experience for such an application . You should save the variable in database ( I used MYSQL ) you can not use uniqueid to save variable as well because it will change after you originate . I used callerid and a flag field in database to save my variables and can fetch them .