Asterisk - how to execute script on call received - asterisk

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.

Related

gRPC not dropping disconnected channel

Steps to reproduce
Start server
Send a client RPC to server
Restart server
Using the same client, send another RPC. The call will fail
Send another RPC, this call will success
Also I found that if the server is leave stopped for a long time before starting up again, the call in step 5 will return "channel is in state TRANSIENT_FAILURE" as well.
Example code: https://github.com/whs/grpc-repro
(Install from requirements.txt then run main.py)
Expected result
All call should success.
Tested with Python grpcio==1.19.0 server/client and with go-grpc server. I tried setting grpc.max_connection_age_grace_ms, grpc.max_connection_age_ms, grpc.max_connection_idle_ms, grpc.keepalive_time_ms, grpc.keepalive_permit_without_calls but they doesn't seems to help.
The question is duplicated with https://groups.google.com/forum/#!msg/grpc-io/199V_iF0NMw/NahHz_vMBwAJ.
The feature you want probably is "wait_for_ready". In case of TRANSIENT_FAILURE (server not available temporarily), it will automatically wait for the channel become READY again without failing. Read more about wait for ready.

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)

Asterisk HOLD functionality workaround

I'm using asterisk with webrtc in chrome (SIPml5 client) and also using their webrtc2sip gateway.
My problem is that I can't send the hook-flash/flash signal to asterisk for some reason.
Is there a possibility to trigger hook flash by sending DTMF signals ? (which apparently work for me )
Example: I want to trigger the standard hold functionality by sending the following DTMF sequence: #123.
On the other hand as a workaround, could I hold a channel using AMI or AGI ?
Basically I want the other party to hear OnHoldMusic while the channels/call remain active. On the local side I can just mute the audio tag which is fine.
Thanks.
Yes, you can do hold using ami command hold or AGI exec command musiconhold
That info is availible in AMI/AGI documentation
You can handle dtmf by using features.conf

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.

Where can I see executed "Originate" command from Asterisk AMI

I'm adjusting simple application that among other things should be able to call another party using Asterisk AMI Originate command.
I'm stuck and I believe that my originate command is wrong.
Where/how can I see log of Originate commands that Asterisk creates when I use regular phone so I can compare it to my hand crafted one?
Use a network sniffer, such as tcpdump or wireshark, and capture the packets that come and go to/from asterisk. By default, it uses 5038/tcp. Check your manager.conf file, and look for the bindaddr and port options to be sure you capture the right traffic.
If you are using ssl (sslenable=yes), then you will have to configure wireshark with your ssl keys, so it can decrypt the traffic or just use normal tcp (without ssl) for debugging and then switch to ssl.
You should see the Action: Originate coming in to asterisk, and the asterisk response and the associated events. Look for the ActionID parameter of the action so you can trace which responses and events correspond to each issued action.
Take into account that an async originate (async: true) will return a response as soon as the action is received by asterisk, but it will then send asynchronous events to inform the call status (once finished). On the other hand, when using async: false, the call will be placed and the response will have the status.
A few more resources on the originate action:
http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+Originate
https://wiki.asterisk.org/wiki/display/AST/ManagerAction_Originate
Another question related to the async parameter:
Asterisk originate response says successfully queued but nothing more
Hope it helps!
EDIT: Asterisk does not create the originate command, but will dial a target (a channel) based on an incoming originate action, or call file, so your application (the ami client) will issue an originate action and then asterisk will react to it by doing the call. If your call is originating from a phone, it's more probable that the call is being originated by a dial() command in your dialplan.

Resources