Sipsorcery for no XMPP calling with Google Voice

Started by giqcass, December 12, 2013, 03:14:40 AM

Previous topic - Next topic

giqcass

I still have a free Sipsorcery account so I decided to do a little testing tonight.  Any ATA including the Obi can be used with Sipsorcery to make and receive free Google Voice Calls.  Sipsorcery does not use XMPP so it should continue to work just fine after XMPP is shut off. Unfortunately free accounts with them don't appear to be available right now.  Paid accounts start at $69 per year flat rate. That averages out to $5.75 per month.  Since you can use sipsorcery to set up multiple Google voice accounts at no additional charge this can be a good deal.  The Sipsorcery account need not be used with a single ATA so one account could be used by you at home, at work, and one at your sisters house.  All of the ATA devices could use different phone numbers if you like or they could all use the same phone number.  Soft-phones can also be used with Sipsorcery so you could use your Android or Iphone with Sip to save minutes on your cell phone plan.  In my tests tonight I added Sipsorcery as a Gateway to my OBi.  Inbound calls do not need to be routed through Sipsorcery but if you choose to do so they will ring as normal.  Outbound calls work as normal accept you will hear one extra ring before the called party hears their 1st ring. 

Sipsorcery seems to work just as well for me today as it did the first time I used it years ago.  All updates are made on the Sipsorcery system so firmware updates are not needed if something breaks. You must enter your Google Voice credentials on their website in order to use their system with Google Voice. Sound quality is as good for me as it is on my Obi with the current Obi Google Voice calls.  Multiple calling routes are supported. 

There is no limit on the number of Google Voice accounts you can add to once Sipsorcery account but it appears only 3 Google Voice outbound calls can be made at the same time with the $69 plan.  For instance if you had 5 Google Voice accounts set up 3 of them could be making calls well 2 of them are taking calls all at the same time.  The math looks like this if you look at it on a per account basis.
1 Google Voice accoint=$5.75 per month.
2 Google Voice accoints=$2.87 per month.
3 Google Voice accoints=$1.91 per month.
4 Google Voice accoints=$1.43 per month.
5 Google Voice accoints=$1.15 per month.


On a side note Sipsorcery could be used as a backup route in case your Obi fails to register with Google Voice by using trunk groups.
Long live our new ObiLords!

AntonS

This sounds very interesting. As it turns out I still have a free (never used) sip sorcery account! Can you elaborate a little more how to set this up. I understand how to create the voice gateway and I read on Sipsorcery how to add Google Voice for outgoing calls, but don't follow all the instructions over there quite. Moreover how do I modify my Obi110 to use this. Currently I have Google Voice as Sp1 and Callcentric with a free DID on Sp2 and my Callcentric number is a forwarding phone number for Google Voice (from Sipsorcery's documentation I understand that this is all necessary). What else do I need to do on the Obi? I assume modifying the outbound call route, but how. What complicates things a little that I already use a voice gateway for my 800 numbers to avoid Google Voice's problems with some 800 numbers. I also did not quite understand what I have to on Sipsorcery's side. Any details would be appreciated.

giqcass

#2
Use the Silverlight gateway on Sipsorcery to do the following steps.
Step 1
Create a ruby dial plan named default on Sipsorcery.  Paste the following.

case req.URI.User
 when /^00/ then sys.Dial("cheapintlcalls")
 else sys.Dial("MyGoogleVoice")
end


Step 2
Add a Sip provider named MyGoogleVoice
Select Google Voice.
Enter your full email Google Voice email address as the user name.
Enter your Google Voice Password. 2-step verification must not be turned on.  App specific passwords won't work.
Enter your Callcentric number as the callback number.
Select Home for the phone type.

Step 3
Create a sip account.  This is the sip account you will use on you obi. Out dial plan = default.

Step 4
Go to callcentric and create this call treatment.  
Call coming from Caller ID:
This number: = your google voice number
Redirect call to:One destination
This number:= yousipaccount@sipsorcery.com The sip account you created in step 3.

Step 5
Set up a Gateway on your Obi.            
AccessNumber = SP2(sipsorcery.com)
AuthUserID = The Sipsorcery user name the part before the @ sign in the sip address from step 3
AuthPassword = The Sipsorcery password for the sip account in step 3

Step 6
Set up a dial plan on your Obi to make use of the Gateway in whatever fashion you plan to use it. Do you want to use it as a backup? as you primary? As a fallback?

Outgoing calls using the Gateway go through Sipsorcery.
Incoming calls bypass Sipsorcery entirely.


If you want to use it as a failover you will need to create a trunk Group.
Trunk Group 1 = SP1,VGx   where x = the Gateway you set up for Sip sorcery.
I don't know what your current dial plan looks like but you would replace sp1() with TG1() in your outbound plan.

With the Above setup if Callcentric went down Sipsorcery would not work.  An alternative would be to use an IPkall number as a Google Voice forwarding phone.  In Google Voice you would leave it unchecked and on the IpKall website you would forward directly to the sipsorcery sip account listed in step 3.

If anyone sees any errors let me know.  I was very frustrated writing this because I accidentally closed the tab the first time I wrote it and I lost the whole thing.   :'(
Long live our new ObiLords!

azrobert

#3
This is another solution. I was very busy today and worked on this off and on since this morning, so I have to post it.

SipSorcery

Create a Dialplan named dialplan
Anything after "#" is a comment

#Ruby # DialPlan
if sys.In                                                                                    #   IN DIALPLAN STARTS
  CID = req.Header.From.FromURI.User
  CID = "#{$1}" if CID =~ /^1?(\d{10})$/                            #   Remove leading "1"
  CallerName = req.Header.From.FromName
  sys.Dial("user1@local[fu=#{CID},fd=#{CallerName}]",30)

else                                                                                          #   OUT DIALPLAN STARTS
 UserID="#{req.Header.From.FromURI.User}"
 dialnum="#{req.URI.User}"
 sys.Log("Phone Number #{dialnum}")
 dialnum.insert(0,"480") if dialnum =~ /^\d{7}$/           #   7 digit Domestic (480=area code)
 if dialnum.match /^(1?[2-9]\d{9}$)/                                #   Domestic - GV Callcentric
    sys.GoogleVoiceCall("GVuserID", "password", "12121234567", "#{$1}", ".*", 1, 20)
#  GVuserID without @gmail,com
# 12121234567 = Callcentric DID
# Next to last parm = GV forwarding DID type. 1=Home, 2=Mobile, 3=Work
  else
    sys.Respond(400,"Invalid Call")
 end
end


Create a SIP Account:
Username = User1
Password = password
In & Out Dial Plan = dialplan

Define Callcentric as a SIP Provider:
Use your Callcentric credentials
Register Contact will be automatically defined by SipSorcery after save.

OBi110

Define Voice Gateway 2:
Name = SipSorcery
AccessNumber = sp2(sipsorcery.com)
DigitMap = (<2:>xxxxxxxxxx|<2:>xxxxxxx)
AuthUserID = user1
AuthPassword = password

Add to Phone Port Digit Map:
2xxxxxxxxxx|2xxxxxxx

Add to Phone Port OutboundCallRoute:
{(Mvg2):vg2}

Dial 24805551212 or 25551212

None of the above was tested.
I cut and pasted pieces of a more complex working dial plan to create the above.

When GV stops working with the OBi do following:
Delete GV, Callcentric and Voice Gateway 2 from the OBi.
Use SP1 to register to user1 at SipSorcery.

giqcass

It should be noted that Sipsorcery allows you to use your Google Voice contacts for incoming caller Id.  I have not set that up so for the moment I can't help with that feature.  The post by azrobert  shows that dial plans can be more complex then the one I posted.  There are many advanced features available to Sipsorcery users.
Long live our new ObiLords!

azrobert

#5
Quote from: giqcass on December 13, 2013, 10:03:57 PM
It should be noted that Sipsorcery allows you to use your Google Voice contacts for incoming caller Id.

You can also setup your own cname table in the dialplan.
It's been a long time since I did this, but I think you need a "begin" between the table and the code and an extra "end" at the end of the code. You can get into trouble if you don't get a match and callername ends up with a null value. That is why I set it to "unknown".

TNAME = {
 '4801111111' => 'Dad',
 '4802222222' => 'Sister',
 '6023333333' => 'Brother'  }

begin

callername = "unknown"
callername = TNAME[CID]

end

AntonS

I have some questions about the sip sorcery dial plan. Currently I use Google Voice also for my international calls. In giqcass's dial plan I assume I can simplify his dial plan, but what is the simplest way. In azrobert's dial plan I am not sure it will handle international calls as listed and I do not understand the role of the 480 area code. Do I change that to my area code and does it handle international calls via Google voice?
Thanks for these explanations, I feel that I am close to implementing this, initially maybe as a fall back.

azrobert

#7
"480" is your local area code. The command inserts "480" to the beginning of a 7 digit dialed number. You could do this function in the OBi.

Here is an updated dial plan and OBi changes including international numbers:

#Ruby # DialPlan
if sys.In                                                            #   IN DIALPLAN STARTS
  CID = req.Header.From.FromURI.User
  CID = "#{$1}" if CID =~ /^1?(\d{10})$/                            #   Remove leading "1"
  CallerName = req.Header.From.FromName
  sys.Dial("user1@local[fu=#{CID},fd=#{CallerName}]",30)

else                                                                #   OUT DIALPLAN STARTS
 UserID="#{req.Header.From.FromURI.User}"
 dialnum="#{req.URI.User}"
 sys.Log("Phone Number #{dialnum}")
 dialnum.insert(0,"480") if dialnum =~ /^\d{7}$/                    #   7 digit Domestic (480=area code)
 if dialnum.match /^1?[2-9]\d{9}$/ or                               #   GV-Callcentric
    dialnum[0,3].match /^011$/
    sys.GoogleVoiceCall("GVuserID", "password", "12121234567", "#{dialnum}", ".*", 1, 20)
# GVuserID without @gmail.com
# 12121234567 = Callcentric DID
# Next to last parm = GV forwarding DID type. 1=Home, 2=Mobile, 3=Work
  else
    sys.Respond(400,"Invalid Call")
 end
end


OBi110

Define Voice Gateway 2:
Name = SipSorcery
AccessNumber = sp2(sipsorcery.com)
DigitMap = (<2:>xxxxxxxxxx|<2:>xxxxxxx|<2:>011xx.)
AuthUserID = user1
AuthPassword = password

Add to Phone Port Digit Map:
2xxxxxxxxxx|2xxxxxxx|2011xx.

Add to Phone Port OutboundCallRoute:
{(Mvg2):vg2}

Dial 24805551212, 25551212 or 2011xx.

AntonS

I tried this, but I get immediately a busy call when dialing my cell phone, while I know the number is not busy (my cell phone is right next to me). I get a busy call after two rings when I call my office phone number. When looking at the OBI Call history page it shows that the cell phone call  never connected, while my office phone was connected for 8 seconds. A few details I guessed at:
When creating the sip provider account for call centric on the Silverlight page it asks me for the username. I tried using both my Callcentric login username and the 1777xxxxxxx number. I also entered callcentric.com as server, which was updated to sip:callcentric.com and I ticked the Register button. The register contact got populated by my callcentric username@callcentric.com
Is this all correct? The Sip provider registry part is populated and seems correct to me.
I must say that I have no clue what is wrong. Any hints?

giqcass

If you were following my instructions and you added Callcentric as a Sip Provider in the Sipsorcery silverlight portal.  Thats problem number 1.  It can work that way but why don't we try to see what else is different.

Why don't you go to the silverlight portal and see what errors you are getting for the calls.  Click the calls tab and tell me what you see.
Long live our new ObiLords!

AntonS

I was using azrobert's method. Tonight I'll try your method and see whether that works. I was wondering whether the different behavior could be caused by the fact that my cell phone is a Google Voice forwarding phone and my work phone is not.

azrobert

I just setup my Callcentric account as a provider using the 1777 number.
The Register Contact should be sip:username@sipsorcery.com
username is your SipSorcery account name.
Don't know why it's showing your Callcentric username.
Does SIP Provider Registrations show you are registered to Callcentric and what is Contact?

You can click on the Console Tab, then click Connect.
The console will show all activity including any dial plan syntax errors.

AntonS

@azrobert
I mistakenly wrote my call centric user name, in fact it shows exactly like you wrote.
SIP Provider Registrations shows registered with contact replacing my real username by username: sip:username@sipsorcery.com;rinstance=MHYTBD
When I clicked on console it showed:
Monitor 21:37:40:172: basetype=console, ipaddress=*, user=username, event=*, request=*, serveripaddress=*, server=*, regex=.*.
Do I watch the console while trying to make call? If so, it will have to wait until I am home.

azrobert

Yes, you need to make a call.

As I said before I created the dial plan with several cut and pastes plus some mods, so it's very likely I made a mistake.

AntonS

@azrobert
I tried making a call. Now I got the female Google Voice message saying that it could not complete the call. Please try again. The console on Sipsorcery did not change at all, so it seems that the call never reached sipsorcery. The insole did show a successful registration with Callcentric:
ContactRegisterInProgress 02:10:33:472 sip1(1740): Sending initial register for xxxxxx and Callcentric to udp:204.11.192.163:5080.
ContactRegisterInProgress 02:10:33:472 sip1(1740): Initiating registration for xxxxxx on sip:callcentric.com.
ContactRegistered 02:10:33:550 sip1(1740): Contact successfully registered for xxxxxx on sip:callcentric.com, expiry 64s.

I have to check my OBI configuration. Does it matter where I add the items for the Phone port (i.e. any place  in the PortDigitMap and  Phone Port OutboundCallRoute).

azrobert

I think the call is being routed out SP1.
The default ITSP A DigitMap contains the rule "xx." which will match the dialed number and route the call out SP1.
Add "{(Mvg2):vg2}" at the beginning of the Phone Port OutboundCallRoute.
It doesn't matter where the DigitMap rule is placed.

AntonS

I already suspected that my OutboundCallRoute was not correct and was planning to add the "{(Mvg2):vg2} to it. I did and now it seems to work. One question: should the call not show up as an inbound call on the Callcentric webpage? I looked and it was not listed.

azrobert

Yes, the call should be posted on Callcentric.
Are you sure the call is going to SipSorcery?
Can you see it in the SipSorcery console or Call history?

azrobert

Anybody with a smartphone can use this setup to make and receive GV calls. Install a softphone and register it to SipSorcery using the same credentials as VG2.

AntonS

My guess is that it does not go to Sipsorcery. I am wondering whether the digit map in the ITSP Profile for Callcentric is the problem. I have:
(*xx.|**275*x.|[3469]11|1xxxxxxxxxx|<1>[2-9]xxxxxxxxx|011xx.|xx.|(Mipd)|[^*#]@@.)
Would this digit map cause the number to out over Sp1 (my default outgoing service)?