如何通过 asterisk 的 AMI API 执行拨号计划?

发布于 2024-12-05 18:24:41 字数 164 浏览 1 评论 0原文

找不到这个问题的具体答案。我是 asterisk 和 AMI 的新手。我需要使用星号自动生成调用并将参数传递给 AGI 程序。使用调用文件似乎会首先生成不需要的调用。那么,如何使用 asterisk AMI API (PHP) 通过向其中传递所有参数来执行包含 AGI 的拨号计划?因此,AGI 将接管并做出决定。

Couldn't find a specific answer for this. I'm a newbie to asterisk and AMI. I need to auto generate calls using asterisk and pass parameters to an AGI program. 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? So, the AGI will take over and make the call.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最舍不得你 2024-12-12 18:24:41

我认为在你的情况下,使用调用文件实际上会更简单。原因如下:

  1. AMI 要求您编写网络代码,这(如果您是初学者)构建简单的文本文件(调用文件)会更加棘手。
  2. 呼叫文件允许您将变量传递给 Asterisk,您可以在拨号计划代码中使用这些变量。
  3. 调用文件极其简单。

下面是使用调用文件执行此操作的简单方法的完整示例。我已尽力在相关评论中对其进行解释。

首先,我们假设您有一些使用变量的拨号计划代码,并调用 AGI 脚本(我假设您根据您的问题正在执行此操作)。这意味着您的 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()

下面是一个调用文件,该文件将:

  1. 需要在某个临时目录中创建(可能是 / tmp/)。

  2. 保存后,您可以将其移动到 /var/spool/asterisk/outgoing/ 来运行它(例如:mv /tmp/blah.call /var/spool /星号/传出/)。

  3. 呼叫文件将立即拨打电话号码 818-222-3333。

  4. 一旦 818-222-3333 的人员接听电话,Asterisk 将立即开始执行您的 [test_stuff] dialplan 代码,并且可以使用您的呼叫文件中设置的变量。

通话文件:

Channel: SIP/trunkname/18182223333
Context: test_stuff
Extension: s
Priority: 1
Set: somevar=hithere
Set: some_other_var=woot

希望有帮助!

I think in your case, using call files would actually be simpler. Here's why:

  1. The AMI requires you to write networked code, which (if you're a beginner) will be a lot more tricky the building simple text files (Call Files).
  2. Call Files allow you to pass variables to Asterisk that you can use in your dialplan code.
  3. Call Files are extremely simple.

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). That means you'll have code in your extensions.conf file that looks something like:

[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:

  1. Need to be created in some temporary directory (maybe /tmp/).

  2. Once it has been saved, you can run it by moving it to /var/spool/asterisk/outgoing/ (eg: mv /tmp/blah.call /var/spool/asterisk/outgoing/).

  3. The call file will the immediately dial outbound to the phone number 818-222-3333.

  4. 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.

Call file:

Channel: SIP/trunkname/18182223333
Context: test_stuff
Extension: s
Priority: 1
Set: somevar=hithere
Set: some_other_var=woot

Hope that helps!

一页 2024-12-12 18:24:41

您的问题可以借助本地通道来解决,例如

在调用文件中使用 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})

您可以将此方法与接口 AMI 或 .call 文件一起使用

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

[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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文