It can be modified to append the area code of your choice to the 7 digit number. It can also be modified to make the x11 dialing substitutions of your choice. Appropriate modifications must also be made to the GoogleVoiceCall() parameters to suit your account. I allowed a free gateway to make toll-free calls when possible to avoid the GV callback delay.
**Edited to incorporate the "fromUserToMatch" parameter within the sys.GoogleVoiceCall() to add flexibility to use it with various providers.
**Edited to incorporate the "phone type parameter for sys.GoogleVoiceCall().
Code: Select all
#Ruby - Default (works)
# Dial Plan Generated by Rubyzard v0.1
# If you need help, please post in our forum
# http://www.mysipswitch.com
begin
# SIP tracing : true or false
sys.Trace = false
sys.Log("call from #{req.Header.From.FromURI.ToString()} to #{req.URI.User}.")
if sys.In then
# Do your INCOMING call processing customisations here.
if sys.IsAvailable()
sys.Dial("#{sys.Username}@local",30)
else
sys.Respond(480, "#{sys.Username} Not available")
end
else
# Do your OUTGOING call processing customisations here.
GV_email = "xxxxxx@domain.com"
GV_pwd = "******"
SIPnum = "1747xxxxxxx"
ac = "773" # area code
pt = 7 # phone type (1=Home, 2=Mobile (default), 3=Work, 7=Gizmo)
case req.URI.User
when /^1?(50001|9000)$/ then sys.Dial("#{GV_nbr}@Future-Nine") # GV Voicemail
when /^1?(976|900|809)\d{7}$/
sys.Log("Calls to #{req.URI.User} not allowed")
sys.Respond(488, "Call not allowed")
when /^1?((888|877|866|800)\d{7})$/ then sys.Dial("1#{$1}@sip.tollfreegateway.com") # use free gateway
when /^411$/ then sys.Dial("18004664411@sip.tollfreegateway.com") # use free gateway
when /^1?([2-9]\d{2}[2-9]\d{6})$/ then sys.GoogleVoiceCall(GV_email,GV_pwd,SIPnum,"1#{$1}",".*",pt) # 10 or 11 digits
when /^([2-9]\d{6})$/ then sys.GoogleVoiceCall(GV_email,GV_pwd,SIPnum,"1#{ac}#{$1}",".*",pt) # 7 digits
when /^311$/ then sys.GoogleVoiceCall(GV_email,GV_pwd,SIPnum,"13127445000",".*",pt)
else
sys.Log("#{req.URI.User} is an invalid number")
sys.Respond(603,'Wrong number, check & dial again')
end
end
rescue
sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end