AGI on Queue Ringing an Agent in Asterisk? - asterisk

We can trigger an AGI if an agent attends a call in Queue.Is it possible to trigger an AGI when an agent rings in a Queue?

You can do agi on
1) before call other party - using AGI command
2) answer call before bridge - using M in dial command
No, not posible start agi on ringing event, but posible catch ringing event using AMI event listener and do action based on that.

Related

Asterisk - how to execute script on call received

How can I execute a script to open our CRM app on the specific client CALLERID in when the call is answered in asterisk (on the computer of the receiver of the call and not the server asterisk) ?
I can execute a script on the server, but can't do it on the client that reveives the call.
Thanks a lot.
You probably need asterisk events
https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+AMI+Events
Event can be AgentConnect if you use queues or Join/Bridge if you need it fire without queues.
You need write always-running daemon which will fire your scripts on event.

Asterisk AMI - How to simulate a DTMF sending action over AMI

I am building an application in Asterisk , which has to simulate the phone keypress action i.e DTMF. For instance , if a caller calls a number and the IVR requires to press a digit , the application (say a webpage) should also be able to simulate the same key press. I tried the following:
- I have a web application that triggers PlayDTMF action over AMI to simulate the key press on the caller channel. Unfortunately this didn't work , as it played the DTMF digit on the channel (the keypress could be heard) but asterisk didn't receive the DTMF. It was just playing the DTMF, which is what the AMI action was designed for. I technically need to "send" the DTMF digit on the channel.
- the sendDTMF function in asterisk couldn't be used either,as it is a dialplan function and I need a AMI action to trigger DTMF from an external source.
A similar issue was reported sometime back: Asterisk AMI: DTMF not received on SIP channel
I am using Asterisk 11. Is there a way to implement the above using AMI/AGI? Or do i need to further upgrade my Asterisk to 12 to make use of ARI?
Appreciate your inputs.
I managed to simulate the DTMF action , by Dialing/Originating out to a local context and using the outgoing bridging channel id for DTMF input. So the flow is :
call lands on Asterisk -> Asterisk Dials out to a Local context -> The dialout creates a bridging event which has the outgoing channel id(store in some DB) -> The local context can have the IVR flow and using the stored channel and PLayDTMF action - dtmf digits can be inserted. Not sure if there is a more elegant solution to this!

channel originate, how to do call from a local channel? (call intercom and send dtmf)

My goal is to :
run a background task activated by dynamic feature while in active call, that will execute dial to another EXT and send DTMF.
It means, when a user is active call with someone, when the user press 5555, the door will be opened.
In order to open the door today, I have to manually call EXT 6(the door) and send DTMF digits: 00*
All of this has to happen automatically when the user press 5555 without interfering the active call.
I tried before to do all of this with dial, but dial blocks the call or bridges with another extension and then I lose the original call.
I figured out that I need to do this with ASYNC, means I can not use dialplan, I need to use CLI, and then originate some how.
Asterisk will need to create a local session / local channel and establish/connect to the door extension, then send DTMF and hangup
All of this – in background.
this is somthing i managed to do so far:
features_applicationmap_custom.conf
openthedoor=> 5555,caller,macro,OpenIntercomCall
then in ->
extensions_custom.conf
[macro-OpenIntercomCall]
exten => s,1,System(asterisk -rx "channel originate SIP/6 extension#yoyo")
i do not understand how do i call to SIP/6 from asterisk(using a local or random channel), and then send DTMF on answer.
the door ext is SIP/6, and 00* is the dtmf to open it.
What i am trying to do is that when a user 5555 in a call, the door will be opened.
means i want asterisk to call the intercom and send dtmf
There are no any sence do exec asterisk from inside asterisk. You can do Originate command.
Originate(tech_data,type,arg1[,arg2[,arg3[,timeout]]])
For example you can do something like this
exten => s,1,Originate(SIP/6,app,SendDTMF,ww00*)
Should be enought for your need.

How Can we execute a Agi script after hangup

How Can we execute a Agi script after hangup ,Actually i am using queue with local channel, I m trying with "h,1,AGI()".but it is executing two times after hangup but i want to execute it one time after hangup of both channels
Correct way - NEVER execute scripts after hangups. Use mysql or other db cdrs, put all info you need into cdrs using custom fields
exten => s,n,Set(CDR(my_db_custom_field)=something)
After call end check cdrs and execute needed action by EXTERNAL threads.
Asterisk h extensions designed for fast non-blocking actions only.
It will be executed only once. If you have twice, very likly you have more then 1 channel (Local/ channels) in your dialplan.
You have add h-extension only into ONE place(in case of queue only in agent call or better use queue_log action for queue)

How to cancel call created with AMI originate

I am wondering if there is an easy way to hangup a channel created with Originate?
What I do is following:
Call in dialplan triggers Agi;
Agi starts AMI: Originate with Channel "SIP/201".
Now the extension rings. At answer I can bridge the channels. But, if the calling party leaves the call before the call is answered, I would like to stop the outgoing call. When I send AMI Hangup with Channel "SIP/201", It can't hangup originated call.
I can stop that call using 'hangup request channelname' using CLI
but how to hangup call using program.
please help me. how to hangup originated call
If calling party leave call,it will be auto-hanguped with CANCEL cause.
You also can use AMI action Hangup
http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+Hangup
BTW, very likly you just doing it wrong way.

Resources