Alternating GoogleVoice accounts

Catalog of dial plans
reraikes
Posts: 237
Joined: Thu Aug 13, 2009 10:15 pm

Post by reraikes » Wed Nov 25, 2009 9:33 pm

Mike,

A teeny tiny enhancement to your code...

From:

Code: Select all

2.times { |x| gvcall num,r+x }
To:

Code: Select all

GVaccounts.length.times { |x| gvcall num,r+x }
gets rid of the fixed iteration count and makes it dynamic based on the size of the GVaccounts table.

Ron

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

Post by MikeTelis » Thu Nov 26, 2009 5:22 am

Ron,

I deliberately made it fixed. Each attempt takes 10-15 seconds and, if you list of accounts is long, the wait time becomes unbearable. On the other hand, if 2 attempts fail, chances are that something is wrong with GoogleVoiceCall (for example, Google changed their interface, again) and further attempts will also fail.

Mike

synchron
Posts: 196
Joined: Fri Jun 26, 2009 5:39 am

Post by synchron » Thu Nov 26, 2009 6:58 pm

MikeTelis wrote:
Also, is there a way to add to the failover DP so that if GV is down/not working and it times out on every GV callback provider, it finally dials to a paid provider (i.e. Localphone)?
Of course there's a way! :) If sys.GoogleVoiceCall failed to connect the call it would return control to your dialplan. Then you can use sys.Dial to switch it over to a paid provider.
Hi Mike, you make it sound so easy. I added sys.Dial("Localphone") after the GVcall line and simulated a GVcallback failure but when it gets to the Localphone provider, I get a PSTN routing error. The console shows that the num reverts back to the number you dialed, not the processed num that supports 7/10 digit.

So, call only goes through if you dial full 11-digits.

Regards,

Synchron 8)

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

Post by MikeTelis » Thu Nov 26, 2009 8:48 pm

I understand nothing. Could you please show me what dialplan you're using? I have published quite a lot of them :)

The most intriguing part is that GoogleVoiceCall takes ENUM-formatted numbers (that is, 11-digit). I just can't understand how come GoogleVoiceCall works but your regular provider doesn't.

Anyway, show me the dialplan...

Update: I think I know what's wrong. Apparently you used something like:

sys.Dial('Provider')

or

sys.Dial("#{req.URI.User}@Provider")

Both commands will use req.URI.User as the number you wish to dial and and it's the way you entered it (7-digit, for example). ENUM-formatted number is in the num variable and therefore, you must use something like:

sys.Dial("#{num}@Provider")

synchron
Posts: 196
Joined: Fri Jun 26, 2009 5:39 am

Post by synchron » Thu Nov 26, 2009 11:07 pm

Thanks, that did the trick. It just didn't seem to be obvious to me that the num that was updated in the previous case statement would revert back to the original dialed number.

It is unclear to me the use of {}, dst, # , etc. and all this Ruby syntax. I tried figuring this out on my own but the help in sipsorcery really doesn't explain all this stuff. Is there a good Ruby cheat sheet w/examples on how/when to use this verbage?

Synchron 8)

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

Post by MikeTelis » Fri Nov 27, 2009 4:09 am

Sipsorcery help page explicitly states that dialplan applications description is incomplete. It takes some effort to create your own cheat sheet. Start with Ruby Dialplans thread. It refers to Programming Ruby book by Dave Thomas (also known as "The Pickaxe"), a must-read for every Ruby programmer.

Note that ${dst:n} is not a part of Ruby language. This syntax is processed by sys.Dial internally and therefore, good for sys.Dial calls only. If you try:

sys.Log("Dialing ${dst:2}")

it won't substitute ${dst:2} and it will appear "as is" in the console. There also are some incompatibilities between Ruby and C# stuff. That's why my rule of thumb is: "get a copy of C# string and do all your processing with this copy, not the original".

rmp25
Posts: 64
Joined: Tue Aug 18, 2009 4:45 pm

Post by rmp25 » Sun Nov 29, 2009 4:16 am

Mike,
you've got something you wanted and like always you want to make it even better.

I'm talking about cnam. I asked question about it in techsupport forum, but not getting result, may be because it was about sip-2-sip calls.

Aaron suggested to use "sys.SetFromHeader("Joe Bloggs", nil, nil)" in dialplan in order to get proper cnam for outgoing calls.

My thinking was that I can get "Display Name" from pap2t's line 1, so I've tested this code in many places of failover dialplan with "unknown name" still showing up, not my name.

Am I mistaken how this code should work in SS? And is it possible at all for cnam here?

Thanks.

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

Post by MikeTelis » Sun Nov 29, 2009 5:20 am

I'm not sure I can follow you. CNAM is a [paid] service that allows you to get caller's name along with (or instead of) the number. You can read more about it here. I think of CNAM as of something like Reverse Lookup.

SetFromHeader and fd, fu, fn options passed to sys.Dial change various "from" fields. The only difference between SetFromHeader and the options is that SetFromHeader is global while fd, fu, fn affect specific call leg (btw, they override SetFromHeader on that leg).

And finally, I'm totally confused, I can't understand why you asked about SetFromHeader in this thread. sys.GoogleVoiceCall does not use any of FromName, FromUser, FromHost because it does not send SIP request to initiate your call. Instead, it logins to GV website and initiates the call from there. GV is the one who ultimately places the call and therefore, caller ID comes from GV. As far as I know, Google always sends your GV number and this can't be changed.
Last edited by MikeTelis on Sun Nov 29, 2009 8:08 pm, edited 1 time in total.

rmp25
Posts: 64
Joined: Tue Aug 18, 2009 4:45 pm

Post by rmp25 » Sun Nov 29, 2009 7:15 pm

Thanks for clarifying that.

trav
Posts: 120
Joined: Tue Sep 08, 2009 8:34 pm

Post by trav » Wed Dec 02, 2009 2:37 am

hi all...i've been using a modified ver of the alt google accounts, where i want GV to dial in a certain order, instead of randomized (b/c gizmo has been less reliable, so it's on the bottom of the list). my plan worked ok until google added params, and i was wondering what i was doing wrong:

i setup an array, but added a label parameter in the [0] position, which i use for logging purposes to show explicitly which voip branch was used:

Code: Select all

GVaccounts = [
  ["Sipgate",GV_email,GV_pwd,SIPnumSG,GV_num,'.*',1,10],
  ["Gizmo",GV_email,GV_pwd,SIPnumG5,'.*',7,10]
]
then i use this bit for the actual call

Code: Select all

def googleVoice(acnt)
  a = GVaccounts[acnt]      # fetch params
  sys.Log("*** Calling GOOGLEVOICE USING #{a[0]} ***")
  sys.GoogleVoiceCall(*((a[1,3] << @num) + a[4,4]))
end
but when i dial, i get a Error: can't convert String into Fixnum. i think it's because i'm mucking up strings and integers, but not sure. i'm trying to understand how ".*" is being used for now, and i think my array syntax on the sys.GVC call is off. thanks for your help!

Post Reply