Im trying to figure out a clever way to delay the 200 ok for the sip handshake till after the "please enter your calling card code" that my voip system will be transmitting to the incoming call..
Any thoughts on this.. I must admit, I';m looking at this conceptually at this point and am a bit naive...
Thanks in advance!
You won't be able to at least if you're planning on supporting standard SIP devices.
You can send early media to a device, such as your "please enter.." audio, with a 183 Session Progress Response but I can't see that being much use as the SIP calling device won't send any DTMF tones to the server until the call has been answered which requires the 200 Ok response.
Despite that I suspect you may be looking at the wrong thing. The 200 Ok from Asterisk is for the call between the caller and the Asterisk server to get the DTMF tones and determine whether the next call leg is authorised. Only after the calling card code is accepted does the next call leg start. It sounds like your problem is that users are noticing that the billable call time includes the time they spend entering their calling card PIN. Fiddling with the 200 Ok response is not the way to fix that. Trying to get Asterisk to generate a new CDR for the second call leg would be a better approach.
For called party:
[main_content]
exten => _X.,1,Dial(SIP/${NUM}#provider,,M(dialout-macro))
[macro-dialout-macro]
exten => s,1,Noop(here you should add detect of "please enter")
exten => s,n,Noop(some other commands go)
exten => s,n,MacroExit;we are ready to connect call.
For calling party - you need ALL your provider support early media and dtmf before answer. It is posible get provider which support early media, yes. But i not know any system which support dtmf before answer,sorry.
Dialplan will be like this
exten => _x.,1,Read(variable,filename,10,n,3)
note: no answer should be BEFORE that command, should be used option n
n: to read digits even if the line is not up.
However as i say that will work only in theory.
Related
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
I made an outbound-call service application using Asterisk AMI interface.
Following is how my application works.
I generate an Originate request to internal channel using TCP/IP socket.
my dialplan accepts the request and run dial command. extension.conf file is
[from-internal]
exten => _X.,1,NoOP()
same => n,MixMonitor(${DialMonitorFile}.wav)
same => n,Dial(PJSIP/${EXTEN}#TRUNK_100-1234-5678,30)
What I want to do is record whole call process (from ringback tone sound until user hangup).
But, when dial started, only 44 byte size file is generated (maybe wav file header?) before user accepts the call. And, file increased after user accepts call.
Can someone help me how can I record ringback tone sound as well ?
Regards,
Brian
You should do Answer before MixMonitor if you want that
Please note, CDRs will be affected
I'm using a cloud-based Asterisk server as my PBX. At my current location, the Internet is rather shaky, but cell phones are reliable and commonplace. However, international cell calls are expensive, VOIP calls are much cheaper.
So, I came up with a script in Asterisk which dials my local cell phone:
exten => _abcd.,1,NoOp(-- Making outbound call to number ${EXTEN:4} --)
same => n,Answer()
same => n,Wait(1)
same => n,Originate(SIP/+86[my_cell_no]#[voip_provider],exten,incoming_remote,##${EXTEN:4})
same => n,Hangup()
Let's say I want to call a UK mobile number, +4477something. I would use my softphone to dial abcd+4477something. The script above runs, makes a call into my local cell phone. As soon as I answer, it jumps into another extension _##. which dials the outbound number, and connects the two together.
It works perfectly. However, whilst I'm waiting for the local cell to connect, I've got silence on the line. I'd quite like to play music... but I can't use the MusicOnHold() application, because it just sits there & does nothing until I hang up!
I can't add any "DIAL" style commands (i.e. "m") to the Originate command because it doesn't support them.
Is there any known way of playing (one of) the MusicOnHold channels asynchronously whilst the rest of my dialplan gets on with it?
Would the AGI command SET MUSIC do what I wanted?
e.g.
exten => _abcd.,1,NoOp(-- Making outbound call to number ${EXTEN:4} --)
same => n,AGI(turn_music_on.sh)
same => n,Answer()
.....etc.
I'm using Asterisk 1.8, if a newer version fixes/changes the MusicOnHold behaviour, then that will be the accepted answer (but the documentation seems to suggest it's the same).
You can call to Local channel(dialplan). After that in dialplan you can use m of dial command.
https://www.voip-info.org/wiki/view/Asterisk+local+channels
same => n,Originate(Local/[my_cell_no]#out/n,exten,incoming_remote,##${EXTEN:4})
[out]
exten => _X.,1,Dial(SIP/+86${EXTEN}#[voip_provider],,m)
I am a real beginner in asterisk, so please tolerate my question :)
I tried to configure asterisk for realtime and it is working fine for local sip calls. Now, I am trying to make the following test with dahdi calls:
I connected an analog phone to an FXS channel of my Digium card and tried to call this phone (exten 124) from a sip softphone (X-lite).
I get the following error:
-- Executing [124#from-sip:1] Dial("SIP/2000-00000004", "SIP/124")
[May 31 10:24:22] WARNING[5457]: chan_sip.c:5667 create_addr: Purely numeric hostname (124), and not a peer--rejecting
my extensions.conf:
[from-sip]
switch =>Realtime
[from-pstn]
exten => 124,1,Dial(DAHDI/3)
It seems that the dial is done using from-sip context not from-pstn context as required.
Anyone to advise or correct my understanding?
Thanks million
Zak
In Asterisk realtime and not realtime you can configure where to send calls from particular extension, this should be configured in "context"(for realtime check context column), so I believe in your case it is "from-sip". This means all calls from that extension will hit this context, you can't send one call from same extension to one context and other to another, all calls will hit "from-sip" context.
i want to connect to 5 numbers at a time to put them in conference call.
i was trying with this dialplan
exten => 123,1,Dial(Dahdi/g0/no_1&Dahdi/g0/no_2&Dahdi/g0/no_3)
with this code who ever answer the call first it will be connected and remaining will get disconnect.
regards
Vikas
That dialplan have be working if you group0 setuped correctly and have enough free channels
You also can use dial Local/123#context/n - call via dialplan