Dialplan Assistance

Hello! I work for a Hosted PBX Company that supplies Voip service to people. A new product of ours is trunking which tends to have the majority of customers running some sort of asterisks based software to act as their PBX, mainly Elastix and Trixbox. Understanding that these are simply graphical overlays of Asterisk, im now trying to set an asterisk system up with no assistance from a GUI. Ive manually written my sip.conf, manager.conf, extensions,conf, and voicemail.conf files using as many online resources as i can find, however im a bit at a loss when it comes to my Dialplans.

my sip.conf file names 1 extension and 1 trunk which is successfully registered using auth details i created for myself at work. my voicemail.conf file has my mailboxes, and my manager.conf file contains my manager user ive created. My extensions.conf file im having some trouble with. I have successfully gotten a phone registered to my astericks machine (currently my laptop running ubuntu linux). Every time i try to make or recieve a call i get an error message in my asterisks CLI:

Call from extension 100 to X number rejected, no extension present in context [users].

[users] is the context ive made to contain all of my dialplans, and in my trunk settings i set the context=users

Is there a known comprehensive guide to creating dialplans out there? Im farmiliar with the format as i insert them into elastix and trixbox all the time using the dial=plan wizard. Any suggestions will help thanks!

posting your extensions.conf, would help in seeing what you have done so far…
but you need to add some lines to your [users] section on how you want to handle the dialed number.

such as, if you wish it to ring another sip device…

exten => 101,1,Dial(SIP/101)

you want to check your voicemail? dial *98 for instance.

exten => *98,1,VoiceMailMain(${CALLERID(num)}@xxx,s)

outbound calls…prepend a 9 like in a business

exten => _9.,1,Dial(SIP/${EXTEN:1}@trunkprovider)

you should read the book…Asterisk: The Future of Telephony http://www.asteriskdocs.org/

The main reference is the sample file that comes in the source code distribution.

awesome i will read that resource at once! I realized that i never posted my config files, so here they are. Keep in mind my goal is a simple one, i just want to be able to make/recieve calls on my single sip device, and on my second sip device i will set up to just be able to make and recieve calls from my first sip device (extension 100)

Here is the file i started with (sip.conf)
; Custom sip.conf file
; Written by Aaron DeMarco

; the general context contains global settings

[general]
port=5060
disallow=all
allow=ulaw

register => AUTHNAME:AUTHKEY@SERVERS.I.P.ADDRESS/AUTHNAME

; here 2 extensions are defined

[100]
type=peer
host=dynamic
secret=100
context=users
mailbox=100@default

[200]
type=peer
host=dynamic
secret=200
context=users
mailbox=200@default

; trunk defined

[Nextiva_Trunk1]
disallow=all
allow=ulaw
username=AUTHNAME
fromuser=AUTHNAME
type=friend
secret=AUTHKEY
qualify=no
maxexpirey=3600
host=MY.SERVERS.IP.ADDRESS
fromdomain=MY.SERVERS.IP.ADDRESS
insecure=invite
dtmfmode=rfc2833
session-timers=refuse
defaultexpirey=60
nat=no
canreinvite=no
context=users

And HERE we have the extensions.conf file i created:

; Custom extensions.conf file
; Written by Aaron DeMarco

; static is set to yes so the extensions.conf file will not be rewritten
static=yes

; writeprotect is set to no so you can save the dialplan from the CLI
writeprotect=no

; autofallthrough is for extension behavior when it runs out of things to do
autofallthrough=yes

; clearglobalvars set to yes has global variables cleared on reload
clearglobalvars=no

; priorityjumping set to no to avoid applications that support priority switching
; doing so
priorityjumping=no

; Macro for extension behavior, macros are advanced but eliminated need to code
; duplicate phone behavior for each extension

[macro-phone]
exten => s,1,Dial(SIP/${MACRO_EXTEN},25)
exten => s,n,Goto(${DIALSTATUS},1)
exten => ANSWER,1,Hangup
exten => CANCEL,1,Hangup
exten => NOANSWER,1,Voicemail(${MACRO_EXTEN}@default,u)
exten => BUSY,1,Voicemail(${MACRO_EXTEN}@default,b)
exten => CONGESTION,1,Voicemail(${MACRO_EXTEN}@default,b)
exten => CHANUNAVAIL,1,Voicemail(${MACRO_EXTEN}@default,u)
exten => a,1,VoicemailMain(${MACRO_EXTEN}@default)

; define the extensions for the 2 phones created in sip.conf (100 and 200)

[users]
exten => 100,1,Macro(phone)
exten => 200,1,Macro(phone)
exten => 123,1,VoicemailMain(default)

; dialplans
exten => _MYAUTHNAME,1,Dial(SIP/Nextiva_Trunk1/${EXTEN})

; long-distance
exten => _NXXNXXXXXX,1,Dial(SIP/Nextiva_Trunk1/1${EXTEN})
exten => _1NXXNXXXXXX,1,Dial(SIP/Nextiva_Trunk1/${EXTEN})
exten => _X,1,Dial(SIP/Nextiva_Trunk1/${EXTEN})

; local
exten => _NXXXXXX,1,Dial(SIP/Nextiva_Trunk1/1480${EXTEN})
exten => _NXXXXXX,1,Dial(SIP/Nextiva_Trunk1/1602${EXTEN})

and last but not least, the error message i receive when trying to dial anything inbound/outbound:
[Jun 10 07:26:01] NOTICE[1016]: chan_sip.c:20152 handle_request_invite: Call from ‘100’ to extension ‘THENUMBERIDIALEDHERE’ rejected because extension not found in context ‘users’.

As you can see ive added quite a few lines which im sure dont do anything at all trying to figure this out.

Hiding come information is great for your protection and privacy, but at the same time, it makes it were a proper problem solving can not always be done. Try to give something to work with. For instance, change the area code to 123 and the phone number to 5555. Or better yet try to dial a number to a motel. Something that wouldn’t matter, if people saw.

The number that you dialed must not match one of your mask in the [users] context…which of these lines do you think should have matched what you dialed and been used?

[users]
exten => 100,1,Macro(phone)
exten => 200,1,Macro(phone)
exten => 123,1,VoicemailMain(default)




; dialplans
exten => _MYAUTHNAME,1,Dial(SIP/Nextiva_Trunk1/${EXTEN})


; long-distance
exten => _NXXNXXXXXX,1,Dial(SIP/Nextiva_Trunk1/1${EXTEN})
exten => _1NXXNXXXXXX,1,Dial(SIP/Nextiva_Trunk1/${EXTEN})
exten => _X,1,Dial(SIP/Nextiva_Trunk1/${EXTEN})

; local
exten => _NXXXXXX,1,Dial(SIP/Nextiva_Trunk1/1480${EXTEN})
exten => _NXXXXXX,1,Dial(SIP/Nextiva_Trunk1/1602${EXTEN})

As far as inbound calls, your SIP provider would need to be providing the 100 or 200 to ring your sip phones. Otherwise, I believe your going to need a s extensions to catch those inbound calls.

exten => s,1,NoOp(Incoming call)
exten => s,n,Dial(SIP/100)

true that most likely will handle it…but I didn’t want to point that out yet, as he had made pattern matches for both long distance and local. So if his match is right and he dialed his number correctly, one of those patterns should have caught it.

Ok i read alot of the book (one of the resources posted above) at asteriskdocs, and wow have i come a long way since i first posted this. My problems were everywhere in the files i posted earlier, and would like to tell everyone what i did to fix it incase anyone else is having this same problem. I have now set up a complete phone system. I have a trunk registered, when you dial the number assigned to it my asterisk box plays a sound file from its hard drive that says “Weasels have eaten our phone system!” (One of the sound files that comes with asterisk). It them waits for DTMF. If you press any key from 1-7 it will play a sound file, reading the number that you pressed back to you. It then goes BACK to the Weasels message and waits for DTMF again. If you press 8, it rings the softphone i have on my other computer which is pointed towards my asterisk box’s local ip address. (And if i answer the call actually connects with 2 way audio) If you press 9 it thanks you for trying asterisk and hangs up the phone. Instead of pressing 8 to ring the phone you can also dial 2000. Outbound calls also function both local and long distance! I hope this helps someone

Here are my new files:
sip.conf

; Custom sip.conf file written for Asterisk
; Written by Aaron DeMarco

[general]
context=default
allowoverlap=no
bindport=5060
disallow=all
allow=ulaw

bindaddr=0.0.0.0
srvlookup=yes

register => AUTHNAME:AUTHKEY@PROVIDERIP/AUTHNAME

[2000]
type=friend
host=dynamic
secret=2000
context=phones

[trunk1]
disallow=all
allow=ulaw
username=AUTHNAME
fromuser=AUTHNAME
type=friend
secret=AUTHKEY
qualify=no
context=incoming
maxexpirey=3600
host=PROVIDERIP
fromdomain=PROVIDERIP
insecure=invite
dtmfmode=rfc2833
session-timers=refuse
defaultexpirey=60
nat=no
canreinvite=no


extensions.conf

; Custom extensions.conf file written for Asterisk
; Written by Aaron DeMarco

[general]
static=yes
writeprotect=no
autofallthrough=yes
clearglobalvars=yes

[globals]

[default]
[incoming]
exten => AUTHNAME,1,Answer()
exten => AUTHNAME,n,Background(/usr/share/asterisk/sounds/en_US_f_Allison/tt-weasels)
exten => AUTHNAME,n,WaitExten()
exten => AUTHNAME,n,Hangup()

exten => 1,1,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/digits/1)
exten => 1,n,Goto(incoming,AUTHNAME,1)

exten => 2,1,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/digits/2)
exten => 2,n,Goto(incoming,AUTHNAME,1)

exten => 3,1,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/digits/3)
exten => 3,n,Goto(incoming,AUTHNAME,1)

exten => 4,1,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/digits/4)
exten => 4,n,Goto(incoming,AUTHNAME,1)

exten => 5,1,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/digits/5)
exten => 5,n,Goto(incoming,AUTHNAME,1)

exten => 6,1,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/digits/6)
exten => 6,n,Goto(incoming,AUTHNAME,1)

exten => 7,1,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/digits/7)
exten => 7,n,Goto(incoming,AUTHNAME,1)

exten => 8,1,Dial(SIP/2000,20)
exten => 8,n,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/vm-sorry)
exten => 8,n,Hangup()

exten => 9,1,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/demo-thanks)
exten => 9,n,Hangup()

exten => i,1,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/pbx-invalid)
exten => i,n,Goto(incoming,AUTHNAME,1)

exten => 2000,1,Dial(SIP/2000,20)
exten => 2000,n,Playback(/usr/share/asterisk/sounds/en_US_f_Allison/vm-sorry)
exten => 2000,n,Hangup()

[outgoing]
exten => _NXXXXXX,1,Dial(SIP/trunk1/${EXTEN})
exten => _NXXXXXX,n,Congestion()
exten => _NXXXXXX,n,Hangup()

exten => _NXXXXXXXXX,1,Dial(SIP/trunk1/${EXTEN})
exten => _NXXXXXXXXX,n,Congestion()
exten => _NXXXXXXXXX,n,Hangup()

exten => _NXXXXXXXXXX,1,Dial(SIP/trunk1/${EXTEN})
exten => _NXXXXXXXXXX,n,Congestion()
exten => _NXXXXXXXXXX,n,Hangup()

[internal]

[phones]
include => outgoing

Please do not perpetuate "magic incantations"™ by asking your users to use type=friend.
Seeing a provider asking customers to use type=friend in their configs is a sure sign they have no idea what they are doing.

"magic incantations"™ appears courtesy of David W - issues.asterisk.org/jira/browse/ASTERISK-17763