We weren’t sure we would ever be writing this column. And, if it weren’t for @NAF of DSL Reports fame, it might very well have been years before a SIP-compatible version of Google Voice was available for Asterisk®. We really can’t overstate the scope and enormity of his accomplishment. If you look at NAF’s code additions to Asterisk, you’ll understand why. We would hasten to add that Bill Simon of Simonics was the pioneer in getting Google’s code to work with anything other than an OBiHai device, and the Simonics gateway remains a viable option for those that would prefer to let Bill babysit your Google Voice connections. With the Nerd Vittles coupon, it’s just $4.99 so it’s a terrific bargain with a one-minute setup.

July 20 NEWS FLASH: Google now has discontinued support of their XMPP interface to Google Voice so the latest CentOS/SL versions of Incredible PBX 13-13 (including the Incredible PBX ISO) now incorporate NAF’s GVSIP interface to Google Voice. You can read all about it here. What has changed is you now add Google Voice trunks from the command line by running /root/gvsip-naf/install-gvsip. You can delete trunks by running /root/gvsip-naf/del-trunk. Once one or more trunks have been added, they are numbered GVSIP1 through GVSIPn. Using the GUI, you then add an Outbound Route and an Inbound Route for each trunk. You’ll need both your Google Voice 10-digit phone number and a Refresh Token to add a new trunk. Please review the referenced GVSIP tutorial for the latest instructions.

That’s the good news. But the rest of the story is this isn’t quite production-ready at the moment, and we really need some folks to step up and do some testing. That’s what open source development is all about. We’ve built several dozen servers using our new GVSIP installation script, and everything "just works." The install script lets you load and reload NAF’s latest Google Voice components into Asterisk without having to start all over each time a new release is available. And we introduced an awesome cloud platform for this just last week. $10 a year buys you a terrific HiFormance VPS with a prebuilt Incredible PBX® 13-13 image that you can install in less than a minute and reinstall as many times as you like. So cough up your ten bucks and help us out. This HiFormance VPS running Incredible PBX 13-13 makes a perfect sandbox and also provides NAF with a consistent point of reference in his development efforts without injecting different operating systems and unique setups.

Once you have an Incredible PBX 13-13 server running under CentOS/SL 6 (only!), you’re ready to roll up your sleeves. Let’s briefly walk through the upgrade process for today. First, you’ll need a Google Voice OAuth 2 refresh token. If you have an existing Incredible PBX 13-13.3 server, you’ve already been through the drill. Just dig up your refresh token again making sure that you shut down your existing platform before we begin. If you’re upgrading in place, then you’ll need to delete your existing Google Voice XMPP credentials in the FreePBX® GUI and then restart Asterisk.

If you don’t yet have a Google Voice account or a refresh token, see the tutorial below to obtain one. Next, we’ll download an installation script to handle the GVSIP upgrades from NAF. You can run this script as often as you like, and it will remember your Google Voice credentials without having to reenter them. CentOS ships with an OpenSSL version from the stone age so the first time you run the installer, it will upgrade OpenSSL. Next, it upgrades Asterisk to version 13.21.1 after first applying NAF’s latest GVSIP patches. There are lots of them, but the install script will handle all of this for you. Finally, the script puts the dialplan pieces in place to activate your Google Voice trunk and set the inbound and outbound dialing rules. The first time you run the installer, you’ll be prompted for your GV credentials. After that, the prompts will be skipped unless you delete pjsip_custom.conf in /etc/asterisk. When the install finishes, you’re ready to try out some GV calls into and out of your server. By default, you place Google Voice calls by dialing the GV prefix (*48) followed by a 10-digit number, e.g. *48-NXXNXXXXXX. Inbound calls to your Google Voice number will be routed to the Demo IVR (3366). You can modify this setup as desired by following the customization instructions below once the install finishes. Your configuration will not get mangled by again running the installer to upgrade Asterisk’s GVSIP components.

WARNING: We have not yet tested this with CentOS 7 or on the Ubuntu platform. A separate Raspberry Pi installer now is available here. We are getting these installers out the door as quickly as possible so that others can participate in and enjoy the latest from Google Voice. There still has been no indication of whether Google plans to continue XMPP support or not. So time was of the essence to get a stable GVSIP platform just in case.

If you already have a Google Voice refresh_token that you plan to use, then you’re ready to proceed with the GVSIP upgrade. Otherwise, skip down to the Google Voice section of this tutorial to first obtain your credentials.

Deploying GVSIP with Incredible PBX 13-13

To upgrade your existing Incredible PBX 13-13 server to support GVSIP, start by logging into your server as root using SSH or Putty. Remember, if you are currently using the Google Voice number either on this server or another server, you must shut it down, uninstall it using the FreePBX GUI, and restart Asterisk before you begin the upgrade. If you have completed these steps, then simply issue the following commands to kick off the upgrade. Keep in mind that you will need your Google Voice refresh_token AND your Google Voice phone number during the install procedure. We want to repeat one final cautionary note. This is very new code. While it has been thoroughly tested, your particular platform might introduce new wrinkles we have not encountered. So make sure you have a good backup of your server before proceeding. One final heads up. NAF isn’t the only one improving his code. We’ve made at least a dozen changes to the scripts below in just the last 24 hours. So it’s a good idea to download the latest and greatest version before installing NAF’s GVSIP updates. To get the very latest versions of everything, it’s also a good idea to first delete /etc/asterisk/pjsip_custom.conf before running the installer again. This will assure that all of your dialplan code gets updated.

cd /root
wget http://incrediblepbx.com/gvsip-naf.tar.gz
tar zxvf gvsip-naf.tar.gz
rm -f gvsip-naf.tar.gz
cd gvsip-naf

When you finish the GVSIP upgrade process, your Legacy Google Voice profile in Settings will morph into something like this:

UPDATE #1: While initially you could leave both Google Chat and the so-called OBiTALK Device enabled, that appears to have changed in the last few hours. You now may need to disable Google Chat in Legacy Google Voice Settings:Phones before inbound calling will work.

UPDATE #2: We also are observing intermittent disruption of inbounding calling with Google messages that the number is not in service. Currently, there is no fix for this since it’s at Google’s end. We recommend that you whitelist obihai.telephony.goog using /root/add-fqdn just to eliminate the remote possibility that the IPtables firewall is disrupting these calls. To better monitor PJsip in the Asterisk CLI, issue the command: pjproject set log level 5

UPDATE #3: In troubleshooting the failed incoming calls issue, I tried a call from a different phone number. And, presto, the call went through. Apparently, making multiple calls of short duration from the same number gets you placed in Google’s spam bucket. By going into your Legacy Google Voice profile, you can turn Global Spam Filtering OFF in the Settings:Calls tab.

UPDATE #4: In our testing this past week, we’ve discovered that Google Voice usernames used for registration MUST be unique, or your connection will be disconnected when someone else attempts to register with the same username. For this reason, our latest installers generate a unique username based upon your Google Voice 10-digit phone number coupled with a random number. For this reason, inputting your Google Voice phone number now is mandatory.

UPDATE #5: A new installer is now available that supports two Google Voice trunks and (soon) many more. With the new configuration, 10-digit calls with the *GV prefix will be routed to the primary (first) trunk while 11-digit calls with the *GV prefix will be routed to the second trunk. Inbound calls from both trunks are still handled by the existing [from-external-custom] context.

Placing Test Calls with GVSIP

Once the install finishes, we recommend you reboot your server just to be safe. Then load the Asterisk CLI so you can watch what happens when you place and receive calls using your Google Voice number. To place outbound calls, you’ll need to set up a softphone and connect it to the default extension (701) on your PBX. Your extension 701 password was configured when you first installed Incredible PBX 13-13.

To place an outbound call, dial the GV prefix (*48) followed by a 10-digit phone number. To call into your Google Voice trunk, simply dial the 10-digit Google Voice number from a smartphone or some other phone outside your PBX.

Configuring a Softphone for Incredible PBX

We’re in the home stretch now. You can connect virtually any kind of telephone to your new PBX. SIP phones can be connected directly so long as they have an IP address. These could be hardware devices or software devices such as the YateClient softphone. We’ll start with a free one today so you can begin making calls. You can find dozens of recommendations for hardware-based SIP phones both on Nerd Vittles and the PIAF Forum when you’re ready to get serious about VoIP telephony.

We recommend YateClient which is free. Download it from here. Run YateClient once you’ve installed it and enter the credentials for the 701 extension on Incredible PBX. You’ll need the IP address of your server plus your extension 701 password. In the web GUI, choose Applications _> Extensions -> 701 and write down your SIP Password if you can’t remember it. Fill in the blanks on the YateClient using the IP address of your Server, 701 for your Username, and whatever Password you assigned to the extension when you installed Incredible PBX. Click OK to save your entries.

Once you are registered to extension 701, close the Account window. Then click on YATE’s Telephony Tab and place some test calls using the GV prefix.

If you are a Mac user, another great no-frills softphone is Telephone. Just download and install it from the Mac App Store.

Customizing GVSIP with Incredible PBX 13-13

For future reference, your refresh_token is stored in pjsip_custom.conf in /etc/asterisk. You can modify it to assign a new Google Voice number to your account. Then restart Asterisk. If you wish to reinstall the dialplan code on a subsequent running of the installer, you must first delete pjsip_custom.conf. Otherwise, the GVSIP dialplan code and your refresh_token are preserved.

You also can modify the Google Voice behavior for incoming and outgoing calls by editing extensions_custom.conf. At the top of the file, you’ll find the [from-internal-custom] context which controls outbound calling with your Google Voice trunk. If you would prefer to use a different dialing prefix for outgoing Google Voice calls, simply change *48 to the prefix desired in every line of the context. Then reload your Asterisk dialplan by issuing the following command: asterisk -rx "dialplan reload". Instructions also are provided in the context that will show you how to remove the dialing prefix completely if you’d prefer to simply place outbound calls by dialing 10-digit numbers.

To modify the Google Voice behavior for incoming calls, jump to the bottom of extensions_custom.conf. There you’ll find the [from-external-custom] context which controls the routing and processing of incoming calls to your Google Voice trunk. Several examples are provided. By default, the inbound calls are routed to the Demo IVR (3366). If your PBX has a Ring Group 777 and you’d prefer to send the calls there, simply change 3366 to 777. If you would prefer to send the calls to an extension, then comment out the Demo IVR line with a semicolon and uncomment the SIP/701 line while also replacing 701 with the extension desired. If you’d prefer to send incoming calls to a specific Asterisk application, an example is provided to route the calls to the NV Weather ZIP application. Then reload your Asterisk dialplan by issuing the following command: asterisk -rx "dialplan reload"

Configuring Google Voice with Incredible PBX

The advantage of Google Voice trunks for those of you in the United States is that all of your calls within the U.S. and Canada are free. You can’t beat the price, and it has worked reliably for many, many years but the XMPP version may disappear any day now. Here’s how to obtain a Google Voice number and a refresh_token for your Google Voice account.

Here are the steps to obtain a free Google Voice number:

1. Set up a dedicated Gmail and Google Voice account to use exclusively for this Google Voice setup on your PBX. Head over to the Google Voice site and register. You’ll need to provide a U.S. phone number to verify your account by either text message or phone call.

2. Once you have verified your account by entering your verification code, you’ll get a welcome message from Mr. Google. Click Continue to Google Voice.

3. Provide an existing U.S. phone number for verification. It can be the same one you used to set up your Google account in step #1.

4. Once your phone number has been verified, choose a DID in the area code of your choice.

Special Note: Google continues to tighten up on obtaining more than one Google Voice number from the same computer or the same IP address. If this is a problem for you, here’s a workaround. From your smartphone, install the Google Voice app from iPhone App Store or Google’s Play Store. Then open the app and login to your new Google account. Choose your new Google Voice number when prompted and provide a cell number with SMS as your callback number for verification. Once the number is verified, log out of Google Voice. Do NOT make any calls. Now head back to your PC’s browser and login to https://voice.google.com. You will be presented with the new Google Voice interface which does not include the Google Chat option. But fear not. At least for now there’s still a way to get there. After you have set up your new phone number and opened the Google Voice interface, click on the 3 vertical dots in the left sidebar (it’s labeled More). When it opens, click Legacy Google Voice in the sidebar. That will return you to the old UI. Now click on the Gear icon (upper right) and choose Settings. Make sure the Google Chat option is selected and disable forwarding calls to whatever default phone number you set up.

5. When your DID has been assigned, click the More icon at the bottom of the left column of the Google Voice desktop. Click Legacy Google Voice. Now click the Settings icon on your legacy Google Voice desktop. Make certain that Forward Calls to Google chat is checked and disable calls to your forwarding number. Click on the Calls tab and select Call Screening:OFF, CallerID (Incoming):Display Caller’s Number, and Global Spam Filtering:checked. The remaining entries should be blank.

6. Google Voice configuration is now complete. Sign out of your Google Voice account.

To use GVSIP, you also need to obtain an OAuth 2 refresh_token:

1. Be sure you are still logged into your Google Voice account. If not, log back in at https://voice.google.com.

2. In a separate browser tab, go to the Google OAUTH Playground using your browser while still logged into your Google Voice account.

3. Once logged in to Google OAUTH Playground, click on the Gear icon in upper right corner (as shown below).

  3a. Check the box: Use your own OAuth credentials
  3b. Enter Incredible PBX OAuth Client ID:


  3c. Enter Incredible PBX OAuth Client secret: 4ewzJaCx275clcT4i4Hfxqo2
  3d. Click Close

4. Click Step 1: Select and Authorize APIs (as shown below)

  4a. In OAUTH Scope field, enter: https://www.googleapis.com/auth/googletalk
  4b. Click Authorize APIs (blue) button.

5. Click Step 2: Exchange authorization code for tokens

  5a. Click Exchange authorization code for tokens (blue) button

  5b. When the tokens have been generated, Step 2 will close.

6. Reopen Step 2 and copy your Refresh_Token. This is the "password" you will need to enter when you run the GVsip installer below. Store this refresh_token in a safe place. Google doesn’t permanently store it!

7. Authorization tokens NEVER expire! If you ever need to remove your authorization tokens, go here and delete Incredible PBX Google Voice OAUTH entry by clicking on it and choosing DELETE option.

Switch back to your Gmail account and click on the Phone icon at the bottom of the window to place one test call. Once you successfully place a call, you can log out of Google Voice and Gmail.

Yes, this is a convoluted process. Setting up a secure computing environment often is. Just follow the steps and don’t skip any. It’s easy once you get the hang of it. And you’ll sleep better.

Continue reading for the latest developments…

Originally published: Monday, June 25, 2018

Support Issues. With any application as sophisticated as this one, you’re bound to have questions. Blog comments are a difficult place to address support issues although we welcome general comments about our articles and software. If you have particular support issues, we encourage you to get actively involved in the PBX in a Flash Forum. It’s the best Asterisk tech support site in the business, and it’s all free! Please have a look and post your support questions there. Unlike some forums, the PIAF Forum is extremely friendly and is supported by literally hundreds of Asterisk gurus and thousands of users just like you. You won’t have to wait long for an answer to your question.

Need help with Asterisk? Join our new MeWe Support Site.


Special Thanks to Our Generous Sponsors

FULL DISCLOSURE: RentPBX, Amazon, Skyetel, Vitelity, DigitalOcean, Vultr, Digium, Sangoma, 3CX, TelecomsXchange and others have provided financial support to Nerd Vittles and our open source projects through advertising, referral revenue, and/or merchandise. We’ve chosen these providers not the other way around. Our decisions are based upon their corporate reputation and the quality of their offerings and pricing. Our recommendations regarding technology are reached without regard to financial compensation except in situations in which comparable products at comparable pricing are available from multiple sources. In this limited case, we support our sponsors because our sponsors support us.

Skyetel $50 Free Trial: Enjoy state-of-the-art VoIP service with a $50 free trial and free number porting when you sign up for a Skyetel account. No restrictions on number of simultaneous calls, and triple data center redundancy assures that you never experience a failed call. Tutorial and sign up details available here.

Special Thanks to Vitelity. Vitelity is now Voyant Communications and has halted new registrations for the time being. Our special thanks to Vitelity for their unwavering financial support over many years and to the many Nerd Vittles readers who continue to enjoy the benefits of their service offerings. We will keep everyone posted on further developments.

RentPBX, a long-time partner and supporter of PIAF project, is offering generous discounts for Nerd Vittles readers. For all of your Incredible PBX hosting needs, sign up at www.RentPBX.com and use code NOGOTCHAS to get the special pricing. The code will lower the price to $14.99/month, originally $24.99/month. It’s less than 50¢/day.

Print Friendly, PDF & Email

Be Sociable, Share!

This article has 15 comments

  1. Simon’s gateway may have to close. He is having problems with the sip connections spawning threads to the point the server CPU can’t handle it.

    [WM: It’s certainly a setback, but I wouldn’t count Bill out just yet. He’s pulled magic out of his hat more than a few times.]

  2. Bill has announced he will shut the gateway down when Google terminates XMPP:
    "With regrets, I am announcing the discontinuation of Google Voice Gateway at the time when Google fully discontinues their XMPP interop"
    It was a good run. I switched over to Simon’s GVGW when my home PBX died. Work is being done on Asterisk so there will be individual solutions available.

  3. I got a email from him below is the email: Notice of Simon Telephonics Google Voice Gateway Discontinuation

    You may have read that in late April, Google announced that they will be discontinuing XMPP Interop with Google Voice. See our news posting at
    Since that time, we have worked on an updated Google Voice Gateway implementation that would allow us to connect to Google using their new SIP-based protocol.
    From late May to mid-June, we ran a beta test of this new software to find bugs and determined that it would be suitable for production.

    On Sunday, June 24, we attempted to put the new software into production. A serious problem was uncovered at this point related to the large number of
    accounts we are registering to Google Voice. On Tuesday, the system was rolled back and we studied the problem. Unfortunately, what we found was a very
    large increase of computing resources needed in order to support the new platform at production scale. We attempted some optimizations, but the problems
    are fundamental to the VoIP engine, and the resource requirements to run the new platform are not sustainable.

    With regrets, I am announcing the discontinuation of Google Voice Gateway at the time when Google fully discontinues their XMPP interop. This was slated
    to begin on June 18, so we expect that the remaining time is short–perhaps another week. Thank you to all of you who have supported this service over
    its 6+ year history.

    Accounts should be working at this time using the Google Chat (XMPP) connections. If you are not receiving calls, please see the post by me on this forum

    Users looking to continue service with Google Voice using regular phones should consider the Obihai 2xx, 10xx, and 2xxx series phones, or use the new Google
    Voice app for Android (wi-fi calling).

    Again, thank you for a good run with the Google Voice Gateway.

    Bill Simon

  4. How do you install multiple refresh tokens so that you can run multiple GV numbers on the PBX, all forwarded to different extensions so that you have different SIP logins?

    [WM: Not there yet. Stay tuned.

  5. I’m very happy to report that all works well with GV. The GVSIP installer and instructions are fantastic! Thanks to everyone who made this possible.

  6. This is all very interesting. My pbx server uses Asterisk 13 with a FreePBX front end and GoogleVoiceMotif, not PIAF. I’m wondering if GVSIP can be installed to this system without resorting to a full rebuild of Incredible 13-13. Is GVSIP specific to that platform? Thanks for all your work in this problem of XMPP going away at GV.

    [WM: Without knowing exactly how you built your server and its underlying Linux platform, it would be difficult to offer much encouragement. What I would suggest you do is look through the install script and then cut-and-paste and execute small sections of the code at a time. Then you can correct any problems which crop up. The most critical piece will be getting OpenSSL up to the 1.1 version: openssl version. After that, the Asterisk upgrade pieces of the script should work fine, and the new FreePBX contexts to support GVSIP should also be OK with a little tweaking of the [from-external-custom] context in gvsip_incoming.txt to support your extension setup. Good luck AND make a backup first. 🙂 ]

  7. I am receiving the following error running the GV script on top of a fresh install of IncrediblePBX 13-13

    make: warning: Clock skew detected. Your build may be incomplete.
    checking for bundled pjproject… make: Warning: File `/tmp/pjproject-2.7.2.tar.bz2′ has modification time 9.1e+03 s in the future
    make: Warning: File `/tmp/pjproject-2.7.2.tar.bz2′ has modification time 9.1e+03 s in the future.

    [WM: Your server’s hardware and system clocks are out of sync. This will cause Asterisk compiles to fail.]

  8. Thx Ward. The NTP service stopped on my ESXi host and my clock was out of sync. All good now.

  9. The only problem I was having is with early media and ring back. After some digging I discovered that it’s a known bug. I removed the ‘r’ option from the extensions_custom.conf file so calls no longer drop prematurely.
    From https://github.com/naf419/asterisk/wiki

    strange behavior with ringback tone / early media. dialing some numbers results in GV playing a ringback tone over the early media, whereas dialing other numbers results in a silent audio stream instead of ringing
    using the Dial ‘r’ option ignores the early media and replaces it with an out-of-band 180 Ringing message, but this results in GV terminating the call after ~20s with a 603 media inactivity

  10. Ward, is it recommend to keep NAF’s GVSIP updated on a regular base by rerunning the installation script? Thanks, Heiko

    [WM: Kinda depends although now is a good time to do a fresh install as we just uploaded the new installer supporting two GV trunks.]

  11. This is wonderful, Ward! I followed this guide and got GVSIP working on my system! Thank you so much for the hard work and dedication! Now, when will something like this be developed for PBX In a Flash (3CX)? 😉

  12. I got the latest today. It seems the patch file is not applying cleanly and some other errors. Is there a previous version (package) I can use that worked with two GV accounts?

    [WM: Patch file errors are nothing to worry about as long as GVSIP works when you’re finished.]

  13. I think it would be nice if when you made an edit to one of these pages. like edit #4 & #5, would to add a date to the edit. thanks for all of the wonderful effort towards this. Best regards.

    [WM: Great suggestion. All of these changes came within a few hours which was the reason for the lack of dates.]

  14. I just did an install of Incredible PBX lean from ISO on a Virtualbox. Towards end of installation flashing began making it impossible to read.

    I then installed the GVSIP and it hung up saying something about WARNING /tmp/PJSIP has a modification date in the future . It never moved on from this and kept flashing and generating the same line over and over.

    [WM: Sounds like the hardware clock and system clock on your computer are out of sync. Asterisk installs will fail if the time is not set correctly.]

  15. I believe using the aforementioned OAUTH client ID and client secret in step 3b & 3c creates a dependency on a google account other than the owner’s google voice account — which I am assuming is probably ObiHai’s. My guess this was intercepted during packet captures by reverse engineering those devices. Is this true? If this is the case then if they were to delete that client ID then all the users of IncrediblePBX with these instructions would no longer be able to use GV. If there is no dependency, then users should generate their own client ID & secret in the Google API console to minimize the risk of using someone else’s client ID.

    [WM: The OAuth client ID and secret are mine, not Obihai’s. It takes a matching OAuth client ID, OAuth secret, AND OAuth refresh token to log into any Google Voice account. We have offered our client ID and secret for use by Incredible PBX users for years to ease the pain of setting up secure OAuth connections using the randomly-generated, 50-character refresh_token which is known only by you. Our tutorial explains how to obtain the refresh token. Unless someone is good at guessing a password out of billions and billions of possibilities, security is not an issue. Multiply 50 to the 60th power to compute the odds of deciphering a refresh token. HINT: Winning the lottery would be much easier and considerably more profitable than attempting to use someone else’s free Google Voice account. To restate the obvious, our client ID and secret credentials aren’t going anywhere. Even assuming we were to pull such a stunt by deleting them, users would be no worse off than they would be by generating their own client ID and secret which can be done at any time. If you will sleep better using all three of your own credentials, by all means do so. Simply edit the install-gvsip script and replace our client ID and secret credentials with yours before adding your GVSIP trunks.]