Google Voice Dial Out

New features you'd like see on SIP Sorcery
User avatar
Stiefel
Posts: 10
Joined: Tue Jun 24, 2008 4:13 am
Location: Berlin, Germany

Post by Stiefel » Mon Sep 28, 2009 8:27 pm

I would like to use GVout, when I dial e.g. 0001xxxxxxxxxx, but this means, the first 3 digits ("000") have to be cut off the dialed number of "req.URI.User.to_str". Is it possible to format the number given back by the "req.URI.User.to_str"-string?

Code: Select all

when /^000/ then sys.GoogleVoiceCall("user name", "password", "1747xxxxxxx", req.URI.User.to_str)
Thanks.
Arne »Stiefel« Robertson
Berlin, Germany

mel2000
Posts: 184
Joined: Fri Jun 05, 2009 11:27 pm

Post by mel2000 » Tue Sep 29, 2009 3:40 am

If I understand correctly, you want to send your calls without the 000 prefix? Why not just dial without the 000?

If all your outbound numbers are of the format 0001xxxxxxxxxx then try:

Code: Select all

case req.URI.User
  when /^000(1\d{10})$/ then sys.GoogleVoiceCall("user name", "password", "1747xxxxxxx", "#{$1}")

User avatar
Stiefel
Posts: 10
Joined: Tue Jun 24, 2008 4:13 am
Location: Berlin, Germany

Post by Stiefel » Tue Sep 29, 2009 4:22 am

mel2000 wrote:If I understand correctly, you want to send your calls without the 000 prefix?
yes, that's right. I'm looking for a way to cut off the prefix "000" (or any other prefix like "1*") of the dialed number returned by "req.URI.User.to_str".
Why not just dial without the 000?
Because if want to choose to use Google Voice with this prefix, e.g.:
001... => USA (NANP) via provider A
0001... => USA via Google Voice

00 international dialing prefix in Germany (Europe) such as 011 in the NANP etc.
000 is unused in the German PSTN so I use this prefix für Google Voice and other VoIP-networks.

Code: Select all

case req.URI.User
  when /^000(1\d{10})$/ then sys.GoogleVoiceCall("user name", "password", "1747xxxxxxx", "#{$1}")
That doesn't work.
Arne »Stiefel« Robertson
Berlin, Germany

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Post by Aaron » Tue Sep 29, 2009 5:07 am

Stiefel wrote:I would like to use GVout, when I dial e.g. 0001xxxxxxxxxx, but this means, the first 3 digits ("000") have to be cut off the dialed number of "req.URI.User.to_str". Is it possible to format the number given back by the "req.URI.User.to_str"-string?

Code: Select all

when /^000/ then sys.GoogleVoiceCall("user name", "password", "1747xxxxxxx", req.URI.User.to_str)
The req.URI.User.to_str is a normal Ruby string object so you can manipulate it in any manner you want.

Here's a list of Ruby string functions http://ruby-doc.org/core/classes/String.html.

An example that would seem to suit your requirement is:

Code: Select all

dst = req.URI.User.to_str
trimmedDst = dst[3..(dst.length-3)]

when /^000/ then sys.GoogleVoiceCall("user name", "password", "1747xxxxxxx", trimmedDst )
Regards,

Aaron

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Post by MikeTelis » Tue Sep 29, 2009 8:04 am

Stiefel, Aaron,

I think this problem is of different sort, it's the order in which "when" patterns appear in the case statement. Let's consider the following code:

Code: Select all

num = '00012125551212'

case num
  when /^000(.+)/ then puts "n2 = #$1"
  when /^00(.+)/ then puts "n1 = #$1"
end
If run, this program will print n2 = 12125551212, which is correct. However, if you switch "when" lines:

Code: Select all

num = '00012125551212'

case num
  when /^00(.+)/ then puts "n1 = #$1"
  when /^000(.+)/ then puts "n2 = #$1"
end
it will print n1 = 012125551212, not what you wanted!

My guess is that Stiefel put "000" line after "00", hence the result.

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Post by Aaron » Tue Sep 29, 2009 9:26 am

MikeTelis wrote:If run, this program will print n2 = 12125551212, which is correct. However, if you switch "when" lines:

Code: Select all

num = '00012125551212'

case num
  when /^00(.+)/ then puts "n1 = #$1"
  when /^000(.+)/ then puts "n2 = #$1"
end
it will print n1 = 012125551212, not what you wanted!
Alternatively

Code: Select all

num = '00012125551212'

case num
  when /^00([^0]+)/ then puts "n1 = #$1"
  when /^000(.+)/ then puts "n2 = #$1"
end

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Post by MikeTelis » Tue Sep 29, 2009 2:09 pm

Aaron,

certainly, it works, too! I made it my rule of thumb that, if I need to test several similar patterns with case..when statement, "when" with longer patterns should go first. In this case, when /^000/ should be placed before when /^00/.

User avatar
Stiefel
Posts: 10
Joined: Tue Jun 24, 2008 4:13 am
Location: Berlin, Germany

Post by Stiefel » Tue Sep 29, 2009 7:18 pm

Thank you :-)
Arne »Stiefel« Robertson
Berlin, Germany

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Post by MikeTelis » Tue Sep 29, 2009 7:43 pm

You're welcome! Out of curiosity, was I right, you did put /^000/ pattern after /^00/ in case statement? :wink:

ossiemaracay
Posts: 12
Joined: Fri Aug 14, 2009 1:48 pm
Location: Miami, FL USA

Post by ossiemaracay » Wed Sep 30, 2009 5:20 pm

Ok....After expending my whole weekend messing with this stuff I'm about ready to give up....maybe I can get some help from the experts here:

I've been trying to make outgoing calls using GV/IPKall with no success.

I have used several different plans from the most simple one given by GVTRICKS on this thread to a much more complex plan and I always keep getting the same result: One ring and then a get a fast busy tone.

Here is a copy of the my current GV/IPKALL Plan:

Code: Select all

# Dial Plan for GV/IPKALL

# SIP tracing : true or false
sys.Trace = false
sys.Log("** Call from #{req.Header.From.ToString()} to #{req.URI.User} **") 

if sys.In then
 # Do your INCOMING call processing customisations here.
        sys.Respond(400, "#{sys.Username} Not available")
        sys.Log("No incoming call")
else 
 # Do your OUTGOING call processing customisations here.
   GV_email = "oXXXXXX@gmail.com"
   GV_pwd = "XXXXXX"
   GV_nbr = "305XXXXXXX"
   SIPnum = "253XXXXXXX" #IPKall nbr
   ac = "305"       # area code

   case req.URI.User
     when /^[1]?(976|900|809)/
       sys.Log("Calls to pay-per-call line #{req.URI.User} not allowed")
       sys.Respond(488, "Call not allowed")
     when /^[1]?((800|866|877|888)\d{7})/ then sys.Dial("#{$1}@voiper.ipkall.com")   # use free gateway
     when /^411/ then sys.Dial("8004664411@voiper.ipkall.com")   # use free gateway
     when /^[1]?([2-9]\d{2}[2-9]\d{6})/ then sys.GoogleVoiceCall(GV_email,GV_pwd,SIPnum,"1#{$1}",GV_nbr)   # 10 or 11 digits
     when /^([2-9]\d{6})/ then sys.GoogleVoiceCall(GV_email,GV_pwd,SIPnum,"1#{ac}#{$1}",GV_nbr)   # 7 digits
     when /^311/ then sys.GoogleVoiceCall(GV_email,GV_pwd,SIPnum,"13127445000",GV_nbr)
   else
     sys.Log("Calls to #{req.URI.User} not allowed")
     sys.Respond(488, "Call not allowed")
   end
end
The strange thing is that incoming calls DO WORK; with a 206.XXX.XXXX caller id instead of the right one but they do come through.

After reading this thread I noticed that the same thing happened to LHM a while ago and I did the same thing recommended by Mike; A manual call was initiated from the GV website and then when I check the console this is the output:

Code: Select all

DialPlan 10:14:49:316: Forwarding incoming call for ossiemaracay@sipsorcery.com to 1 bindings.
NewCall 10:14:49:316: Executing script dial plan for call to sip:ossiemaracay@sipsorcery.com.
DialPlan 10:14:49:316: Commencing Dial with: ossiemaracay@sipsorcery.com.
DialPlan 10:14:49:363: Call leg is for local domain looking up bindings for ossiemaracay@sipsorcery.com for call leg ossiemaracay@sipsorcery.com.
DialPlan 10:14:49:378: 1 found for ossiemaracay@sipsorcery.com.
DialPlan 10:14:49:378: ForkCall commencing call leg to sip:ossiemaracay@72.153.28.125:5060.
DialPlan 10:14:49:378: Switching to sip:ossiemaracay@72.153.28.125:5060 via udp:127.0.0.1:5066.
DialPlan 10:14:49:378: SDP on UAC call had public IP not mangled, RTP socket 66.54.140.46:19050.
DialPlan 10:14:49:472: Information response 100 Trying for sip:ossiemaracay@72.153.28.125:5060.
DialPlan 10:14:49:566: Information response 180 Ringing for sip:ossiemaracay@72.153.28.125:5060.
DialPlan 10:14:49:566: UAS call progressing with Ringing.
DialPlan 10:15:49:582: Response 480 Temporarily not available for sip:ossiemaracay@72.153.28.125:5060.
DialPlan 10:15:50:019: Dial plan execution completed without answering and a last failure status of TemporarilyNotAvailable Temporarily not available.
DialPlan 10:15:50:019: UAS call failed with a response status of 480 and Temporarily not available.

Any ideas on what I am doing wrong?

Post Reply