Asterisk Originate a muted call - asterisk

i have a script that start a call from some channels in my asterisk
this scripts runs the folowing commands:
channel originate SIP/11 extension 800#from-internal
channel originate SIP/12 extension 800#from-internal
channel originate SIP/13 extension 800#from-internal
channel originate SIP/14 extension 800#from-internal
after that i ned to mute each channel using python amy integration like it:
action = SimpleAction(
'MuteAudio',
Channel='SIP/11-00001',
Exten='11',
Direction='in',
State='on'
)
but it gives me to mutch errors, if a channel dont start a call this command never runs.
id like to know if tehre is any commando that can originate a call muted. and after that i can choos what channel will be unmuted based on my system status.

You can mute audio in from-internal context as first priority.
You can originate via Local/ channel to do any Dial command params or any apps before call.

Related

Finding uniqueid of call channel

I use Asterisk 16.5 and sip trunk.
If known sip channel can i find uniqueid of call?
Note: I want do it with Asterisk AMI actions and events.
Action: Command
Command: core show channels concise
give you a list of :
Channel:Context:Exten:Priority:Stats:Application:Data:CallerID:Accountcode:Amaflags:Duration:Bridged
You have to pick the correct channel with the "Channel" field and make a
Action: Command
Command: core show channel YOUR_CHANNEL
If you expect do events, correct way is use event. I.e collect NewChannel events and build map(for example, in memcached).
https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerEvent_Newchannel
Running too many commands sometimes result problem with ami connection.
As an example of such code you can check FOP opensource or FOP2 project(no source now). https://www.fop2.com/about.php

How to handle Asterisk SendText cmd in Ozeki

We're trying to get custom data sent back from Asterisk to our Ozeki softphone (a TaskId).
So far I've found that Asterisk can send text messages via SIP using the asterisk-cmd-sendtext. I've debugged in Asterisk and have confirmed that the command is being executed.
In Ozeki, I first tried using the InstantMessaging.MessageReceived event listener, but it never got triggered.
Then I tried implementing SetSIPMessageManipulator(ISIPMessageManipulator manipulator) (documentation). That too, however, was never called.
How do I consume the message sent from Asterisk?
Turns out the SetSIPMessageManipulator(ISIPMessageManipulator manipulator) should be added after the phone is registered, but before the event listeners (like the statechanged event) is wired up.

Keep calling channel after called channel hangs up in Asterisk

I want to execute an AGI script for calling party after called party hangs up. For example, for doing a survey for customers I am going to run an AGI script after agent hangs up.
Unfortunately, when AGI scripts runs the agi debug output says:
"511: The command cannot be executed on a dead channel"
I use commands like "ANSWER" or "STREAM FILE" in my agi script which need a channel to run on.
I know that calling channel hangs up as soon as called party hangs up.
I tried DeadAGI instead of AGI and also "g" option in dial command but none of them works.
So, I think I have to search for a solution that keep the calling channel up so that I can run my script on that.
Any suggestion please?
You should not use "g" param for this case, because it is CALLER hangup. You should use "F"
F([[context^]exten^]priority): When the caller hangs up, transfer
the *called* party to the specified destination and *start* execution
at that location.
NOTE: Any channel variables you want the called channel to inherit
from the caller channel must be prefixed with one or two underbars ('_').
F: When the caller hangs up, transfer the *called* party to the next
priority of the current extension and *start* execution at that location.
NOTE: Any channel variables you want the called channel to inherit
from the caller channel must be prefixed with one or two underbars ('_').
NOTE: Using this option from a Macro() or GoSub() might not make
sense as there would be no return points.
g: Proceed with dialplan execution at the next priority in the current
extension if the destination channel hangs up.
Finally I found the answer. The problem is that we don't have to execute agi script in h extension otherwise we get an error for some functions like answer or streamfile in agi. we have to redirect the call to some extension before h extension and for that in elastix I had to change extensions.conf.

Asterisk connect to a parked call

I am developing a custom application to control an Asterisk based pbx using ami/agi interface. What I have to do is:
receive a call from a pstn external line
answer the call
play a welcome message
transfer the call to a specific extension
park the call
reconnect to the call from a different extension
Everything should be done using ami/agi interfaces. I succesfully developed everything up to point 5) but I am unable to understand how to transfer (using ami/agi) the parked call to a runtime-defined extension.
Can someone give me an idea on how to do it ?
you should originate from Local/XXX#parked_context to the extension you want.
something like this..
Action: Originate Channel: Local/XXX#parked_context (XXX is the number of parked call)
Context: default (here you put the context where you can reach the second party)
Exten: 123 (number who will receive the call)
Priority: 1
Callerid: 3125551212
Timeout: 30000
Variable:
ActionID:
Simplest way is just use async agi or conference or Wait extension instead of parking, i.e redo parking-like logic yourself.
That way you will 100% know channel name and how to transfer it back.
Considering you are gooing use ami - AsyncAGI is best option for you.

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\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()
I need something similar, but for answering calls.
Can't find any useful command in *CLI> manager show command
Halp me, plox
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!

Resources