Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

pbx - Asterisk AMI - pickup call

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()

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

Halp me, plox

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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

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

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.

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

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

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.

Hope it helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...