How to add SipAddHeader for all calls? - asterisk

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.

Related

Replacing dialplan with ARI for "dynamic" inbound extensions

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.

How to route call from VoiceBlue Next device to Asterisk Server

I want to setup and IVR Menu i mean if a user calls to a particular GSM Number then the number should be redirected to Asterisk Server and the user needs to Get IVR Menu
I am using VoiceBlue Next firmware version 1.31.1.34.1 inserted working SIM Card
If i make a call to that particular number i am able to accept call,reject call and other options from VoiceBlueNext Web Interface.
I have made a SIP account in pjsip.conf file and created and extension as 100 in extensions.conf but unable to transfer the call to Asterisk Server
In asterisk server are there any other files to be changed or any settings in VoiceBlue Next
There are not many details to understand your scenario, I have not used VoiceBlue but on Asterisk if you want to receive calls, from your VoiceBlue or any other provider. You have to do two things, one you have to register this peer to allow receive calls, or you can also set allowguest=yes(but very dangerous anyone can send you calls) or add peers at end of pjsip.conf file as little secure way.
Next, you need to add dialplan, suppose if you get any number _X will be any number, now you can put Dial your extension to receive any number from the provider.
As for sip client to call out you have to register peer and both must be in the same context.
Sending outgoing calls, now if you call any number beginning 6 and 7 they will be forwarded to VoiceBlue
exten=>_6XXXXXXXX,1,Dial(SIP/${EXTEN:0}#10.0.0.20,,r)
exten=>_7XXXXXXXX,1,Dial(SIP/${EXTEN:0}#10.0.0.20,,r)
for incoming please add following in your pjsip.conf
[VoiceBlueNext]
type=peer
host=10.0.0.20
username=voiceblue
secret=password
fromdomain=10.0.0.20
and in same file on top put following general section
[general]
port = 5060
bindaddr = 0.0.0.0
allowgues=no
context = sip
disallow=all
allow=ulaw
Notice I allowguest = no , so you must provide peer VoiceBlue peer information to receive calls, but if you want to test, make it yes and you will get calls without any security.

Unable to set callerID using ARI

I have a java stasis application on Asterisk 14 using ari4java. It mostly works great. I am now trying to receive an external call and relay it back out. I do following
Incoming call enters Stasis
Create bridge
Add first call(channel) to bridge
Create channel
Add second channel to bridge
Dial( secondChID, "Local/2601", 30)
No matter what I try, the second outbound call gets the callerID of the first inbound call. That is actually OK for many calls, but in this case I want to set another callerId.
Before Dial() I have tried to setChannelVar(CALLERID(num)) and this value I can see in all events coming from Asterisk. But once the SIP call is placed, no sign of my callerID.
I doubt it is the ari4java doing anything wrong as I see the callerID in all the "dial" events. I thought I could force a callerID in sip.conf, but unable to do that too.

Asterisk / Freepbx does not set CallerID to calling party when queue contains a cell phone

Does Asterisk / FreePBX support the ability to pass the caller ID of an inbound caller to a remote support agent (on a cell phone)?
Our work has a queue for incoming calls which contains "remote agents" (people on cell phones). To the cell phone agents, all calls appear to be coming from our main number (385-111-1111). We would like the calls to appear to be coming from the caller (201-555-5555).
This is not a problem with our SIP trunk provider. In the past we used different PBX software, with the same SIP trunk provider, and it was able to set the Caller ID properly. Extensions are capable of setting and passing arbitrary Caller ID, only calls from queues retain the main number.
Outgoing PEER Details:
host=sip.provider.com
type=friend
trustrpid=yes
sendrpid=yes
I've manipulated so many settings that I've come to wonder if Asterisk / FreePBX simply does not support this. Has anyone successfully been able to do this?
Asterisk certainly does. Capture the CID in a dialplan variable at the beginning of the call and set the outbound CID to the same value before passing it on.
There's no direct way to do this within the FreePBX GUI but there is a workaround:
Set up a virtual extension
Enable follow-me on the extension, add the mobile number to the follow-me list
Set the follow-me CID mode to default
Ensure the queue's agent restrictions allow the use of follow-me numbers
Have the agent log into the queue using the virtual extension instead of their mobile number
The default behaviour for the follow-me extension is to pass the incoming caller ID out. So, some flexibility is lost (mobile numbers have to be changed in follow-me settings) but it does allow the desired behaviour.
Asterisk supports setting the callerid for all outgoing or redirected calls. I did this with v1.8 and v13.7 as I'm facing the exact same requirements.
This feature depends on the provider and the contract they setup with you. My Provider calls it "Special Arrangement / Clip no screening". In my case they use "P-Asserted-Identity" to find callerid.
I had to set the following options in the outgoing sip trunk in sip.conf:
trustrpid=yes
sendrpid=pai

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