Return to Snippet

Revision: 29180
at July 23, 2010 09:04 by adhd360


Updated Code
AREA_CODE = '602'                  # your area code
GV_USER   = '[email protected]'   # your GV e-mail address
GV_PASS   = 'YOUR_GOOGLE_VOICE_PASSWORD'          # your GV password
CB_NUMBER = '1415XXXXXXX'          # your 11-digit sipgate number

begin
   sys.Log "** Call from #{req.Header.From} to #{req.URI.User} **"

 if sys.Out    # if outbound call
   num = req.URI.User.to_s        # Get a string copy of the number to dial

   num = SPEED_DIAL[num] || num   # Substitute with speed dial entry, if any

   case num
     when /@/ then sys.Dial num   # URI dialing
     when /^[2-9]\d{6}$/          # Local call, 7-digit number
       num = '1'+ AREA_CODE + num # prefix it with country and area code
     when /^[01]?([2-9]\d{9})/    # US number with or without country code
       num = '1' + $1             # add country code and truncate number to 10-digit
     when /^(011|00|\+)(\d{10,})/ # international number
       num = '+' + $2             # GoogleVoiceCall works with '+' prefix only


     else sys.Respond 603, 'Wrong number, check & dial again'
   end

   sys.Log "Calling #{num} via Google Voice"
   sys.GoogleVoiceCall GV_USER, GV_PASS, CB_NUMBER, num, '.*', CB_NUMBER =~ /^1747/ ? 7 : 1, 30

 else          # sys.Out
   sys.Dial "#{sys.Username}@local"
 end

rescue
 sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end

Revision: 29179
at July 23, 2010 08:43 by adhd360


Initial Code
AREA_CODE = '602'                  # your area code
GV_USER   = '[email protected]'   # your GV e-mail address
GV_PASS   = 'YOUR_GOOGLE_VOICE_PASSWORD'          # your GV password
CB_NUMBER = '1415XXXXXXX'          # your 11-digit sipgate number

begin
   sys.Log "** Call from #{req.Header.From} to #{req.URI.User} **"

 if sys.Out    # if outbound call
   num = req.URI.User.to_s        # Get a string copy of the number to dial

   num = SPEED_DIAL[num] || num   # Substitute with speed dial entry, if any

   case num
     when /@/ then sys.Dial num   # URI dialing
     when /^[2-9]\d{6}$/          # Local call, 7-digit number
       num = '1'+ AREA_CODE + num # prefix it with country and area code
     when /^[01]?([2-9]\d{9})/    # US number with or without country code
       num = '1' + $1             # add country code and truncate number to 10-digit
     when /^(011|00|\+)(\d{10,})/ # international number
       num = '+' + $2             # GoogleVoiceCall works with '+' prefix only


     else sys.Respond 603, 'Wrong number, check & dial again'
   end

   sys.Log "Calling #{num} via Google Voice"
   sys.GoogleVoiceCall GV_USER, GV_PASS, CB_NUMBER, num, '.*', CB_NUMBER =~ /^1747/ ? 7 : 1, 30

 else          # sys.Out
   sys.Dial "#{sys.Username}@local"
 end

rescue
 sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end

Initial URL


Initial Description


Initial Title
sipsorcery dial plan for free GV calls

Initial Tags


Initial Language
Ruby