Replacing dialplan with ARI for "dynamic" inbound extensions - asterisk

I'm experimenting with the ARI interface in Asterisk (v15.5). I've managed to placing and manage outbound calls relatively well, and I'm now trying to tackle inbound calls.
I don't have any dialplan to speak of on my test server; it hasn't been needed: I just connect via ARI, Originate channels, and bridge them together. However, trying to send an inbound call to the server gives me an error
chan_sip.c:26513 handle_request_invite: Call from 'upstreamserver' (192.168.x.x:5060) to extension '12345' rejected because extension not found in context 'default'.
Fair enough - Asterisk doesn't know about extension 12345 or what to do with it. I could, of course, add this into extensions.conf, put the extension into stasis and let my application deal with this: however, this has two downsides:
We have potentially hundreds of inbound numbers, and we'd need to keep the dialplan up to date
We'd like to have multiple ARI applications connecting to the server: it seems we need to specify a specific application name for each extension
Ideally, I'd like to use ARI to programatically tell Asterisk: hey Asterisk, I'm an ARI application, let me know if there's any calls for extension 12345, and I'll take care of those for you. Is there currently a way to do this, or is it back to editing the dialplan and pointing it to my app by hand?

If you want control all via ARI you should do something like this
[default]
exten => _.,1,Noop(need ban this <${CHANNEL(recvip)}>);use fail2ban
exten => h,1,Hangup
[from-trunk]
exten => _.,1,Stasis()
exten => h,1,Hangup
You should not use default context in your peers/extensions
You also can use dynamic realtime and fastagi for control dialplan.

Related

How to add SipAddHeader for all calls?

There is telephony based on FreePBX Distro.
The task, for all calls (internal, outgoing, incoming) in the SIP Header to add the UNIQUEID value, for further analysis of calls in CRM.
In extensions_custom.conf I add:
exten => _., 1, SIPaddheader (Unique-ID: $ {UNIQUEID})
And when receiving an incoming call from another extension, we see that the necessary information has been received:
1
No matter how SIPaddheader did in this file, it is not possible to add UNIQUEID to the header of outgoing calls, and incoming from outside.
SIPAddHeader do adding headers only for next ONE outbound and only to first invite.
For incoming calls use channels variables.
Please note, that some applications like ringgroup and queues may create much more then one channel, so you need use inheritance(add two underscore before variable name). Check asterisk doc for more info.
There are no sinlge place for make it perfect, you should understand freepbx internals.

Asterisk ringback tone recording

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

Testing Asterisk SIP and DAHDI local calls

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.

How to use repro to modify sip request?

I am using the repro sip proxy to modify SIP requests.
I need to change my SIP request header from 7001 to 7001_abc.
How could I do this using repro sip proxy with asterisk?
I would suspect that you want to change to person you are dialing to from "7001" to "7001_abc", prior to the call entering the Asterisk dialplan?
If that is the case, you don't really need "repro" in order to do this. You can simply to the following in your Asterisk server:
file: sip.conf
[myprovider]
type=peer
host=bla.bla.bla
context=from_provider
.
.
Now, in dialplan you can do the following:
file: extensions.conf
[from_provider]
exten => _X.,1,Noop(*** Retargetting ***)
same => n,Dial(Local/${EXTEN}_abc#my_dialplan)
same => n,Hangup
[my_dialplan]
exten => _XXXX_abc,1,Noop(*** Start my thing ***)
Just as a closed caption, it's more common to use a prefix, not a suffix. In addition, I would use Kamailio and not Repro, as the information and scalability of it is much better.
Currently I am doing 7001 to create unique user id, where user has to provision its deskphone/softphone.
Now I want user to provision 7001#companyname.com our proxy will change it to 7001_companyname or 4535342#pbx.sip.com (any random unique number)

Error: "Channel not in Stasis application" when adding channel to a bridge

I'm working with Asterisk ARI. When I create channels via ARI, I specify application name and I can add those channels to a bridge with no problem. But when I use other client (like Zoiper) to make calls, and try to add those channels to a bridge, I get an error "Channel not in Stasis application". I am not sure what is Stasis, I followed this article and put the following in extensions conf file, but it still doesn't work:
same => n,Stasis(myApp)
same => n,Hangup()
So, what is a stasis app and how can I be able to bridge channels which are created outside of ARI?
You can't bridge already bridged calls
You can bridge by AMI calls which are set to MOH or AsyncAGI applications.
You can't perform operations on channels that are not in a Stasis application. This is a safety mechanism: a Stasis application hands complete control of the channel over to your external application to control. Channels in dialplan are not in that state, and many operations on a channel that are possible through ARI would cause problems (read: crash) if they were performed on a channel in dialplan.
You'll need to place the channel into the Stasis dialplan application to control it using the /channels resource.

Resources