Archive for the 'Asterisk' Category

Speed dial on Asterisk

It’s fairly simple to setup a programmable speeddial with asterisk. All with a option to playback what speed dials you have setup.

You’ll need to setup the dialplan to handle the extensions for the speeddial. For me, I choose a *29 to setup the speed dials, then *3X, *4X, and *5X as the actual speed dials. *30, *40, *50 are reserved for playback (see later). I used each range to hold different meanings. *3X was for family, *4X was for friends, and *5X was for restaurants. These instructions should give you enough to set it up and change it to what you’d like.

In your main dialplan (house for this example) in your extensions.conf file:

[house]

;; Normal outgoing rules, whatever you have for your outgoing provider
exten => _ZXXXXX.,1,Dial(SIP/${EXTEN}@PROVIDER)

;; Start of speed dial rules, go at the end of your main dialplan
exten => *29,1,Goto(speeddial,create,1)
exten => *30,1,Goto(speeddial,answer,Speed30)
exten => *40,1,Goto(speeddial,answer,Speed40)
exten => *50,1,Goto(speeddial,answer,Speed50)

;; This handles all the speed dials and will figure out what number to dial
;; and hand it back to your main dial plan. It'll also check to make sure
;; it's valid and if not, play a message indicating it's empty.
exten => _*[3-5][1-9],1,Answer()
exten => _*[3-5][1-9],n,Wait(1)
exten => _*[3-5][1-9],n,Set(NUMBER=${DB(speeddial/${EXTEN})})
exten => _*[3-5][1-9],n,GotoIf($["${NUMBER}" = ""]?BadNumber)
exten => _*[3-5][1-9],n,Playback(speed-dial)
exten => _*[3-5][1-9],n,Playback(call)
exten => _*[3-5][1-9],n,Playback(numbers/${NUMBER})
;; Hand it back to your main dial plan, ie "house"
exten => _*[3-5][1-9],n,Dial(local/${NUMBER}@house)
exten => _*[3-5][1-9],n,Hangup()
exten => _*[3-5][1-9],n(BadNumber),Playback(speed-dial-empty)
exten => _*[3-5][1-9],n,Hangup()

[speeddial]

;; Setup a new speed dial. Note: It won't let you enter any of the
;; playback speed dials, or outside the range
exten => create,1,Answer()
exten => create,n(Start),Read(NEW|custom/speeddial/speed-intro,2)
exten => create,n,Set(STEST=${DB_EXISTS(speeddial/*${NEW})})
exten => create,n,GotoIf($["${STEST}" = "1"]?Overwrite)
;; Put the *30, *40, *50 extentions here so you can't use them, also
;; adjust the range (ie: 31-->59)
exten => create,n,GotoIf($["${MATH(${NEW}<=30,int)}" = "TRUE"]?Start)
exten => create,n,GotoIf($["${NEW}" = "40"]?Start)
exten => create,n,GotoIf($["${NEW}" = "50"]?Start)
exten => create,n,GotoIf($["${MATH(${NEW}>=60,int)}" = "TRUE"]?Start)

;; Prompt for the new 10 digit outgoing number
exten => create,n(Number),Read(NEWEXT|custom/speeddial/enternumber|10)
exten => create,n,Playback(custom/speeddial/you-entered)
exten => create,n,SayDigits(${NEWEXT}
exten => create,n,Read(CHECK,custom/speeddial/correct-press1-otherwise-press-2,1)
exten => create,n,GotoIf($[${CHECK} = 2] ?Number)
exten => create,n,GotoIf($[${CHECK} = 1] ?Record)

;; Record a message indicating who this is (ie, Mother, Father, Friend's name etc...)
exten => create,n(Record),Playback(custom/speeddial/recordmesg)
exten => create,n,Record(numbers/${NEWEXT}:sln)
exten => create,n,Playback(numbers/${newext})
exten => create,n,Playback(custom/speeddial/thankbye)
exten => create,n,Set(DB(speeddial/*${NEW})=${NEWEXT})
exten => create,n,Hangup()

;; This just handles if you want to overwrite an existing speeddial
exten => create,n(Overwrite),Read(OVER,custom/speeddial/speed-overwrite,1)
exten => create,n,GotoIf($[${OVER} = 1] ?Number)
exten => create,n,GotoIf($[${OVER} = 2] ?PlayNumber)
exten => create,n,GotoIf($[${OVER} = 3] ?Start)
exten => create,n,Hangup()

exten => create,n(PlayNumber),Set(NUMBER=${DB(speeddial/*${NEW})})
exten => create,n,Playback(numbers/${NUMBER})
exten => create,n,Goto(Start)

;; If you dial *30, *40, *50 it'll start playing back all the speed dial recordings
;; starting that next higher one.
;; *30 starts playback at speed dial *31
;; *40 starts playback at speed dial *41
;; *50 starts playback at speed dial *51
exten => answer,1,Answer()
exten => answer,n(Speed30),Set(SDIAL=31)
exten => answer,n,Goto(StartPlay)
exten => answer,n(Speed40),Set(SDIAL=41)
exten => answer,n,Goto(StartPlay)
exten => answer,n(Speed50),Set(SDIAL=51)
exten => answer,n,Goto(StartPlay)

;; You can dial any speed dial number while it's going through the playback.
exten => answer,n(StartPlay),Set(TIMEOUT(digit)=2)
exten => answer,n,Set(TIMEOUT(response)=60)
exten => answer,n,Wait(1)
exten => answer,n(Playnumber),Set(STEST=${DB_EXISTS(speeddial/*${SDIAL})})
exten => answer,n,GotoIf($["${STEST}" = "0"]?Add1)
exten => answer,n,Set(NUMBER=${DB(speeddial/*${SDIAL})})
exten => answer,n,Background(press-star)
exten => answer,n,SayDigits(${SDIAL})
exten => answer,n,Background(for)
exten => answer,n,Background(numbers/${NUMBER})
exten => answer,n(Add1),Set(SDIAL=${MATH(${SDIAL}+1,int)})

exten => answer,n,GotoIf($["${MATH(${SDIAL}>=59,int)}" = "TRUE"]?LastDial)

exten => answer,n,Goto(Playnumber)

;; Last number played, wait up to 60 seconds for them to press an * speed dial
exten => answer,n(LastDial),NoOp( No More )
exten => answer,n,WaitExten(60)
exten => answer,n,Playback(goodbye)
exten => answer,n,Hangup()

;; Handle the dialing of the speed dial, just pass it to the main dial plan (house)

exten => _*[3-5][1-9],1,Dial(local/${EXTEN}@house)

Here’s the zip file with the custom/speeddial sounds.  You’ll want to unzip this in your sounds/custom folder.

Enjoy!

No Comments »

on November 3rd 2010 in Asterisk

Gizmo and Asterisk 1.6

After upgrading to Ubuntu 9.10 which includes Asterisk 1.6 my Google Voice connection through Gizmo5 stopped working. Sound familiar?

The issue is that Asterisk 1.6 requires insecure=invite in the sip.conf definition for Gizmo.

Here’s my working config:
[gizmo]
type=peer
context=your-context-here
disallow=all
allow=ulaw
allow=gsm
dtmfmode=rfc2833
host=proxy01.sipphone.com
insecure=invite    <---Change this setting
secret=password-here
username=gizmo-number-here
canreinvite=no

Source: http://vaug.ca/pipermail/vaug/2009-March/000053.html

No Comments »

on December 18th 2009 in Asterisk

Asterisk voicemail sent to cell phone

Anyone whom uses asterisk knows that Asterisk can send voicemail notifications to your cell phone. Normally the Asterisk voicemail.conf file would look like this:

201 => 1234,Eric,my@email.com,CELLNUMBER@vtext.com,|tz=eastern|volgain=3.0

This would send a short text message to your cell phone indicating you have a new voicemail. It would also send the voicemail itself as an attachment to your email address. This example goes to a Verizon wireless cell phone. Once you get the notification you still need to check the voicemail. This could be as simple as dialing in from your cell phone to check on the voicemail remotely. Wouldn’t it be nice if you could just get the message directly to your cell phone? You can! The audio message that is attached is just a wave file that seems to be playable on most phones as a multimedia attachment. For Verizon you just need to send it to a different email address:

201 => 1234,Eric,CELLNUMBER@vzwpix.com,,|tz=eastern|volgain=4.0

This changes the email address to be the email address for Verizon’s MMS gateway. What shows up on the phone is PIX message with an audio component. You can then play the voicemail directly from your phone. I also had to adjust the volgain in order to raise the volume. Here’s the list for other cell carriers. I know it works for Verizon. In theory it should work many other carries and phones. Anyone who has luck with this, please post and let me know.

No Comments »

on July 13th 2009 in Asterisk