Home » Incredible PBX » VoIPtopia: Google Services with Incredible PBX and PIAF5

The Most Versatile VoIP Provider: FREE PORTING

VoIPtopia: Google Services with Incredible PBX and PIAF5

Lips from Google It’s been a while since we provided a fresh look at Google Voice, Google SMS messaging, and Google’s Speech Recognition labyrinth which have been integral components of Incredible PBX for many years. For those living in the United States, here’s a soup-to-nuts tutorial to get all of the services deployed quickly on any Incredible PBX platform including XiVO and Elastix as well as on the new freeware releases of Ombutel and PBX in a Flash 5 powered by 3CX. On most of the platforms, you can deploy Google Voice services directly; however, with PIAF5, Elastix, and Ombutel you’ll need to set up a SIP trunk using the Simonics SIP to Google Voice gateway to take advantage of free calling in the U.S. and Canada with Google Voice.

Implementing Google Voice with Incredible PBX

Before you can obtain Google Voice service to make free calls in the U.S. and Canada, you’ll need several things: (1) a Google account, (2) access to a computer with an IP address in the United States, and (3) a U.S. phone number to verify your residence for Google Voice.

To get started, sign up for a Gmail account here:

Once your Gmail account is created, click Allow and then Allow and Remember when prompted whether to Allow Gmail to run "Google Talk."

In a separate tab of the same browser, go to Google Voice to sign up for an account. Begin by choosing whether to obtain a new phone number for Google Voice or whether you wish to use an existing mobile phone number that you already own. Next, choose a forwarding phone number which will ring when your Google Voice number is called. NOTE: You do not need to keep this activated on your account once it is completely set up. Be advised that Google also plays games with certain phone numbers such as pretending to ring them when, in fact, they haven’t placed a verification call at all. This usually is because of prior abuse of the number with the Google Voice service or because you’ve gotten greedy and signed up for too many free numbers. If a number doesn’t work for verification, you’ll need to choose another number. And it’s usually a good idea to create additional Google Voice accounts from different IP addresses. Once you complete the verification step, you can choose a phone number in an area code of your choice. Same thing holds for picking phone numbers. If you get error messages saying to "try later," what Google is really telling you is you’re a greedy bastard. Set up additional Google Voice numbers from a different computer using a different IP address and chances are the problem will go away. It did for us. 😉

Once you have your new Google Voice number, Google will drop you into the Voice Inbox. Ignore offers to activate, enable, or do anything else with Hangouts. Otherwise, you may kill the ability to use your new Google Voice number with Asterisk®.

Click on the Settings Gear icon in the upper-right corner of the window. In the Phones tab, make certain that (1) Google Chat is enabled and (2) your forwarding phone number is disabled:

In the Calls tab, make it look like this for proper Google Voice operation with Asterisk:

You now have a basic Google Voice setup on the Google side to support Asterisk calling. But the default setup uses plain-text passwords for your Google Voice account, and this is not only a security issue, but it also will cause problems if you move your Google Voice account to a different computer. For that reason, we strongly recommend setting up OAuth 2 authentication for your Google Voice account.

Obtaining an OAuth 2 Token for Google Voice

To deploy Google Voice with OAuth 2 authentication on the Incredible PBX platforms that support direct connections to Google Voice (Incredible PBX 13 and Incredible PBX for XiVO), you will first need to obtain an OAuth 2 Refresh Token from Google. On the remaining platforms that require a SIP account using the Simonics SIP to Google Voice gateway (PIAF5 powered by 3CX, Ombutel, and Elastix), you can skip this section since the Simonics site will obtain the refresh token for you as part of the signup process.

While you’re still logged into your Google Voice account, you need to obtain a refresh_token which is what you’ll use instead of a password when setting up your Google Voice accounts with Incredible PBX 13 and Incredible PBX for XiVO. Here’s how.

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

2. 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 (together with your Gmail account name and 10-digit GV phone number) when you add your GV trunk in Incredible PBX 13 GUI. On the XiVO platform, log into your server as root and run: /root/add-gvtrunk. 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. Sleep well.

Configuring Google Voice Trunks with Incredible PBX

The setup procedure differs a bit with Incredible PBX for XiVO and Incredible PBX 13.

With Incredible PBX for XiVO, log into the Linux CLI with your root credentials and run: /root/add-gvtrunk. Enter your Google email address, refresh token, and 10-digit Google Voice number when prompted. Follow the instructions which appear when the script finishes, and you’ll have a functioning Google Voice trunk in less than a minute.

With Incredible PBX 13, log into the Incredible GUI as admin using a web browser. Choose Connectivity -> Google Voice -> Add Account and fill in your Google Username, Refresh Token, and 10-digit Phone Number. Check the Add Trunk and Add Outbound Route check boxes. Then click Submit. Create an Inbound Route to tell Asterisk how to route incoming calls to your 10-digit DID. Finally, log into the Linux CLI as root and restart Asterisk: amportal restart.

Simonics SIP to Google Voice Gateway Setup

There’s a one-time fee of $4.99 to use the Simonics gateway if you take advantage of the Nerd Vittles signup link. All remaining Google services are free. You obviously can use the Simonics gateway with almost any PBX that supports SIP trunks, but it’s particularly well-suited for PBXs that don’t natively support Google Voice with OAuth 2 authentication such as PIAF5, Ombutel, and Elastix. To get started, you’ll need to set up an account at Simonics using your existing Google Voice credentials.

1. Using your favorite browser, log in to the Google Voice account you wish to associate with the Simonics SIP gateway. Be sure that you’ve enabled Google Chat in your Google Voice setup.

2. Using a separate tab of your browser, connect to the Simonics Google Voice Gateway site.

3. Go through the steps to register your Google Voice account with the Simonics Google Voice gateway and obtain your credentials.

4. For those using PIAF5, Ombutel, or Elastix, use another tab of your browser to open the GUI interface and create a new SIP trunk using your new Simonics SIP login credentials. With Incredible PBX 13, here’s the drill. Replace 8005551212 with your actual Google Voice number and YOUR-SIP-PW with your actual Simonics SIP password in BOTH the PEER Details and Registration String. Add your Google Voice number to the end of the Registration String like this: GV18005551212:YOUR-SIP-PW@gvgw.simonics.com/8005551212

5. Regardless of PBX platform, the next step is to create an Inbound Route for your incoming calls using either your Simonics username or the 10-digit number you entered at the end of the Registration String in step #4a. This obviously depends upon your PBX platform.

6. Create an Outbound Route for outgoing calls that should be handled by your Google Voice trunk. The CallerID number will be your Google Voice number. You cannot change it.

7. If you’d prefer to send incoming calls from the Simonics gateway to a designated SIP URI instead of the server that registered with the Simonics gateway, enter the address in the format: pbx@myserver.xyz. For additional details, read our previous article on SIP URIs.

SMS Messaging with Google Voice

On the Incredible PBX 13 and Incredible PBX for XiVO platforms, the python setup to support SMS messaging through Google Voice is already installed. On the PIAF5, Ombutel, and Elastix platforms, you’ll first need to install it. Here’s how.

Log into your server as root using SSH or Putty and issue the following commands to install the Google Voice CLI tools:

cd /root
apt-get -y install python-setuptools
wget http://incrediblepbx.com/install-gv-cli
chmod +x install-gv-cli

Before the SMS messaging tools will work, there are two preliminary steps that you must complete on every platform. This is because SMS messaging with python uses plain-text passwords for Google Voice, and Google imposes new hoops that you must jump through in order to continue to use such passwords. While logged into your Google Voice account with a browser, click on this link to Enable Less Secure Apps. Next, click on this link to Activate the Google Reset Procedure. You now have a couple of minutes to actually connect to your Google Voice account from your new server using plain text passwords. This will WhiteList the IP address of your server. So let’s send an SMS message quickly so that everything gets squared away.

To Send an SMS Message Blast to one or more destinations, (1) create a message in /root/smsmsg.txt, (2) specify the SMS numbers in /root/smslist.txt, (3) insert your Google credentials (using your plaintext Google Voice password) in /root/smsblast, and (4) run /root/smsblast to send the message.

Implementing Google’s Speech Recognition API

Speech Recognition currently works with Incredible PBX 13 and Incredible PBX for XiVO only. But we’ll be collaborating with the 3CX folks to bring it to their platform soon. All of the necessary components to use speech recognition for voice dialing from the AsteriDex phonebook (411) and to take advantage of the Siri-like Wolfram Alpha service (4747) already are in place with Incredible PBX 13. While voice dialing works great with XiVO, Wolfram Alpha is just around the corner on the XiVO platform. Before you can actually use voice recognition, you’ll need a Google API key since Google handles the speech-to-text translation on the Asterisk platform thanks to Lefteris Zafiris’ terrific speech-recog AGI script. Here’s a revised step-by-step tutorial to get your API key from Google and activate it on your PBX.

Place a test call by dialing 4-1-1 and saying "Delta Airlines" when prompted. You should be connected to Delta’s reservation system. Enjoy!

Published: Monday, November 14, 2016

Need help with Asterisk? Visit the PBX in a Flash Forum.


Special Thanks to Our Generous Sponsors

FULL DISCLOSURE: ClearlyIP, Skyetel, Vitelity, DigitalOcean, Vultr, VoIP.ms, 3CX, Sangoma, TelecomsXchange and VitalPBX have provided financial support to Nerd Vittles and our open source projects through advertising, referral revenue, and/or merchandise. As an Amazon Associate and Best Buy Affiliate, we also earn from qualifying purchases. 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.

BOGO Bonaza: Enjoy state-of-the-art VoIP service with a $10 credit and half-price SIP service on up to $500 of Skyetel trunking with free number porting when you fund your Skyetel account. No limits on number of simultaneous calls. Quadruple data center redundancy. $25 monthly minimum spend required. Tutorial and sign up details are here.

The lynchpin of Incredible PBX 2020 and beyond is ClearlyIP components which bring management of FreePBX modules and SIP phone integration to a level never before available with any other Asterisk distribution. And now you can configure and reconfigure your new Incredible PBX phones from the convenience of the Incredible PBX GUI.

VitalPBX is perhaps the fastest-growing PBX offering based upon Asterisk with an installed presence in more than 100 countries worldwide. VitalPBX has generously provided a customized White Label version of Incredible PBX tailored for use with all Incredible PBX and VitalPBX custom applications. Follow this link for a free test drive!

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.

Some Recent Nerd Vittles Articles of Interest…