I also wrote a RubyWizard to make it easy to customize the plan to your needs.
RubyWizard
http://free2call.me/rubywizard.html
USE copy and paste on the rubywizard output to copy the plan, a save of the page may not work and you lose the results.
Keyboard shortcuts work; use Ctrl-C to copy and Ctrl-V to paste.
Ctrl-A to 'select all' of the plan to copy.
just make sure the provider names in SIP Providers are the same ones you set in the dial plan.
Code: Select all
# your OUTGOING call processing.
sys.SetFromHeader("#{req.Header.From.FromName}", nil, nil) # Set Display Name from phone in CallerID
#**************************************************
# Advanced outplan generated using mnipp-RubyWizard
# Fri, 16 Apr 2010 04:16:22 +0000 GMT/UTC
#**************************************************
#**************************************************
# >> ptel << is the name I used in my SIP Provider settings for calls to fixed phones and mobiles.
#**************************************************
SPEED_DIAL = [ # SPEED DIAL Entries with 01 or 02 etc.. dialled number
#**************************************************
'Number Dialled' , 'Number or SIP to Send ' , # Label Contact
' 01 ' , ' buddy1 ' , # dial buddy1 on sipsorcery
' 02 ' , ' buddy2@iptel.org ' , # buddy2 on iptel.org
' 03 ' , ' (02) 8765 4321 ' , # speed dial 02 8765 4321 phone number with pennytel account
# Radio Podcasts on phone, use (*) to skip forward and (#) back in 1 minute jumps.
' 30 ' , ' 5595534621 @ podlinez .net' , # Dr Karl on triplej
' 31 ' , ' 6414539840@podlinez.net ' , # ABC NewsRadio Senate Question Time
' 32 ' , ' 6414539852@podlinez.net ' , # ABC NewsRadio House of Representatives Question Time
' 33 ' , ' 6414530997@podlinez.net ' , # All in the Mind
' 34 ' , ' 6414531005@podlinez.net ' , # Radio National, The Science Show
' 35 ' , ' 6414531002@podlinez.net ' , # Innovations www.radioaustralia.net.au
' 36 ' , ' 6414531004@podlinez.net ' , # StarStuff takes us on a weekly journey across the universe
' 37 ' , ' 4152234133@podlinez.net ' , # AM program
' 38 ' , ' 6502939113@podlinez.net ' , # PM program
# This is a gizmo5 1222 dialled conference room, room number 0000000
' 50 ' , ' 12220000000@proxy01.sipphone.com ' , #
# Try these test numbers on speed dial
' 97 ' , ' 1234@loligo.com ' , #
' 98 ' , ' 904@mouselike.org ' , #
' 99 ' , ' +1800 555 8355 ' , # TELL ME, USA +1800 are free calls on Enum Lookup
'100 ' , ' skype_echo123@proxy01.sipphone.com ' , # echo test on SKYPE
# Send these small numbers to MyNetFone
'151 ' , ' @mynet ' , # MyNetFone acc balance
'121 ' , ' @ mynet ' , # MyNetFone voicemail
# Send these small numbers to pennytel
'771 ' , ' @ ptel ' , # ptel acc balance
'778 ' , ' @ptel ' , # ptel voicemail
'*500 ' , ' @voxalot ' , # voxalot voicemail
' 131314 ' , ' (03) 9683 9999 ' , # ANZ BANK 131314 to 03 9683 9999 cheaper number
]#*************************************************
# The following section is to define functions to be used later in the plan such as
# How to do an Enum lookup.
#**************************************************
# International Enum database list from sipbroker
EnumSuffix = %w[ e164.arpa e164.org e164.info e164.televolution.net enum.org ]
# Only these likely for local numbers for faster lookup
EnumLocal = %w[ e164.arpa e164.org ]
def E164num(nume164) # turn number into full international E164 format.
# this section uses (61)country code (02)area code and (0011)international prefix
if nume164 =~ /^0011/ then
nume164 = nume164[4..50] # remove international prefix (0011) 4 digits from front of number
else
nume164 = "61" + nume164[1..50] if nume164 =~ /^0/ # national number remove leading 0 add 61.
nume164 = "612" + nume164 if nume164.length == 8 # local number 8 digits add 612.
nume164 = "61" + nume164 if !(nume164 =~ /^61/) # add 61 to remaining numbers
EnumSuffix = EnumLocal # Use local Enum database list only
end
sys.Log("Number in Enum E164 format +#{nume164}")
return nume164
end
# ENUM lookup of number for possible sip address
def EnumCall(num)
nume164 = E164num(num) # first turn number into full international e164 format using above rules for your country.
sys.Log("Entering enumCall")
EnumSuffix.each do |suffix| # check each Enum database
sys.Log("Searching #{suffix} for #{nume164}") # log Enum check
if enumuri = sys.ENUMLookup("#{nume164}.#{suffix}") # if true dial returned sip
sys.Log("Attempting call to #{enumuri}")
sys.Dial("#{enumuri}") # dialling returned sip address
sys.Log("Failed to call #{enumuri}")
end
end
end
#******************************************
SPEED_DIAL.map!{ |SDnum| SDnum.to_s.strip} # remove spacing around Speed-dial entries.
SD = Hash[*SPEED_DIAL]
num = SD[req.URI.User.to_s] || req.URI.User.to_s # Get dialled number Substitute with speed dial entry, if any
num = num.gsub(/\ /,'') # delete all spaces.
case num
when /^@/ then sys.Dial("#{req.URI.User}#{num}") # Dial number to selected @provider in SPEED_DIAL
when /@/ then sys.Dial(num) # Dial if sip:address from SPEED_DIAL
when /%40/ then sys.Dial("#{req.URI.User.to_s.gsub(/%(..)/){$1.hex.chr}}[rm=a]") # (user%40host@sipsorcery.com) to (user@host)
# Select dialout provider
when /^1747/ then sys.Dial("gizmo5") # with number prefix
when /^1222/ then sys.Dial("gizmo5") # with number prefix
# Select dialout provider with 1* 2* etc.. in front of number, ${dst:2} will remove the 1* prefix
when /^1\*/ then sys.Dial("${dst:2}@ptel") # dial (1*number) for (number@ptel).
when /^2\*/ then sys.Dial("${dst:2}@mynet") # dial (2*number) for (number@mynet).
when /^3\*/ then sys.Dial("${dst:2}@gizmo5") # dial (3*number) for (number@gizmo5).
# 9*+sipbroker number dialling (eg 9*234..to *234..@sipbroker.com)
when /^9\*/ then sys.Dial("${dst:1}@sipbroker.com[rm=a]")
# Add 0* in front of the number for sipsorcery only dial.
when /^0\*/ then sys.Dial("${dst:2}@local") # 0* + number for sipsorcery.com
# freenum.org style dialling eg (1234*256) for (sip:1234@loligo.com)
when /^(\d{2,})\*(\d{2,})$/ then sys.Dial(sys.ENUMLookup("#{$1}.#{$2}.freenum.org"))
# end of speed dial list
# ****************************************
else
# ****************************************
# if a full sip dial, dial here and quit.
# skip to number dial if sipsorcery host
# ****************************************
if sys.GetCanonicalDomain(req.URI.Host.to_s) == "sipsorcery.com"
sys.Dial("#{num}@local") if num =~ /[a-zA-Z]/ # if dialled sipsorcery name not number from softphone or SPEED DIAL
sys.Respond(480, "failed sip dial.") if num =~ /[a-zA-Z]/ # A failed sip dial, quit dial plan
else
sys.Log("Sip Number in #{req.URI.User}@#{req.URI.Host}")
sys.Dial("#{req.URI.User}@" << "#{req.URI.Host}".downcase) # dial full sip address entered
sys.Respond(480, "failed sip dial.") # A failed sip dial, quit dial plan
end
# end of sip dial.
num = num.gsub(/[^0-9*#+]/,'') # delete all but digits and ( # * + ) on numbers.
num = num.gsub(/^\+/,'0011') # replace leading + with international prefix on numbers.
num = num.gsub(/\+/,'')
num = num[0..14] if num =~ /^00111[2-9]/ # trim USA numbers longer than +(11 digits) to be valid.
numarea = num
numarea = "02" + num if num.length == 8 # local number 8 digits add (02)areacode.
nume164 = E164num(num) # number in full international e164 format
# ****************************************
# Do an Enum check on number.
# ****************************************
# If number greater than or equal to 8 digits try an Enum check
EnumCall(num) if num.length >= 8
# if ENUM failed on USA TollFree try this directly.
sys.Dial("164164#{nume164}@sip.tollfreegateway.com") if nume164 =~ /^1(800|866|877|888)\d{7}/
# ****************************************
# If no above matches,
# The default main provider account
# ****************************************
sys.Dial("#{numarea}@ptel") # default provider. local numbers dialled with (02)areacode
sys.Dial("#{numarea}@mynet") # backup provider. local numbers dialled with (02)areacode
end