Vicidial SIP Trunk with Twilio - asterisk

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.

Related

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)

Not getting DTMF digits during call

I am writing a simple asterisk extension plan, In which when user calls, User press key and that key store to a text file.
For this i write this extension:-
exten => 203,1,Answer()
exten => 203,2,Read(NUMBER1||1)
exten => 203,3,System(echo 'User entered ${NUMBER1}' >> /tmp/key.txt)
exten => 203,4,Hangup()
But whenever i call and press any key, file only have 'User entered', Means i am not getting key.
What i am doing wrong here?
Here is my sip.conf for extension:-
[mysjphone]
type=friend
host=dynamic
username=mysjphone
secret=blablabla
allow=gsm
dtmfmode = rfc2833
host = dynamic
Note: I am doing this in windows server (astriskwin32).
That package is built on an extremely old version of Asterisk, 1.2.x. Since that time, there were many, many improvements made to Asterisk's ability to detect and process RFC2833 DTMF events. You'll likely want to upgrade to a much newer version of Asterisk. For more information about Asterisk versions, please see:
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions

Asterisk CDR Report shows "s" in the destination field

I have had issue on an platform for quite sometime now, when somebody calls in to ivr system, the cdr report destination field shows an 's' in place of the called number.
The inbound route for the DID is set to the ivr menu.
Here is my dial plan:
"
exten => 800000031,1,Set(__FROM_DID=${EXTEN})
exten => 800000031,n,Gosub(app-blacklist-check,s,1)
exten => 800000031,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => 800000031,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => 800000031,n,Set(CALLERPRES()=allowed_not_screened)
exten => 800000031,n(dest-ext),Goto(ivr-3,s,1)*
"
I suspect the issue is on the last line but the file is not allowed to be edited directly.
Will appreciate any help.
s is the default extension in asterisk , go through the logs and try to find out on what context that call was executed. It usually happens when you do not create a context for any specific DID in extension.conf. then the call is being routed to asterisk default context
Use ${EXTEN} instead of s in Goto(ivr-3,s,1), Also in ivr-3 context create a dialplan using wildcard symbol. e.g
exten => 800000031,1,Set(__FROM_DID=${EXTEN})
exten => 800000031,n,Gosub(app-blacklist-check,${EXTEN},1)
exten => 800000031,n,ExecIf($[ "${CALLERID(name)}" = "" ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => 800000031,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => 800000031,n,Set(CALLERPRES()=allowed_not_screened)
exten => 800000031,n(dest-ext),Goto(ivr-3,${EXTEN},1)
[ivr-3]
exten => _X.,1,NoOp("Hello world")
We have an IVR. When an external caller listens to IVR and decides to hangup before IVR ends talking, in report we see "s" as Destination. Otherwise, in report we see extension dialed after or while IVR is talking. I guess it's normal. If You have been hacked You'd see other various destinations but not "s".
Solved on ours, there was no default destination set for the reception ring group. We pointed it back to the IVR and now no longer see the s destination.
Most likly that mean you have been hacked. Please check that you have no guest calls enabled, contact security expert to find hole and fix it.

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})

Asterisk auto Call recording

We are running asterisk with 8 port FXO. FXO connects to our old PBX (Samsung Office Serv 100).
Now we want to record all calls routed through FXO (if it was dialed to outside or comming from outside).
Is there a simple way to do this?
Are you running plain Asterisk? If so you can modify your dial plan to start 'monitoring' the channel, which will record the call.
The monitor command's documentation: http://www.voip-info.org/wiki/view/Asterisk+cmd+monitor
Just for the sake of completion, here's the documentation:
[root#localhost ~]# asterisk -rx 'core show application monitor'
-= Info about application 'Monitor' =-
[Synopsis]
Monitor a channel
[Description]
Monitor([file_format[:urlbase],[fname_base],[options]]):
Used to start monitoring a channel. The channel's input and output
voice packets are logged to files until the channel hangs up or
monitoring is stopped by the StopMonitor application.
file_format optional, if not set, defaults to "wav"
fname_base if set, changes the filename used to the one specified.
options:
m - when the recording ends mix the two leg files into one and
delete the two leg files. If the variable MONITOR_EXEC is set, the
application referenced in it will be executed instead of
soxmix and the raw leg files will NOT be deleted automatically.
soxmix or MONITOR_EXEC is handed 3 arguments, the two leg files
and a target mixed file name which is the same as the leg file names
only without the in/out designator.
If MONITOR_EXEC_ARGS is set, the contents will be passed on as
additional arguments to MONITOR_EXEC
Both MONITOR_EXEC and the Mix flag can be set from the
administrator interface
b - Don't begin recording unless a call is bridged to another channel
i - Skip recording of input stream (disables m option)
o - Skip recording of output stream (disables m option)
By default, files are stored to /var/spool/asterisk/monitor/.
Returns -1 if monitor files can't be opened or if the channel is already
monitored, otherwise 0.
And here's a sample way you can use it:
; This fake context records all outgoing calls to /var/spool/asterisk/monitor in wav format.
[fake-outgoing-context]
exten => s,1,Answer()
exten => s,n,Monitor(wav,,b)
exten => s,n,Dial(DAHDI/g0/${EXTEN})
exten => s,n,Hangup()
Obviously you'd have to make changes to my code, but hopefully that gives you a good idea.
A real life example is
exten => _87X,1,NoOp()
exten => _87X,n,MixMonitor(${UNIQUEID}.wav,ab)
exten => _87X,n,Dial(SIP/${EXTEN},45)
exten => _87X,n,StopMixMonitor()
exten => _87X,n,Hangup()
It's good practise to always have NoOp - the first rule must start with 1, this way you can interchange the rules with the n step any way you want.
It's always best to use MixMonitor as opposed to Monitor - Monitor only records inbound or outbound audio - MixMonitor uses both.
Also wav is quite a good choice as a format - I also use a script to transform the wav files to OGG at the end of the day - the best compromise between size / quality and licensing issues.
With regards to the arguments
a is append
b is bridge (good for production - it will only record when the call is answered - not good for debugging)
With regards to StopMixMonitor(), I'm just being thorough, but for examples there are cases in which you would like to stop the recording, for example:
...
exten => _39[5-9],n,Dial(SIP/${EXTEN},45)
exten => _39[5-9],n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavailable)
exten => _39[5-9],n(busy),NoOp()
exten => _39[5-9],n,StopMixMonitor()
exten => _39[5-9],n,Voicemail(${EXTEN},u)
exten => _39[5-9],n,Hangup()
exten => _39[5-9],n(unavailble),NoOp()
exten => _39[5-9],n,StopMixMonitor()
exten => _39[5-9],n,Hangup()
...
In this example, you would stop the recording of the voice mail interaction.
Hope this will bring some light on the matter.
Depending on the specifications of your Asterisk box you might find this hack useful too. Create a rather large ramdisk and mount /var/spool/asterisk/monitor to it. That way Asterisk records to memory not disk. Then write a script under cron to move the recordings to permanent storage every 15-30 minutes or so.

Resources