How to make and receive calls using Google Voice without XMPP (May 2018 Revision)

I.    Introduction

In Spring 2014, I wrote the original blog post “How to make and receive calls using Google Voice without XMPP” as it was likely Google was going to drop XMPP protocol in May 2014.   The post attracted a lot of interest at that time.  It received over 5000 visits.  However, since Google eventually did not abandon XMPP, the blog was not very useful anymore.

Recently, it was announced that Google is going to drop XMPP from Google Voice on June 17, 2018 and it looks more likely to happen this time.  People have started looking into the possibility of using Google Voice without XMPP again [1][2].

Due to the renewed interest, I tried the method described in my previous blog.  It was found that the original approach still works after some necessary updates based on what described in [1].  The difference between my installation and that described in [1] and [2] is that mine is based on plain Debian/Ubuntu while theirs are build on top of Freepbx.  The approach implemented in plain Linux may be less flexible and versatile than the ones based on Freepbx.  However, it should function fine.  Moreover, the description in this revised blog uses a steps-by-step approach, which should be easier to follow if you want to try it out from ground zero.

The platform of my implementation utilizes Linux (Debian/Ubuntu) operating system.  You can use a stand-alone small ARM based box, such as Raspberry Pi or a similar one, or on an online virtual personal server (VPS).  I tried both.  and they all work pretty well.  The ARM box I used is an Orange Pi PC, although the procedure described below should be valid without modification for any similar ARM Debian box.  It also works on a VPS with some minor changes that I will state later.

To keep the implementation effort to be minimal, only the basic system with call-out and incoming call functionalities are implemented.  With some knowledge of Asterisk, the system functionalities can be expanded as much as you like.

Now, let us begin!

II.    The step-by-step guide of setting up an Asterisk PBX with GV callback.

A.    Get a DID number

To make Google Voice work without XMPP, you will need a telephone number to receive calls, i.e. a DID (Direct Inward Dialing) route.   There may be different ways to obtain DID numbers.  However, the most viable solution is to apply a free DID number from CallCentric.com.  What you need to do are as follows:

  1. Register an account on the CallCentric website.  It is straight forward and free.
  2. Once you confirmed on your email and the account is active, you will be assigned a Callcentric number in the form of 1777XXXXXXX.  You can find the number once you login under the Dashboard subtab.   Note: This number is your SIP user name to be denoted as [sipusername] but is different from your Callcentric website login user name.
  3. Under the Receive Calls Tab, request a free phone number by clicking the “get a number” button.
  4. In the left most column, filling the necessary information and click the Lookup button to go to next page.
  5. Select an area code, click “Order Now” button, and continue on next a few steps, an number will be assigned to you.  Once this step is done, you can find the number under Dashboard/DID number section.  Note that all of the DID number have the area codes in the NY state.  However, any of these will work for this purpose with no difference.  We will denote the 10 digit DID number by [didnumber] below.
  6. Click the edit button at the left of the item “Reference/Phone Password (SIP Password)” to specify the SIP Password, denoted as [sippassword] below.

Now you have all the DID information that you need to continue.

B.    Setup Asterisk and preliminary configuration

In your platform, either it be a Debian box or a VPS running Debian or Ubuntu, you need first to install Asterisk.  You can do so by different methods although the easiest way is probably using the Asterisk package come with the Linux distribution.  To install it use this approach, you simply SSH into your Linux box or VPS and do the following under the Linux # prompt:

apt-get update
apt-get upgrade
apt-get install asterisk

After Asterisk is installed, replacing two default Asterisk conf files, sip.conf and extensions.conf in the /etc/asterisk/ directory with the examples of the files given in the appendices.  You will need to insert your own DID and SIP credentials into the proper place inside these two files.  The Asterisk PBX is set as to have three extensions: 201, 202 and 203.  Any SIP phone, which can be a softphone or a hardware ATA (Analog Telephone Adapter) connected with a regular phone, registered with one of the extensions can make or receive calls.  If there are incoming calls to your GV number or the DID number, the SIP phones registered will ring until one of them is picked up.

In the sip.conf file, there is a register statement and a section [DID] related to the DID.  It is necessary to make sure the DID/SIP credentials obtained from CallCentric.com is filled into the proper places in the register statement and the DID section.

Once all these are done, restart the Asterisk by doing a “service asterisk restart” in an SSH terminal connected to the Debian box.  Then, type “asterisk –rvvv” to get to its CLI interface.  Inside the CLI interface, type “sip show registry” and hit return.  It should show you that your SIP service is registered.  You can also do a “sip show peers” to see if the SIP phone is properly registered.

If everything looks normal, you can make a call from another phone to CallCentric’s DID.  Your SIP phone registered to Asterisk should ring and can be picked up to talk to the caller’s phone.

C.    Set up Google Voice (GV) and callback number.

  1. Go to www.gmail.com and create a gmail account with gvusername and gvpassword.
  2.  Once the gmail account is established, go to www.google.com/voice and apply for a new GV number (gvnumber), if you don’t have one already.
  3. In www.google.com/voice webpage click the three vertical dots on the upper left corner and then click Legacy Google Voice.
  4. Click at the gear symbol on the right and select settings.
  5. In the Settings menu, disable call screening in the Calls submenu.  Note that you need enable voicemail in order to have call screening disabled.
  6.  In the Phone submenu click on “add a phone” botton and use the [didnumber] that you got from Callcentric as this number.  Google will try to verify that you have this number.  Request them to call this DID number instead of sending SMS, and you will need to have a SIP phone connected to the Asterisk server as described above to receive the call.  Verify the number with GV.  The DID number [didnumber] is your GV call back number.
  7. Make a call to the assigned gvnumber, your SIP phone connected to Asterisk server should ring and can receive the call.

D.    Install Python and pygooglevoice

Based on the information given in [1], you can do the following to install pygooglevoice under the Linux prompt on the terminal connected to the Debian box:

cd /root
apt-get -y install mercurial
apt-get -y install python-pip
pip install distribute --upgrade
easy_install -U setuptools
easy_install simplejson
wget https://www.dslreports.com/r0/download/2354351~587bc8e1b0f7c34f1e3536cb3a55473a/pygooglevoice.tar.gz
tar xfz /root/pygooglevoice.tar.gz
cd /root/pygooglevoice
python setup.py install
cp /root/pygooglevoice/bin/gvoice /usr/bin/
cd /root

After pygooglevoice is installed, it can used to make a test phone call by entering:

gvoice -b -e [gvusername]@gmail.com -p [gvpassword]call ${EXTEN} +1[didnumber] 1 

Note it is done at the Linux prompt, not the Asterisk CLI.   If successful, you can use the SIP phone connected to the Asterisk server picking up the call.

In a number of cases, I found that the first attempt for making such a call may not work.  It is because GV may determined that the call is from an unknown device and would reject it.   In such cases, you need to first check the security setting of the gmail account used to make sure that login from less secure devices is allowed.  Secondly, using your PC browser to open the link “https://accounts.google.com/b/0/DisplayUnlockCaptcha” with the same gmail account logged in, and click the “Continue” button to allow access.

After performing these two steps, you should be able to make phone call using the gvoice command.  However, sometimes, you may need to repeat the second step until you can make the call successfully.

E.    Final Steps

Once the call using pygooglevoice from Debian is successful, you only need to fill [gvusername], [gvpassword] and [didnumber] the proper credentials in the lines of

System(gvoice -b -e [gvusername]@gmail.com -p [gvpassword] call ${EXTEN} +1[didnumber] 1 &)

and

System(gvoice -b -e [gvusername]@gmail.com -p [gvpassword] cancel &)

in file extensions.conf.  Then, you can make a call from the SIP phone connected to the Asterisk server and it should work.

A final note, if you decided to install the Asterisk on an VPS, you need to add two lines:


externhost=[VPS' dynamic IP address]
localnet=[VPS' locanet address (xxx.xxx.xxx.0)]/255.255.255.0

in the [general] section of sip.conf to avoid the one way audio problem.

Good Luck!

III.    Acknowledgements and Disclaimers

First the acknowledgement: I am not a network/software/VOIP person.  All of what I did are based the knowledge that I gained from Googling and exchanging with other more experienced people.  Thus, nothing described in this note is invented by myself.  All the credit should go to the people who proposed this approach and worked out the details, specifically, the authors, commenters and contributors of the references [1,2] of this blog.  What I did is just to make sure all of details that I described are correct and to verify it indeed works.  I would appreciate to have your feedback and comments.  If you have any questions, please let me know also.  I will try to answer them as much as I can.

Now the disclaimer: As stated above, what I did is simply trying the GV callback approach designed and described by others.  It is experimental to say the most.  As we all know, whenever one goes online including performing VOIP activities, there are always security risks.  Thus, if you decide to follow what described in this blog, you should know the risks involved and you will be responsible for whatever action you are taken.  You will be responsible for any consequences of your actions. Another point is that we don’t know what Google is going to do after June 17.  Even though the set-up following the above descriptions works today, there’s no guarantee it will work at that time.  We just have to hope it will.

[1] RonR’s post in “Google Voice XMPP support will go away in June” on DSLReport Forum (https://www.dslreports.com/forum/r31938501-Google-Voice-XMPP-support-will-go-away-in-June).

[2] How to use Google Voice with FreePBX and Asterisk without using XMPP or buying new hardware, TechNotes. (https://tech.iprock.com/?p=21950)

IV.    Appendix

The configure files: sip.conf (source)
[general]
context=phone ; Default context for incoming calls
allowoverlap=no ; Disable overlap dialing support. (Default is yes)
bindport=5060 ; UDP Port to bind to (SIP standard port is 5060)
externrefresh=60
localnet=192.168.1.0/255.255.255.0
udpbindaddr=0.0.0.0; IP address to bind to (0.0.0.0 binds to all)
srvlookup=yes ; Enable DNS SRV lookups on outbound calls
canreinvite=no
dtmfmode = rfc2833
tcpenable=no
;directmedia=yes
register = [sipusername]:[sippassword]@callcentric.com:5060/[sipusername]
session-timers=refuse
disallow=all
allow=ulaw
allow=gsm

[201]
defaultuser=201
secret=[secret1]
type=peer
callerid="user1 "
host=dynamic
context=phone
outgoinglimit=1
incominglimit=1
canreinvite=no
nat=force_rport,comedia
qualify=yes

[202]
defaultuser=202
secret=[secret2]
type=peer
callerid="user2 "
host=dynamic
context=phone
outgoinglimit=1
incominglimit=1
canreinvite=no
nat=force_rport,comedia
qualify=yes

[203]
defaultuser=203
secret=[secret3]
type=peer
callerid="user3 "
host=dynamic
context=phone
outgoinglimit=1
incominglimit=1
canreinvite=no
nat=force_rport,comedia
qualify=yes

[DID]
context=sip
defaultuser=[sipusername]
type=peer
secret=[sippassword]
host=callcentric.com
fromdomain=callcentric.com
fromuser=[sipusername]
trustrpid = yes
sendrpid = yes
canreinvite = no
insecure=port,invite
nat=force_rport,comedia

extensions.conf (source)

[general]
static=no
writeprotect=no
autofallthrough=yes
clearglobalvars=yes
priorityjumping=no

[globals]
gtimeout=50 ; timeout value
; initialize
gvuser=10000

[sip]
exten = _[sipusername],1,ExecIf($[${gvuser}!=10000]?Bridge(${gvuser}):Dial(SIP/201&SIP/202&SIP/203,60,D(:1)))
exten = _[sipusername],n, Set(GLOBAL(gvuser)=10000)
exten = _[sipusername], n, Hangup()
[phone]
include = sip
include = gv-outbound
[gv-outbound]
exten = _NXXNXXXXXX,1,GoTo(1${EXTEN},1)
exten = _1NXXNXXXXXX,1,Answer
exten = _1NXXNXXXXXX,n,Set(GLOBAL(gvuser)=${CHANNEL})
exten = _1NXXNXXXXXX,n,System(gvoice -b -e [gvusername]@gmail.com -p [gvpassword] call ${EXTEN} +1[didnumber] 1 &)
exten = _1NXXNXXXXXX,n,Ringing
exten = _1NXXNXXXXXX,n,Wait(30)
exten = _X.,n,Noop(Never received callback from Google Voice on channel ${gvuser} . exiting)
exten = h,1,GotoIf($["${CHANNEL(state)}" = "Ring"]?:bridged)
exten = h,n,Noop(Hangup on channel ${gvuser})
exten = h,n,System(gvoice -b -e [gvusername]@gmail.com -p [gvpassword] cancel &)
exten = h,n, Set(GLOBAL(gvuser)=10000)
exten = h,n,Hangup()
exten = h,n(bridged),Noop(The channel has been bridged successfully)
exten = h,n, Set(GLOBAL(gvuser)=10000)
Advertisements

5 thoughts on “How to make and receive calls using Google Voice without XMPP (May 2018 Revision)

  1. Pingback: How to use Google Voice with FreePBX and Asterisk without using XMPP or buying new hardware | TechNotes

  2. Hi, i am trying to follow these instructions on Fedora 28. I noticed there is no `sip.conf` but there are plenty of other conf files. Is there some modification to get going on fedora? perhaps there is a docker image for all of this somewhere?

    • Thank you for pointing out. The address is still correct. Somehow, it now requires https:// instead of http://
      I have revised the post so please try to see if it works now.
      Good Luck!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s