sipsorcery dial plan for free GV calls


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. AREA_CODE = '602' # your area code
  2. GV_USER = '[email protected]' # your GV e-mail address
  3. GV_PASS = 'YOUR_GOOGLE_VOICE_PASSWORD' # your GV password
  4. CB_NUMBER = '1415XXXXXXX' # your 11-digit sipgate number
  5.  
  6. begin
  7. sys.Log "** Call from #{req.Header.From} to #{req.URI.User} **"
  8.  
  9. if sys.Out # if outbound call
  10. num = req.URI.User.to_s # Get a string copy of the number to dial
  11.  
  12. num = SPEED_DIAL[num] || num # Substitute with speed dial entry, if any
  13.  
  14. case num
  15. when /@/ then sys.Dial num # URI dialing
  16. when /^[2-9]\d{6}$/ # Local call, 7-digit number
  17. num = '1'+ AREA_CODE + num # prefix it with country and area code
  18. when /^[01]?([2-9]\d{9})/ # US number with or without country code
  19. num = '1' + $1 # add country code and truncate number to 10-digit
  20. when /^(011|00|\+)(\d{10,})/ # international number
  21. num = '+' + $2 # GoogleVoiceCall works with '+' prefix only
  22.  
  23.  
  24. else sys.Respond 603, 'Wrong number, check & dial again'
  25. end
  26.  
  27. sys.Log "Calling #{num} via Google Voice"
  28. sys.GoogleVoiceCall GV_USER, GV_PASS, CB_NUMBER, num, '.*', CB_NUMBER =~ /^1747/ ? 7 : 1, 30
  29.  
  30. else # sys.Out
  31. sys.Dial "#{sys.Username}@local"
  32. end
  33.  
  34. rescue
  35. sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
  36. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.