星号AMI-代答电话 [英] Asterisk AMI - pickup call
问题描述
我想使用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\r\n')
sock.send('Events: off\r\n')
sock.send('Username: '+str(ast_server.login)+'\r\n')
sock.send('Secret: '+str(ast_server.password)+'\r\n\r\n')
#originate call
sock.send('Action: originate\r\n')
sock.send('Channel: ' + str(user.asterisk_chan_type) + '/' + str(user.internal_number)+'\r\n')
sock.send('Timeout: '+str(ast_server.wait_time*1000)+'\r\n')
sock.send('CallerId: '+str(user.callerid)+'\r\n')
sock.send('Exten: '+str(ast_number)+'\r\n')
sock.send('Context: '+str(ast_server.context)+'\r\n')
if ast_server.alert_info and user.asterisk_chan_type == 'SIP':
sock.send('Variable: SIPAddHeader=Alert-Info: '+str(ast_server.alert_info)+'\r\n')
sock.send('Priority: '+str(ast_server.extension_priority)+'\r\n\r\n')
#logout
sock.send('Action: Logoff\r\n\r\n')
time.sleep(1)
sock.close()
我需要类似的东西,但要接听电话. 在* CLI>管理器show命令中找不到任何有用的命令
I need something similar, but for answering calls. Can't find any useful command in *CLI> manager show command
让我高兴,普罗克斯
推荐答案
您无法直接通过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.
希望有帮助!
这篇关于星号AMI-代答电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!