Asterisk call transfer to queue - asterisk

I have two sip extensions: 200 and 300 and a queue, let's call it my_queue.
Extension 200 is talking to extension 300 and decides to transfer extension 300 to my_queue.
So extension 200 puts extension 300 on hold and dials the queue number in the dialplan that eventually will call
...
same => n,answer()
same => n,queue(my_queue,,,,${TIMEOUT},,,)
...
Now, at this point extension 200 is listening to the queue's MOH and 300 is listening to the call in progress (as expected).
When 200 hangs up (and uses the IP phone transfer), the extension 300 is indeed transferred to the queue, and if any extension in the queue answers, it is correctly connected to the extension 300.
The problem is that while extension 300 is waiting for some extension in the queue to pick up it is completely silent. It does not hear a call progress nor the queue's MOH.
Is there a way to make extension 300 hear the queue's MOH while it is waiting in the queue?

Try transfer to announcement, which after end go to queue. And hangup before announcemnt ends.
Or add ivr breakout menu to queue(will be silence till IVR, after that moh).

Related

Asterisk ARI - Pass channel to Stasis before Ringing

My goal
Pass an incoming call directly to Stasis and allow the app to decide whether to play a ringing or busy tone to the caller.
The problem
With my ARI app, if I omit the same => n,Ringing line from my dialplan, the Stasis app returns an error if the caller hangs up. I can have a call hang without any early media, until I pass a channel.play() command, via the ARI.
This solution has 2 issues:
The Stasis app receives a second StasisStart when the caller hangs up, returning a Channel not found error.
There is no command for channel.busy
Does anyone have any suggestions?
My only option that I can currently see is to ensure that all users have voicemail and a busy tone is never played. Not everyone wants / likes voicemail and it is not ethical to answer the call and play a busy tone, without the caller knowing that their call is connected.
Update
Using the following dialplan, I can get this to work in the desired way (plays busy to a user if they're not available), but with an error:
extensions.conf
[public]
exten => _.,1,NoOp()
same => n,Stasis(myStasisApp, ${SIP_HEADER(to)})
same => n,Busy(10)
same => n,Hangup()
myApp.js
// The user is available
channel.ring();
// The user is busy
channel.continueInDialplan();
Error
Another StasisStart is sent when the caller hangs up, followed by:
Unhandled rejection Error: {
"message": "Channel not found"
}
We faced the same problem and lost precious time finding out the reason so I'm sharing the solution here and maybe it will help.
extensions.conf
[public]
exten => _.,1,NoOp()
same => n,Stasis(myStasisApp)
same => n,Hangup()
When Asterisk receive a call, it will start the stasis app.
Create a Bridge.
Add the incomming channel A in this bridge.
Create a new outgoing channel B from your ari app with POST /channels/create.
Add the outgoing channel B in that bridge.
Dial from channel B the destination, where both of the channels
are in the same bridge with POST /channels/{channelId}/dial
Now, you will be able to see a new ARI Dial events with Ringing and Answer.
For the Hangup, you will receive Channels end events with Hangup Cause Code not a text like 17 for busy
Asterisk Hangup Cause Mappings
It's simpler to originate a channel (Asterisk version 13) instead of create and dial (Asterisk version 14) but you will not have the early media or a full control on that channel because it's created by Asterisk and not the ARI app so this channel will start sending event back to ARI when the call start and not before.
Asterisk 14 ARI: Create, Bridge, Dial.
ARI and Channels: Manipulating Channel State
This thread helped us a lot:
Re: ARI: add channel to bridge immediatelly after originate action
.
.
.
Have fun ! and Hope this will help.
/ohammami

Create new channel in asterisk dialplan

This operation that I need to implement on Asterisk is similar to a call forwarding, but with some differences. This is a simplified explanation of the system.
There are three extensions: 100, 200 and 300. Calls between 100 and 200 are cheap, and calls from any extension to 300 are expensive. And extension 300 is programmed on the remote device to receive and accept calls only from extension 200.
Extension 200 program a "call forwarding" to extension 300 (it adds to a database).
When extension 100 calls extension 200, extension 200 should call extension 300 and transfer the call to extension 100.
The call forwarding examples I found suggest to use Dial() from the extension 100.
[context]
exten => s,1,Set(CFIM=${DB(CFIM/${ARG1})})
exten => s,n,GotoIf($["${CFIM}"!=""]?s-CFIM,1:s-NoCFIM,1)
exten => s,n,Hangup
exten => s-CFIM,1,Dial(Local/${CFIM},30,Ttr)
exten => s-CFIM,n,Hangup
exten => s-NoCFIM,1,Dial(${ARG1},30,Ttr)
exten => s-NoCFIM,n,Hangup
The problem with this approach is that the call to 300 is actually being made by extension 100 (the current channel). This will generate expensive billing for 100 and extension 300 will receive a call from 100, which it will drop.
What I need to do is create a new channel on behalf of extension 200, dial to 300 and then transfer that call to the current channel, so that extension 300 receives call from 200 and there are two billing generated: one from 100 to 200 and another from 200 to 300.
I tried using the Originate() app, but that doesn't work for me because it blocks until 200 picks up (which it will not do).
Any ideas on what I could do to solve this?
Use Local channels for that.
See freepbx.org system followme module for how realize followme with Local channel.
https://www.voip-info.org/wiki/view/Asterisk+local+channels

No ring back tone on outbound calls. [FreePBX]

I have a FreePBX 13 server set up with a SIP Trunk connection, however for some reason we are not getting the ring back tone for calls going out of the trunk connection.
I was able to implement a work around for this by placing the "Tr" options under "Asterisk Trunk Dial Options" to force Asterisk to produce the ring back tone for outbound calls.
However this only works while manually dialing from a soft-phone / VoIP Phone, when I try to launch a call via the Asterisk AMI "Originate" command we are not getting the ring back tone, even when the "r" option is set on the trunk. This is how the command I'm sending looks:
Action: Originate,
Channel: SIP/{extension},
Context: from-internal,
Exten: {phoneNumber},
Priority: 1,
Callerid: {callerId},
Timeout: 30000,
Async: yes
Any idea about what can I do to force the ring back tone?
This could be due to inband progress.
Try to add the following to your sip.conf
under [general] section,
prematuremedia=no
progressinband=yes
if you are using freepbx, then navigate to your trunk settings in the user interface and add the above 2 configs under the peer settings.
restart asterisk and try after that.
Launch Originate via Local/ channel call, if still not work, launch via custom context which answer first.
This is not an uncommon problem. Your ITSP is being lazy and either not providing or not forwarding RFC-complaince SIP 180/183 responses.
My usual solution is to put the local caller into an MOH state where the MOH is a ring tone, and then when the other end picks up, bridge the two calls.
This is kind of jarring, however, if the remote end is busy or is congested, since you go from "fake ring" to "real error tone". The other option is to reverse your dialing process ... call the remote end and then hook the local end, so that the local end doesn't need to hear ringing.
Of course, you can also reach out to your ITSP and tell them you need them to be RFC SIP 180/183 complaint.

Hangup After First Ring Using Asterisk Call Files

Default Asterisk configuration (only sip.conf changes).
I use call files for calling and I need to hangup after first ring while every dial.
WaitTime: 4 seconds doesn't work sometimes, since it's counting from the beginning (connect to SIP provider etc) and the client doesn't even receive the call.
00359894000001.call
Channel: SIP/flowroute/00359894000001
Extension: 00359894000001
WaitTime: 4
There are no way predict connection time and count how much ring was at called side. Ring create by endpoing equipment, you have no control/info about it.
If the connection time for the SIP provider etc is constant you should just check what it is and add it to your 4 seconds.

asterisk originate drops calls

I am using asterisk(1.6.2.13) to mass originate to specified numbers that are come from mysql database using perl and AMI.
if I send all calls (simultaneous) to asterisk, it will drop half of them after about 20 seconds. but if I sleep for 1 second between each originate it will process the call clearly. so this will reduce the capacity of origination.
Is there any way to get rid of this limitation?
Asterisk uses a single thread to process all SIP messages, and everything relating to SIP messaging happens in this thread (eg. realtime database access). This imposes an upper limit on the number of calls that can be processed per second. You can monitor the unprocessed SIP packets on the socket queue using something like "netstat -na |grep 5060". I've found it can up to 200 call setups per second, beyond that it will start losing and retransmitting packets and eventually dropping calls.

Resources