Asterisk AMI - 代答呼叫 [英] Asterisk AMI - pickup call

查看:38
本文介绍了Asterisk AMI - 代答呼叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 AMI 在 Asterisk 中接听电话.我可以发起呼叫,但完全不知道,如何接听电话...调用脚本:

I want to pickup call in Asterisk using AMI. I can originate call, but totally don't know, how to answer the phone... Script for calling:

#login
sock = socket.socket(af, socktype, proto)
sock.connect(sockaddr)
sock.send('Action: login
')
sock.send('Events: off
')
sock.send('Username: '+str(ast_server.login)+'
')
sock.send('Secret: '+str(ast_server.password)+'

')

#originate call
sock.send('Action: originate
')
sock.send('Channel: ' + str(user.asterisk_chan_type) + '/' + str(user.internal_number)+'
')
sock.send('Timeout: '+str(ast_server.wait_time*1000)+'
')
sock.send('CallerId: '+str(user.callerid)+'
')
sock.send('Exten: '+str(ast_number)+'
')
sock.send('Context: '+str(ast_server.context)+'
')
if ast_server.alert_info and user.asterisk_chan_type == 'SIP':
    sock.send('Variable: SIPAddHeader=Alert-Info: '+str(ast_server.alert_info)+'
')
sock.send('Priority: '+str(ast_server.extension_priority)+'

')

#logout
sock.send('Action: Logoff

')
time.sleep(1)
sock.close()

我需要类似的东西,但用于接听电话.在 *CLI> manager show command

I need something similar, but for answering calls. Can't find any useful command in *CLI> manager show command

帮帮我,plox

推荐答案

您无法直接通过 AMI 接听电话.这是因为新呼叫将到达"在拨号计划中配置的给定上下文/优先级/分机(或者如果找不到适用的将被拒绝).因此,无论该呼叫发生什么,都将从拨号计划中的给定上下文/优先级/分机号开始.

You can't answer a call directly via AMI. This is because a new call will "arrive" at the given context/priority/extension configured in the dialplan (or it will be rejected if cant find one that applies). So whatever happens with that call will start at the given context/priority/extension in the dialplan.

如果您想通过 AMI 处理调用,请尝试使用异步 AGI,如下所示:

If you want to handle calls via AMI, try using asynchronous AGI, like this:

exten => _X.,1,AGI(agi:async)

这将通过发出一个您可以用您的 AMI 客户端处理的事件 (AsyncAGI) 来处理对任何至少有 1 位数字的分机的所有呼叫.

This will handle all calls to any extension that has at least 1 digit, by issuing an event (AsyncAGI) that you can handle with your AMI client.

然后,从您的 AMI 客户端,您可以发送 AGIAction,例如:

Then, from your AMI client, you can send AGIAction's, like:

Action: AGI
Channel: SIP/adevice
Command: ANSWER
CommandID: MyCommandID

这将有效地允许您从 AMI 客户端运行 AGI 命令(并像通常在任何 AGI 脚本中一样处理调用).

This will effectively allow you to run AGI commands (and handle a call like you would normally do in any AGI script) from your AMI client.

希望能帮到你!

这篇关于Asterisk AMI - 代答呼叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆