How to use repro to modify sip request? - asterisk

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)

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.

Get return value of the Dial application in Asterisk

I call to a voice browser with the Dial application on SIP channel in Asterisk. The VXI returns a number. How can I get that number as a return value of the Dial application? ${DIALSTATUS} doesn't get the return value. It has last result of Dial application like ANSWER,NOANSWER,... .
exten => _.,n,Set(VXMLFILE=/var/spool/asterisk/tmp/${EXTEN}.vxml)
exten => _.,n,SipAddHeader(voicexml: ${VXMLFILE})
exten => _.,n,Dial(sip/[some parameters])
Voicexml processing is not part of asterisk, it done by your UA.
So you have consult our UA for result.
Can suggest it allow save log on remote syslog server, so you can parse result from log.
Asterisk cannot directly parse the vxml or xml files.
Create an Asterisk AGI script and parse the vxml file and assign the value to the variable "VXMLFILE".
Go through this URL to understand how Asterisk AGI works.
voip-info.org

Asterisk : Display Caller ID of original caller when an IAX Trunk is set

Friendly greetings, everyone !
I set up two Asterisk boxes : one with 2000 to 2999 extensions, the other with 5000 to 5999 extensions. On both, I have SIP users : 2005 and 2025 on one, 5002 and 5025 on the other.
I set up an IAX trunk between the two, using Asterisk-GUI : on my trunks, the user's extensions are 2999 and 5999. The trunks are registered, everything is OK on this matter.
Let's say user SIP 2005 (on one side) wants to call user SIP 5002 (on the other side). I make the call, the call is normally relayed (I can join the other side) but, on 5002's phone, the displayed Caller ID is "2999" (trunk ID), which is bothersome.
Is there a way to keep the original Caller ID (so, in my example, 2005) and display it on 5002's phone ?
I consulted Asterisk's doc and voip-info.org, but I haven't found my answer as of yet.
That mean you trunk have callerid= or fromuser= in definition. If you remove it, will be original callerid.
Also please note, you should use dial command with "o" flag when calling trunk.
o([x]): If <x> is not provided, specify that the CallerID that was
present on the *calling* channel be stored as the CallerID on the *called*
channel. This was the behavior of Asterisk 1.0 and earlier. If <x> is
provided, specify the CallerID stored on the *called* channel. Note that
o(${CALLERID(all)}) is similar to option o without the parameter.
Not sure which version of Asterisk your using but you need to set the caller id in the dial plan. That way you can send whatever you like rather than being fixed to sending 1 caller ID for any call on that trunk.
In extensions.conf you should have something like this (taken from my conf)
[to_hq]
exten => _7900.,1,Set(CALLERID(num)=7000${CALLERID(num)})
exten => _7900.,2,Dial(IAX2/to_hq/${EXTEN:4})
In my config I dial 7900 to access the iax trunk then the remote ext I'm trying to reach. The caller id sends and displays on the remote phone as 7000xxxx where xxxx=the local ext I'm calling from.
7000 in my config is my local trunk code so that when I call a remote user they can call me back without having to dial the routing code.
The other side of the config on the remote node would look like this;
[to_me]
exten => _7000.,1,Set(CALLERID(num)=7900${CALLERID(num)})
exten => _7000.,2,Dial(IAX2/to_me/${EXTEN:4})

Vicidial SIP Trunk with Twilio

I need a step by step guide on configuring Twilio Elastic SIP Trunk on my Vicidial Server. I've been working it out for days now. Still can't make an outbound call. My account on twilio is still a trial account. thank you guys. :(
From vicidial admin panel, go to Admin >> Carriers
Add a new carrier named "myname"
**Replace "myname" with whatever you like but keep it consistent throughout the config. Anywhere you see "myname" replace it with the same value.
In the account entry section use this template:
Account Entry:
[myname]
type=peer
secret=mypassword ;if you created a Credentials list in Twilio the password goes here
username=myuser ;the Credentials username goes here
host=mytrunkname.pstn.twilio.com ;in Twilio this is your Termination SIP URI that you created under Elastic SIP Trunk settings
dtmfmode=rfc2833
canreinvite=no
disallow=all
allow=ulaw
insecure=port,invite
fromuser=+18005551234 ;the phone number associated with your trunk goes here
fromdomain=mytrunkname.pstn.twilio.com
Global String: DIAL9TRUNK = SIP/myname
Dialplan Entry:
exten => _91NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _91NXXNXXXXXX,n,Dial(${DIAL9TRUNK}/+1${EXTEN:2},,To)
exten => _91NXXNXXXXXX,n,Hangup
exten => _9NXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9NXXNXXXXXX,n,Dial(${DIAL9TRUNK}/+1${EXTEN:1},,tTo)
exten => _9NXXNXXXXXX,n,Hangup
That should activate outbound calling prefixed with the number 9. Meaning, dial 9 and then the number you want to dial as usual. You might want to remove all of my comments in the settings just to be safe. If you need any more help post back with your current config and I'll try to respond quickly.
Cheers!
The above answer is several years old, and I get emails asking how to add Twilio to Vicidial quite frequently. The problem is almost always with how you configure your Twilio account. I have to admit I have found the process fairly painful.
You going to need a unique trunk name for Twilio. I recommend you head to random.org and just use a random string. Copy one and paste it into a note.
You need to use a Twilio product called "Elastic SIP Trunking". Here's what you fill in when you create your new Twilio trunk:
Trunk Name: Vicidial
Call Recording: No
Secure Trunking: Disabled
Termination URI: [that random string from random.org].pstn.twilio.com
IP Access Control Lists: (add every public IP address of your Vicidial cluster that needs to dial)
Credential Lists: (here's what people tend to mess up in my experience; make sure these are set with both username and password - I'd copy and past them into a note for reference when trunking Vicidial)
Origination SIP URI: (add the public IP address of one server of your Vicidial cluster; I tend you pick the server that's set as the voicemail server)
Priority: 10
Weight: 10
Log into your Administration interface of your Vicidial system and head to Carriers (Administration → Admin → Carriers)
Click "Add A New Carrier". It's in the grey bar across the top.
Carrier ID: Twilio
Carrier Name: Elastic SIP Trunk
Carrier Description: (I leave that blank)
Registration String: (leave that blank)
Account Entry:
[twilio]
disallow=all
allow=ulaw
type=friend
secret=(password you created in "Credential Lists")
username=(user name you created in "Credential Lists")
host=(the value used in "Termination URI", e.g. wkR9PaMPvk9h.pstn.twilio.com)
dtmfmode=rfc2833
context=trunk-inbound
Globals String:
TWILIO = SIP/twilio
Dialplan Entry:
exten => _91XXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _91XXXNXXXXXX,2,Dial(${TWILIO}/${EXTEN:1},,To)
exten => _91XXXNXXXXXX,3,Hangup
exten => _9XXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9XXXNXXXXXX,2,Dial(${TWILIO}/1${EXTEN:1},,To)
exten => _9XXXNXXXXXX,3,Hangup
exten => _1XXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _1XXXNXXXXXX,2,Dial(${TWILIO}/${EXTEN},,To)
exten => _1XXXNXXXXXX,3,Hangup
exten => _XXXNXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _XXXNXXXXXX,2,Dial(${TWILIO}/1${EXTEN},,To)
exten => _XXXNXXXXXX,3,Hangup
Submit and ensure the carrier is saved as Active "Y" (you'll have to submit a second time). Wait a minute or two and you should be able to send calls to Twilio. If there's a problem, double and triple check your outbound Caller ID setting as Twilio will block calls if that's not set up perfectly.

Asterisk incoming call DID question (number dialed)

I am setting up a new Asterisk system at a hosted Asterisk provider using 1.4.38, moving from a self-hosted version 1.2. Whereas before I could do:
[incoming]
exten => _1NXXNXXXXXX,1,DoSomething
Now, it appears the incoming context will only get properly called if it is:
[incoming]
exten => s,1,DoSomething
How do I determine what number was dialed in this scenario? We have dozens of numbers and I need to be able to know which was called to route correctly...
Thanks,
Ben
You can use a pattern. I have this line in a running asterisk instance:
exten => 5858876463,1,Set(__FROM_DID=${EXTEN})
However, to answer your question, you can use the ${EXTEN} variable to decide what number was called. E.g.
exten => s,1,SomeScript(${EXTEN})

Resources