[英]How to execute a dialplan by asterisk's AMI API?
Couldn't find a specific answer for this. 找不到具体的答案。 I'm a newbie to asterisk and AMI.
我是星号和AMI的新手。 I need to auto generate calls using asterisk and pass parameters to an AGI program.
我需要使用星号自动生成调用并将参数传递给AGI程序。 Using a call file seems to generate the call first which is not wanted.
使用呼叫文件似乎首先会生成不需要的呼叫。 So, how do I use asterisk AMI API (PHP) to execute a dialplan with AGI in it, by passing all parameters to it?
因此,如何通过将所有参数传递给星号AMI API(PHP)来执行带有AGI的拨号计划? So, the AGI will take over and make the call.
因此,AGI将接管并进行呼叫。
I think in your case, using call files would actually be simpler. 我认为在您的情况下,使用调用文件实际上会更简单。 Here's why:
原因如下:
Below is a full example of a simple way to do it using call files. 以下是使用调用文件完成此操作的简单方法的完整示例。 I've tried my best to explain it in the associated comments.
我已尽力在相关评论中对此进行了解释。
Firstly, let's assume you have some dialplan code that uses variables, and calls an AGI script (which is what I assume you're doing based on your question). 首先,让我们假设您有一些使用变量的Dialplan代码,并调用AGI脚本(根据您的问题,我假设您正在这样做)。 That means you'll have code in your
extensions.conf
file that looks something like: 这意味着您将在
extensions.conf
文件中包含类似于以下内容的代码:
[test_stuff]
exten => s,1,NoOp(starting test!)
exten => s,n,NoOp(my variable's value is: ${somevar})
exten => s,n,NoOp(my other variable's value is: ${some_other_var})
exten => s,n,AGI(/path/to/my/script.sh,${somevar})
exten => s,n,NoOp(i just ran an AGI script and passed it a command line argument!)
exten => s,n,Hangup()
Below is a call file that will: 以下是一个呼叫文件,它将:
/tmp/
). /tmp/
)中创建。 /var/spool/asterisk/outgoing/
(eg: mv /tmp/blah.call /var/spool/asterisk/outgoing/
). /var/spool/asterisk/outgoing/
(例如, mv /tmp/blah.call /var/spool/asterisk/outgoing/
)来运行它。 Once the person at 818-222-3333 picks up the call, Asterisk will immediately start executing your [test_stuff] dialplan code, and will have the variables set in your call file available to it: 一旦818-222-3333处的人接听电话,Asterisk将立即开始执行您的[test_stuff]拨号计划代码,并将在您的呼叫文件中设置的变量可用:
Channel: SIP/trunkname/18182223333 频道:SIP / trunkname / 18182223333
Context: test_stuff 上下文:test_stuff
Extension: s 扩展名:s
Priority: 1 优先级:1
Set: somevar=hithere 设置:somevar = hithere
Set: some_other_var=woot 设置:some_other_var = woot
Hope that helps! 希望有帮助!
Your problem can be solved with the help of local channel for example 您的问题可以通过本地渠道解决,例如
In call file use Local/1812222222@test_stuff
as channels while using following dialplan 在呼叫文件中,使用以下拨号
Local/1812222222@test_stuff
,请使用Local/1812222222@test_stuff
作为渠道
[test_stuff]
exten => _X.,1,NoOp(starting test!)
exten => _X.,n,Set(phone=${EXTEN})
exten => _X.,n,AGI(/path/to/my/billing,${phone},${other_variables_account_etc..})
exten => _X.,n,Dial(SIP/trunkName/${phone})
You can use this method with both interfaces AMI or .call file 您可以对两个接口AMI或.call文件使用此方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.