Tweaking Asterisk for Free Google Voice Calling
Now that the Asterisk and Google Voice marriage is finally underway, we wanted to step back today and revise the original methodology a bit to take advantage of some of the terrific comments which were offered in response to our last article. First, the good news. U.S. calls through Google Voice using Asterisk work! They sound great, and they're free. The not so good news was that the MeetMe conferencing trick to join your outbound call with the Google Voice click-to-dial return call from your destination worked great so long as a real person answered the phone. But, if an answering machine picked up or no one answered the call at all, there were problems because these calls already had been transferred to the MeetMe conference and there was no simple way to disconnect them. And the need for two DIDs to support a single Google Voice interface just seemed a bit wasteful.
9/1/2010 Update: A good bit has changed with Google Voice since this article was first published. For the definitive guide and installation procedure, we highly recommend The Incredible PBX and accompanying article which can be found at this link. Google Voice (and much more) already is included in our new PBX which is literally Plug-and-Play. If you prefer to roll your own, be sure to also have a look at this excellent update on the Michigan Telephone Blog.
Today we want to try to eliminate these two quirks while stiill providing a seamless interface between Google Voice and Asterisk. We also appreciate that thousands of you already have implemented the previous approach. So we want your transition to the new way of doing things to be as painless as possible. On the other hand, for frequent readers, we hope you'll bear with us as we repeat some of what already has been covered in previous articles so new visitors don't have to jump around between articles to get the complete picture of what we're trying to accomplish.
The objective remains the same. We want a methodology that lets us make outbound calls from any Asterisk phone using the Google Voice service to take advantage of free calling in the United States and Canada. And we want calls to our Google Voice number delivered to our Asterisk system for transparent call processing. Yes, SIP is still on our wish list for both outbound and inbound calls with Google Voice, but we'll make do with PSTN calls particularly while Google is footing the bill for all of the calls.
Update: There's now a turnkey Asterisk solution that implements Google Voice calling without getting your hands dirty. Check out our new Orgasmatron V.
Tweaked Design. Here's the new design. You obviously still need a free Google Voice account. If you don't have one, you can request an invite here. At last report, it's only taking a few days from application to invite which is really great news. Don't use a space in your Google Voice password! Once you have a Google Voice account and phone number (Google has reserved a million of them so... not to worry!), then you'll need a DID that provides unlimited, free incoming calls. Once you get your DID set up on your Asterisk system, we'll set up a forwarding phone number for this DID in your Google Voice account so that Google Voice calls can be connected to your Asterisk server.
For outbound calls, we'll combine a little dialplan voodoo with pygooglevoice to instruct Asterisk to place a click-to-dial call using your Google Voice forwarding number. Then we'll stuff in the destination U.S. phone number. When you dial GV-678-1234567 from any of your Asterisk phones, Asterisk will park your initial call in a reserved parking lot slot and then join the called party to the originally parked call. The entire procedure is virtually transparent both to the caller and the callee. And, unlike the MeetMe conference, the parking lot fades out of the picture as soon as the call is connected. Thus, if either party hangs up, the active channel for the call is terminated on your Asterisk server.
For inbound calls from your Google Voice number, we'll tweak the dialplan so that it can distinguish between a RingBack call that Google Voice initiated and a true inbound call. We'll peel off the real inbound calls and route them to a separate Inbound Route in FreePBX for processing in any way you desire.
Finally, for those that implemented the methodology in our previous article, we'll walk you through the steps to revise your existing setup to take advantage of these new tweaks. You can skip over the initial installation process if you already have gone through the Google Voice setup from our earlier article. Just skip down to Tweaking Previous Setups.
Special Thanks. At the outset, we again want to express our sincere appreciation to Jacob Feisley and Paul Marks for their pioneering work on a Python interface to Google Voice. We also stumbled upon another Python development project, Google Voice for Python. While we originally had planned to rely upon Jacob and Paul's script, we ultimately decided to implement pygooglevoice because of the additional flexibility it provided for down the road. With pygooglevoice, you not only can make Google Voice calls, but you also can send SMS messages with no muss or fuss. Jacob Feisley has now joined that project as well. So, our special tip of the hat goes to the entire Google Voice for Python development team. It's a terrific product as you will see.
Prerequisites. Today's setup requires a CentOS-based Asterisk aggregation with a current version of FreePBX. Be aware that today's solution requires Python 2.4 or higher and reportedly will not work with Python 2.3 found in some Linux distributions. We've tested everything with PBX in a Flash and, on that platform, you're good to go. The install script should work equally well with the other CentOS-based Asterisk aggregations, but we haven't tested them. Be our guest, and let us know if you encounter any problems. Finally, a word of caution. We don't ordinarily distribute solutions using development tools we don't use. Our knowledge of Python wouldn't fill a thimble. We've made an exception today because of the extraordinary interest in Google Voice by the Asterisk community. But, if something comes unglued, we can't fix it. So have a backup plan in place just in case.
Today's Drill. To get everything working today, there are six steps: (1) obtaining and configuring a DID to manage calls between Google Voice and Asterisk, (2) configuring a Google Voice forwarding number for this DID to manage your outbound and inbound calls, (3) configuring FreePBX to route all outbound calls with a GV prefix to your special Google Voice dialplan context, (4) configuring an inbound route to manage incoming calls from your Google Voice number, (5) setting up a series of Parked Call extensions, one of which will be used to manage your outbound Google Voice calls, and (6) running our install script which adds the dialplan code for Google Voice calling with your credentials and puts the Python application into place on your server. It sounds more complicated than it is. So hang on to your hat. Here we go!
Dedicated DID. Before you can use Google Voice with Asterisk, you'll need a DID that can be dedicated to your Google Voice interface to Asterisk. We'd recommend a free IPkall or SIPgate DID. To get started, use one of the links above to obtain and configure the DID. Temporarily point the DID to an extension on your Asterisk system that can be used to verify your requests for the number. Since all of these calls are free, the area code of the DID really doesn't matter because you're never going to publish the fact that it exists.
The easiest method for setting up the DID is to first create a SIP URI for the DID on your Asterisk system. Next route the SIP URI to an Inbound Route in FreePBX where you can manage the destination for calls to that DID. Initially, you want the destination to be an extension on your Asterisk system that you can answer to verify both the DID setup and the GV setup below. Finally, point the DID you obtained to the SIP URI defined above.
HINT: The entry in extensions_override_freepbx.conf would look something like this for a SIP URI called ipkall-1:
exten => ipkall-1,1,Goto(from-trunk,${DID},1)
Then you would create an inbound route named ipkall-1 using FreePBX and designate some existing extension on your server as the destination for these inbound calls.
When you set up the SIP forwarding for the DID at ipkall.com, you'd specify the SIP URI as:
ipkall-1@ipaddress_of_your-Asterisk_server
We've previously covered in detail how to do this so read the article if you need a refresher course. To reiterate, the area code of this DID really doesn't matter because you're never going to give out the number. So use one of the free sources and save yourself some money. The real trick is you want to use a DID with unlimited, free inbound calls. Both IPkall and SIPgate provide that functionality at no cost.
Google Voice Setup. Log into your Google Voice account and click Settings, Phones, Add Another Phone. Add the area code and phone number of your DID. Be sure the DID is pointed to an extension on your PBX that you can answer since you have to go through Google's confirmation drill to successfully register the number. After the DID is confirmed, be sure there's a check mark beside this Google Voice destination so that incoming calls to your GV number will be routed to your Asterisk server.
While you're still in the Google Voice Setup, click on the General tab. Uncheck Enable Call Screening. Turn Call Presentation Off. And set CallerID to Display Caller's Number. Be aware that IPkall DIDs only forward your IPkall number as the CallerID number while SIPgate DIDs reportedly forward the actual number of the person calling you. If this matters to you, then you may prefer the SIPgate DID option. Finally, uncheck Do Not Disturb. Now click the Save Changes button.
Integrating Google Voice into Asterisk with FreePBX. Open FreePBX with a web browser and choose Setup, Trunks, Add Custom Trunk. Insert your GV number in the Outbound CallerID field and add the following Custom Dial String on the form and Submit Changes and reload the dialplan:
local/$OUTNUM$@custom-gv
Next, choose Setup, Outbound Routes, Add Route and fill in the following entries on the form:
Route Name: GoogleVoice
Dial Pattern: 48|NXXNXXXXXX
Trunk Seq: local/$OUTNUM$@custom-gv
Inbound Routes. Next, we need two Inbound Routes to get everything working. In setting up your DID with IPkall or SIPgate, you already should have created one inbound route for that provider. It already should be routing calls to an extension on your PBX. Now we need to create a Custom Destination for this inbound route and then reroute these calls there. In that way, your RingBack calls will be routed to some special dialplan code that drops these calls into a custom parking lot where the RingBack call is married up to the extension from which you placed the original call. Then we need to create another inbound route to manage normal incoming calls that are forwarded to your PBX whenever someone dials your Google Voice number.
To begin, choose Tools, Custom Destinations, Add Custom Destination and add an entry like this and then click the Submit Changes button:
Custom Destination: custom-park,s,1
Description: Custom GV-Park
Next choose Setup, Inbound Route and click on the inbound route you created previously for IPkall or SIPgate. Change the destination for these calls to Custom Destination: Custom GV-Park.
Now click on Add Incoming Route and create a new route for your incoming Google Voice calls. Give it any description you like but, for the DID number, it must be gv-incoming. You can leave most of the other defaults. Just be sure you set a destination for your incoming calls from Google Voice. It could be an extension, ring group, IVR, or whatever best meets your needs. The important entry here is gv-incoming for the DID number. Click the Submit button to save your entries. Ignore the warning that you've entered an oddball DID. We know what we're doing.
Setting Up the Parking Lot. While still in FreePBX, we need to create or adjust your existing settings in Setup, Parking Lot. The parking lot is used by FreePBX to simulate old key telephones where you could place a call on hold and then someone else in the office could pick up the call by clicking on the blinking key on their phone. The Asterisk equivalent is to press the flash hook and dial your Parking Lot Extension which then places the call in a Parking Lot space and tells you what the space number is. Someone else then can dial the number of that space to pick up the call. Our little trick today works like this. When you place an outbound call through Google Voice, your extension will be dumped into a reserved parking lot space. When Google Voice initiates the RingBack call before connecting the destination number you've dialed, that call will be sent to the same reserved parking lot space. The two calls then are joined, and you'll hear the parking lot number followed by ring tones as your call is connected by GV to its final destination. Our special thanks to Richard Bateman for his comment on the previous article and this terrific tip! He wins an Atomic Flash installer from Nerd Vittles. In addition, A. Godong wins an Atomic Flash installer for his tip on consolidating two DIDs into a single DID to manage both inbound and outbound GV calls. Just send us your addresses.
Now, where were we? Most FreePBX systems have a default setup for the Parking Lot. What we need to do is be sure you have reserved one more space in the parking lot than you actually need for day to day operation of your PBX. We'll use the last parking lot space number to manage outbound calling through Google Voice. Our entries look like the following:
Enable Parking Lot Feature: checked
Parking Lot Extension: 70
Number of Slots: 5
Parking Timeout: 30 seconds
Parking Lot Context: parkedcallsDestination for Orphaned Calls: Terminate Call: Hangup
If you use our setup above, the Magic Number is 75 which is the fifth slot in the Parking Lot. If you use a different Parking Lot extension or number of slots, here's how to calculate the Magic Number. Start counting the slots beginning with one more than the Parking Lot Extension. When you get to the last slot in the number of slots you've specified, that's your Parking Lot Magic Number. Write it down. You'll need it in a second when you run our GV installation script.
Save your entries and reload the Asterisk dialplan when prompted.
Integrating pygooglevoice. Now we're ready to complete the setup by running our revised script which loads pygooglevoice and sets up your dialplan in extensions_custom.conf. You'll need 5 pieces of information to run the script so write them down before you begin:
1. Your 10-digit Google Voice phone number
2. Your Google Voice email address
3. Your Google Voice password (no spaces!)
4. Your 11-digit RingBack DID (16781234567)
5. Your Parking Lot Magic Number
A word of caution: If you used a gMail address to set up your Google Voice account, it's possible to have different gMail and Google Voice passwords. For this to work, you'll need to enter your gMail password, not your Google Voice password (assuming they're different).
Now log into your Asterisk server as root and issue the following commands:
cd /root
wget http://bestof.nerdvittles.com/applications/gv/install-gv-new
chmod +x install-gv-new
./install-gv-new
Google Voice Speed Dials. For frequently called numbers, you can add speed dials by inserting entries in the [from-internal-custom] context of extensions_custom.conf that look like the example below where 333 is the speed dial number and 6781234567 is the area code and number to call. Be sure to reload your Asterisk dialplan to activate them.
exten => 333,1,Dial(local/6781234567@custom-gv,300)
Congratulations! You now have what we hope will be flawless and free U.S. calling on your Asterisk system using Google Voice. No gimmicks, no strings, no cost. Enjoy!
Finally, one additional word of caution. Both Google Voice and this call design are set up for a single call at a time. There are no safeguards to prevent multiple calls, but that may violate the Google Voice terms of service.
Asterisk 1.6 Solution. Several readers now have documented the procedure for implementing the Asterisk 1.6 bridge technology to make outbound Google Voice calls. You can read all about it here.
Tweaking Previous Setups. If you installed pygooglevoice using our previous tutorial, here's what you need to do. First, log into your Asterisk server as root and issue the following commands:
cd /etc/asterisk
nano -w extensions_custom.conf
Scroll to the bottom of the file by pressing Ctrl-W then Ctrl-V. Move up the file using up arrow until you reach [custom-gv]. Press Ctrl-K repeatedly to delete all of the lines in the [custom-gv] context. If you get to another line that starts with a label in brackets like [this], STOP deleting. Once you've deleted all of the lines in the [custom-gv] context, save the file: Ctrl-X, Y, and press Enter.
Now continue reading this article by jumping up to the Google Voice Setup topic. The Custom Trunk entry and the GoogleVoice outbound route will already be in your FreePBX system so there's no need to repeat those two steps. You will need to perform the remaining FreePBX steps beginning at the Inbound Routes topic and continuing on with Setting Up the Parking Lot. Finally, when you run the new installation script, it will detect that pygooglevoice is already on your system and will skip that step but will install the new custom contexts in extensions_custom.conf using your new settings. Enjoy!
Thought for the Day. Which is more arbitrary: (1) Apple snubs Google Voice or (2) Google Voice snubs SIP? Pays to look in the mirror occasionally.
Best Read of the Week. Memo to Steve Jobs and Apple: Stop Being A Jerk!

Need help with Asterisk? Visit the PBX in a Flash Forum.
Or Try the New, Free PBX in a Flash Conference Bridge.
whos.amung.us If you're wondering what your fellow man is reading on Nerd Vittles these days, wonder no more. Visit our new whos.amung.us statistical web site and check out what's happening. It's a terrific resource both for us and for you.
New Vitelity Special. Vitelity has generously offered a new discount for PBX in a Flash users. You now can get an almost half-price DID and 60 free minutes from our special Vitelity sign-up link. If you're seeking the best flexibility in choosing an area code and phone number plus the lowest entry level pricing plus high quality calls, then Vitelity is the hands-down winner. Vitelity provides Tier A DID inbound service in over 3,000 rate centers throughout the US and Canada. And, when you use our special link to sign up, the Nerd Vittles and PBX in a Flash projects get a few shekels down the road while you get an incredible signup deal as well. The going rate for Vitelity's DID service is $7.95 a month which includes up to 4,000 incoming minutes on two simultaneous channels with terminations priced at 1.45¢ per minute. Not any more! For PBX in a Flash users, here's a deal you can't (and shouldn't) refuse! Sign up now, and you can purchase a Tier A DID with unlimited incoming calls for just $3.99 a month and you get a free hour of outbound calling to test out their call quality. To check availability of local numbers and tiers of service from Vitelity, click here. Do not use this link to order your DIDs, or you won't get the special pricing! After the free hour of outbound calling, Vitelity's rate is just 1.44¢ per minute for outbound calls in the U.S. There is a $35 prepay when you sign up. This covers future usage and any balance is fully refundable if you decide to discontinue service with Vitelity.Some Recent Nerd Vittles Articles of Interest...























Twitter

By skug67, Wednesday, August 5, 2009 @ 10:59 am
Just curious why you’re suggesting IPkall/SIPgate to be where GV forwards incoming calls instead of Gizmo5. I only ask because I’ve got a Gizmo account but not an IPkall or SIPgate account. If there’s a benefit to using IPkall/SIPgate over Gizmo5 (e.g., less latency, better call quality), I’m happy to sign up for one more free service. But under the theory that less is more, I figured I’d ask before I go ahead and take that extra step.
[WM: We're not convinced that any service at Gizmo5 will remain free for long. Hence, the reason we didn't recommend it. However, a G5 DID should work if you can reliably receive SIP calls from G5 and complete the Google Voice setup process. Haven't tested it.]
By Jared, Wednesday, August 5, 2009 @ 11:20 am
Thanks Ward! Works great!
By Leif Madsen, Wednesday, August 5, 2009 @ 11:23 am
Just curious what the purpose of using a DID (GV) which forwards to another DID is? Wouldn’t it make more sense to have the free DID (inbound, non-GV) for your incoming calls, then use the outbound method for the free outbound calling portion?
Seems silly to me to forward one DID to another DID just to get your GV number to your Asterisk. Isn’t that what the free DID is doing anyways?
[WM: The GV DID isn't a DID that you can register with Asterisk at this point because they've blocked SIP connectivity. Down the road, we hope that will change. In the meantime, you need a way for inbound calls to GV to get to Asterisk, and that requires another DID that can be registered with Asterisk.]
By Edward, Wednesday, August 5, 2009 @ 12:01 pm
Thanks Ward!!! I have two questions:
(1) Your stated that….”If you use a different Parking Lot extension or number of slots, here’s how to calculate the Magic Number. Start counting the slots beginning with one more than the Parking Lot Extension. When you get to the last slot in the number of slots you’ve specified, that’s your Parking Lot Magic Number.”….
This is a little confusing for me. If I read what was said above, with a Parking Lot Extension: 70 and Number of Slots: 5, wouldn’t I start at 71 and have 5, making the magic number 76? Or I start at 70 and 71 will be the first number of the additional 5 slots?
[WM: Your Parking Lot slots would be 71, 72, 73, 74, and 75. So 75 is the last slot and the Magic Number. It still has to be in your range of parking lot extensions.]
(2) I started the “revision” (did previous setup with pygooglevoice) process by following your article at the top. When I was finish, I notice where you stated that we should have edited the “extensions_custom.conf” first before proceeding with the new (revised) setup. I check the file after the fact and there doesn’t seem to be any duplication or redundant entries in that file). I’m I incorrect?
[WM: If you previously used our pygooglevoice script, then there is a duplicate [custom-gv] context in the file. Use Ctrl-W in nano to search for the two occurrences and delete the contents of the top context. If you don’t find two, then something failed the first time around.]
By Edward, Wednesday, August 5, 2009 @ 12:18 pm
Sorry Ward, I found the answer to my second question!! After attempting to place a call and was unable to connect, I recheck the “extensions_custom.conf” file and YES, there were TWO “[custom-gv]” contexts and I delete the “old” context. Maybe you should place the “Tweaking Previous Setups” statements earlier in your writeup for people that have done the previous install. Thx.
[WM: The article says, for previous installs, to jump directly to the last section of the article and names it. I don't know how much clearer that could be.
]
By ralph, Wednesday, August 5, 2009 @ 1:01 pm
What is the ringback did? is this sipgate/ipkall did i entered on my googlevoice account?
I have sipgate setup but i am a little confuse with the sip uri thing. My sipgate did is working I am able to receive incoming calls via that did.
[WM: That is your RingBack DID. If you can receive calls from that DID, you're all set to configure it as a destination DID in Google Voice.]
By Bryan, Wednesday, August 5, 2009 @ 2:10 pm
Thank you for all of the help with using GV! I was happily using the previous method using g5, and ipkall for inbound and am trying to move to this latest configuration. In my extensions override file, do I need the line exten => demo,1,Goto(from-trunk,3366,1)? Admittedly, I not sure what it does. Also, I don’t have an option for Custom Destinations under Tools. All of the modules appear to be installed and options enabled. What am I missing? Thanks again, this is great!
[WM: Blog comments are a horrible way to diagnose problems and provide tech support. Visit the PIAF Forums and post issues there. Thanks.]
By Leif Madsen, Wednesday, August 5, 2009 @ 3:03 pm
WM: Oh, I get that you can’t register directly. I just don’t quite get why you would even bother with the Google Voice incoming if you’ve already got a DID that you could advertise.
I guess if you want to use the voicemail on google and have the transcriptions and all that, I suppose you need to direct the calls to the GV DID.
Anyways, was just thinking out loud mostly
By A. Godong, Wednesday, August 5, 2009 @ 5:10 pm
Leif Madsen: One reason why you want to handle the incoming GV DID call is because your outgoing call Caller ID will be your GV DID. GV doesn’t allow you to override the caller ID (Well if they do it will defeat its main purpose as one number for all :)) and you’re right, having transcription is also a nice feature. You should advertise your GV DID instead of your ringback number.
By Hector, Wednesday, August 5, 2009 @ 9:26 pm
Strange, maybe someone can help. I can run the gvoice -e… command from the command prompt on trixbox as root and the call comes fine to try and answer a parked call, but when asterisk tries running it through System(gvoice -e…), the command does not seem to execute neither does it show an error through /var/log/asterisk/full nor /var/log/messages. Is there a log file I can find to see if there’s an error so I could fix this? Thanks.
By Jim, Thursday, August 6, 2009 @ 2:26 am
Is there a solution that does not require a computer to be on such as plugging an ATA to a router?
By Hector, Thursday, August 6, 2009 @ 2:42 am
I finally got it to work, I had to add “asterisk ALL = NOPASSWRD: /usr/bin/gvoice” to the end of /etc/sudoers then run System(sudo gvoice -e “${ACCTNAME}” -p ${ACCTPASS} call ${EXTEN} ${RINGBACK}) notice the quotes around the acctname variable. Hopefully this helps anyone who’s in the same situation as I was.
By Bao Nguyen, Thursday, August 6, 2009 @ 4:41 am
Well, this approach is using Park() function. But I dont see its advantages over Meetme() solution. One thing I like about MeetMe is you can set MusicOnHold to custom class, which will play connecting tone like “tit tit tit tit…” or my own message, and the caller does not aware of the technique being used.
Maybe it is easier to create multiple Park Numbers than Conference Rooms.
For the callback trunk from GV, since I dont want to mess up with default incoming route “Any DID/Any CID”, I will create a incoming route just for GV callback as below:
1. Description: Callback-from-GV
2. DID Number: your-Sipgate-DID ;should be your SG username
3. Caller ID Number: your-GV-Number
4. Destination: [custom-park]-or-[whatever]
nttranbao
By Dan, Thursday, August 6, 2009 @ 10:09 am
Hector, or anyone else. I believe I have the same problem as Hector did. However i am not follwoing where to add Asterisk All = No Password
what is going on is I am able to hit my GV trunk make call out I get the parking lot number when I call but the far end never rings.. looks like i am getting some errors below.. thanks for the help
[root@asterisk1 ~]#
[root@asterisk1 ~]# gvoice -e
Traceback (most recent call last):
File “/usr/bin/gvoice”, line 4, in ?
from googlevoice import Voice,LoginError,input
File “/usr/lib/python2.3/site-packages/googlevoice/__init__.py”, line 16
@property
^
SyntaxError: invalid syntax
[root@asterisk1 ~]#
[WM: Sounds like you have a Google Voice login issue, too. At the command prompt, run gvoice and answer the prompts. Does it complete the call? Post this on the forum once you have more info.]
By Dan, Thursday, August 6, 2009 @ 11:11 am
Hey Ward, i dont see to be follwing you. obviously I am a little green on CLI Not sure what you mean by answer the prompts or run gvoice? when I type in gvoice I get the below error. although my username and password are correct I even verified by logging into google.com/voice this morning.
[root@asterisk1 ~]#
[root@asterisk1 ~]# gvoice
Traceback (most recent call last):
File “/usr/bin/gvoice”, line 4, in ?
from googlevoice import Voice,LoginError,input
File “/usr/lib/python2.3/site-packages/googlevoice/__init__.py”, line 16
@property
^
SyntaxError: invalid syntax
[WM: Something's missing in your setup. Post your hardware config and this issue on the forum. Can't debug tech issues on a blog. Sorry.]
By Jacob Feisley, Thursday, August 6, 2009 @ 2:47 pm
@Dan,
That issue is because Python2.3 is too old to use for the pyGoogleVoice library.
You will need at least Python2.4 to use the tool.
By skug67, Thursday, August 6, 2009 @ 2:50 pm
This is working great for me. A few (helpful, I hope) comments:
(1) It seems to work fine using a Gizmo5 account. Because of the integration between GV and Gizmo5, you don’t need to sign up for a PSTN DID, you can just route everything through a SIP trunk registered to your Gizmo5 account.
(2) I agree with Bao Nguyen that the dialplan is a bit more complicated than necessary. You should be able to use the standard incoming route for the DID/trunk you’re for incoming calls just fine. And you can simply have a new route incoming route for that trunk w/your GV caller-id that goes to the custom-park destination. This eliminates the need for a separate non-standard route “gv-incoming.”
(3) I’m running Asterisk/FreePBX on an Ubuntu box, and I needed to install simplejson (apt-get install python-simplejson) in order for pygooglevoice to work. But now everything’s working great.
By ralph, Thursday, August 6, 2009 @ 3:52 pm
This is not clear to me:
exten => ipkall-1,1,Goto(from-trunk,${DID},1)
ipkall-1 thats an extension right? can I just randomly pick amy name ? i have sipgate so can I just put sipgate instead of ipkall-1?
[WM It's the label for your SIP URI and inbound route. Just be sure to use the same name here and in the name for the DID in your inbound route for SipGate, and you're good to go.]
By Jordan, Thursday, August 6, 2009 @ 4:36 pm
This works like a charm first try with IPKALL. The only issue Im having is that when I make the destination of gv-incoming anything besides extension or ring group asterisk does not pickup and the call goes to the google voice voicemail. Any ideas why?
By Sorvani, Thursday, August 6, 2009 @ 11:14 pm
A user over in the trixbox forum has tweaked this setup to use the Bridge function in Asterisk 1.6. I set my system up this way and it is working great.
http://trixbox.org/forums/trixbox-forums/open-discussion/outbound-calls-google-voice
By Bao Nguyen, Thursday, August 6, 2009 @ 11:52 pm
Jordan, it’s the GV’s problem, and the same with direct routing to extension. If you answer right after it rings your extension, the call will go to GV voicemail.
You should have Wait() for at least 3 seconds before the command Answer(), like this:
exten => s,1,Wait(4)
exten => s,2,Goto(ivr,s,1) ; or s,2,Goto(from-internal,your-extension-No,1)
By Sid, Friday, August 7, 2009 @ 12:17 am
I have the same issue as Dan. I have the older version of python v2.3. Are there any instructions on how to update to ver 2.4 or any chances of making pygooglevoice backward compatible with version 2.3.
Any help is appreciated.
By Chris, Friday, August 7, 2009 @ 3:17 am
Got it working with this writeup
Only problem is that when I place the call out, it rings the extension I’m calling from and when I answer it, then it rings and connects me. It shouldn’t be doing that, right?
By Jordan, Friday, August 7, 2009 @ 8:47 am
@Bao Nguyen
Okay an IVR will kick in consistently now. However I have isolated another issue. DTMF - calling outbound from a zoiper softphone works. Calling inbound to my google voice number from my cellphone DTMF works about 5% of the time. Calling my ringback number direct with cellphone DTFM works 100% of the time. Conclusion - the trunk is configured properly something in Google Voice isnt doing DTMF very well which makes the usefulness considerably less. Anyone else having similar issues? And yes I know this should be in the PIAF forum… Im eagarly awaiting access approval.
By ralph, Friday, August 7, 2009 @ 9:19 am
I am using an IAX connection for my ipkall DID. I guess I don’t have to setup extensions_override_freepbx.conf . Am I right?
By Eugene Ellison, Friday, August 7, 2009 @ 11:00 am
For incoming calls, why not point the Google Voice to Gizmo5 and do SIP Forwarding to the Asterisk Server? Most everyone has a DYNDns (or equivalent) FQD. Set the Gizmo5 SIP forwarding to asterisk_ext@DYNDns_FQD.
[WM: Hundreds of possibilities. Should work fine.]
By Chris, Friday, August 7, 2009 @ 12:47 pm
After playing with it more, I think what my issue is that instead of this:
“When Google Voice initiates the RingBack call before connecting the destination number you’ve dialed, that call will be sent to the same reserved parking lot space. The two calls then are joined, and you’ll hear the parking lot number followed by ring tones as your call is connected by GV to its final destination.”
The call is calling my same extension, so it causes it to call me on line 2, which I must answer while keeping the line where I placed the call on hold indefinitely and initiating the call on that second line on the same extension. For some reason it isn’t connecting it on the same line on that extension.
[WM: The destination extension for your RingBack DID should be different than your calling extension.]
By pagemen, Saturday, August 8, 2009 @ 9:31 pm
There is a potential problem by using incoming CID to do parking. While most of the time it should work, all calls initiated from Google Voice’s web interface will fail. My solution is to use GROUP_COUNT instead. You don’t have to hard code the GV# into your dial plan.
[gvout]
…..(after agi call)….
exten => s,n,Set(GROUP()=gvout)
include => parkedcalls
exten => s,n,Set(PARKINGEXTEN=701)
exten => s,n,Park()
[incoming-trunk]
exten => s,1,NoOp()
exten => s,n,GotoIf($[ ${GROUP_COUNT(gvout)} = 1 ]?parked:notparked)
exten => s,n(parked),Wait(3)
exten => s,n,ParkedCall(701)
exten => s,n(notparked),GoTo(ring,s,1)
By Chris, Tuesday, August 11, 2009 @ 4:46 pm
Does this leave the original outgoing call parked til its terminated after 30 seconds, or does it just connect the two calls together?
[WM: The two calls immediately get connected together, and the parking lot entry is cleared.]
By Mark A Peters, Wednesday, August 12, 2009 @ 10:34 pm
This works like a charm first try with SIPgate.
Has anyone looked into using this to do Follow Me?
By A. Godong, Thursday, August 13, 2009 @ 5:35 am
@Mark A Peters: If you use bridge in 1.6, multichannel works so you can set up follow me. Look at the forum on the article and add to that the non-CID pagemen solution.
By Jon, Thursday, August 13, 2009 @ 5:27 pm
Awesome mashup =). Anyone know of a way to disable Allison from saying ‘7′ ‘5′ when an outbound call is placed in park?
[WM: Look on the bright side. Could have been six less.
Try explaining that to the Little Mrs.]
By ward, Friday, August 14, 2009 @ 10:20 am
An interesting new SIP dialing approach through Google Voice has been posted here. Keep in mind that the longevity of these SIP solutions is running about a week.
By Frank Pepe, Sunday, August 16, 2009 @ 11:33 am
********************************
PLEASE DISREGARD ALL OF MY POSTS.
*******************************
Turns out my problem was self induced. I am sorry for all the confusion.
I made a mistake here:
1. Your 10-digit Google Voice phone number
I must have entered an 11-digit number. I found an 11 digit GV number in my extensions_custom.conf and got rid of the first digit “1″ . put everything back to the way i had it originally and shazam! it works
thanks for the awesome solution.
-Frank
By Ben Klopfenstein, Monday, August 17, 2009 @ 12:14 pm
Jon:
If you use exten => _X.,n,ParkAndAnnounce(pbx-transfer:PARKED|45|/dev/null) to park your call, rather than just Park(), Allison says nothing (actually, she does but it is sent to /dev/null).
Now i’m trying to figure out how to get ring tones instead of hold music…
[WM: Great tip! If you'd prefer not to have errors in your log, here's an alternative that does the same thing:]
exten => _X.,n,ParkAndAnnounce(pbx-transfer:PARKED|45|Console/dsp)
By savant, Monday, August 17, 2009 @ 10:59 pm
Great write up!
Has anyone got this working on a vanilla Asterisk install? This site leans more toward FreePBX which is cool and all, but I prefer an asterisk-only solution. The parts I’m having a hard time visualizing are how the two inbound and 1 outbound trunks should look in the dial plan. I’ve got GV forwarding to sipgate, which forwards to an extension on my asterisk system, and I can receive calls wonderfully on my sip phone. I’d like to now be able to place calls from GV. I’ve installed the python app and it seems like it setup extensions_custom.conf, but that’s where I’m stuck. Any help would be much obliged.
By jimb, Tuesday, August 18, 2009 @ 8:58 pm
I found that with pygooglevoice, if your login fails, the program goes interactive asking if you want to try again (and since no one is around to press Y or N, the channel just hangs, waiting for a key to be pressed.)
I fixed the issue by getting commenting out the try/except statements, but kept:
voice.login(options.email,options.passwd)
I would be nice to have another option, such as “-b” (batch) which would tell the program to end on any error (without interaction).
By Brooke C, Wednesday, August 19, 2009 @ 5:08 pm
I have this working fine but what I have noticed is there is no outbound CDR logged for calls sent over gvoice. The inbound CDR is fine, however. There is a NoCDR in the inbound section but that simply prevens the ringback from being logged, as far as I can tell. Is outbound CDR working for anyone else?
By Cloudscout, Friday, August 21, 2009 @ 9:27 pm
It looks like people with AT&T phones can no longer call Google Voice subscribers (at least here in Minnesota). When they dial a Google Voice number they get a recording that says, “The call you are attempting to place is not allowed from this line. Please dial 611 for Customer Service.”
I’m calling Customer Care right now to see what the deal is.
By Justin, Thursday, August 27, 2009 @ 5:15 am
I am working on updating pygooglevoice to allow for python2.3 support (@Dan), batch mode (@jimb), and to move the asterisk configuration script under revision control at googlecode. You will still need to install simplejson in order for it to work. Look for the updates in the project soon
By ralph, Saturday, August 29, 2009 @ 10:15 pm
ipkall fails for me. it does not pass GoogleVoice’s CID .Sipgate works ok though! thanks!
[WM: Some IPkall numbers pass CID, and some don't.
Can't beat free though.]
By Alfred, Saturday, September 5, 2009 @ 10:47 pm
Ok, now what if you want to setup say five GV-Sipgate connections instead of just the one?
[WM: You could do this with IPkall and SIP URI's but probably not with SIPgate.]
By Kevin, Thursday, September 17, 2009 @ 1:35 pm
This is not working for me. I am trying to place the call using zoiper and at first I hear “are busy now please try your call again later” and then it hangs up with the error “invalid number format”. I was able to successfully use google voice from the console, though. Any thoughts on what’s wrong?
By Kevin, Thursday, September 17, 2009 @ 1:57 pm
Here’s some more info from troubleshooting: it works if I do the speed-dial trick you mentioned above. So, is it a problem with the dial pattern? Or maybe the $OUTNUM$ variable?
By Kevin, Thursday, September 17, 2009 @ 3:17 pm
Okay, I got it working. Apparently it was using one of my other outbound routes… This dial pattern was apparently a better match?: NXXXXX.
I changed it to NXXXXXX and now it’s working fine.
By ward, Wednesday, September 30, 2009 @ 10:23 am
There have been some updates to Google Voice which broke things… again. For new installs, there shouldn’t be a problem because we’ve fixed the downloads. If you’ve already installed this before NOW, do the following to get Google Voice working again. Make certain that you first have enabled the DAG Repository!
Log into your server as root and issue the following commands:
cd /root/pygooglevoice
yum install mercurial
rm -r pygooglevoice
hg clone https://pygooglevoice.googlecode.com/hg/ pygooglevoice
cd pygooglevoice
rm /usr/bin/gvoice
python setup.py install
By Bryan, Monday, October 19, 2009 @ 10:15 pm
Sorry, but I am looking for the forum that would help in troubleshooting this. I performed all the steps exactly and reviewed it several times. I am getting inbound calls and outbound is going straight out my sipgate trunk. It appears not to invoke the gv parking and call initiation. The only difference may be I did article 637 first and ran the “configure-gv”. Anyways, just looking to see where I can locate troubleshooting steps possibly. Thanks.
[WM: http://pbxinaflash.com/forum ]
By Bryan, Monday, October 19, 2009 @ 11:29 pm
I was able to get it working. I had the dial string of 48|NXXNXXXXXX. Once I removed the 48|, it worked. Thanks
By ward, Wednesday, November 18, 2009 @ 8:00 am
Google Voice interface seems to again be broken. The issue already has been reported here if you want to track progress in resolving it.
By Jamie, Wednesday, November 18, 2009 @ 10:32 am
Thanks for the update Ward. I was freaking out yesterday when my wife told me it wasn’t working - I thought it was my system. Hope they come up with a fix soon!
By ward, Wednesday, November 18, 2009 @ 11:25 am
Here’s the fix. First, you’ll need to find voice.py in your existing server. It should be in /root/pygooglevoice/googlevoice or /root/pygooglevoice/googlevoice.
Once you find the directory, cd to that directory and…
Be sure to cd to proper directory
mv voice.py voice.py.old
wget http://pbxinaflash.net/source/gv/voice.zip
unzip voice.zip
rm voice.zip
cd ..
python setup.py install
By Jamie, Saturday, November 21, 2009 @ 2:21 am
Thank you so much Ward! That fixed it. I like how you provided simple step-by-step instructions. People like me need that.
By Tipu, Wednesday, December 2, 2009 @ 3:58 pm
Is there a way to change the GV account details (Phone number and/or google account credentials) once the python script has been setup? I have changed my account password and wanted to update it in the python script.
[WM: You'll find the entries at the end of the extensions_custom.conf file in /etc/asterisk.]
By Tipu, Thursday, December 10, 2009 @ 11:40 am
For some reason my setup has stopped working. I have not changed anything on my side (Not even the google account settings). I just get the parked call message and then music on hold without the call ever connecting.
I see that there is a new release of the Pygooglevoice script on google code. How do i upgrade to it?
[WM: See the last 10 comments on this Nerd Vittles article for some tips.]
By arandomperson, Thursday, January 14, 2010 @ 2:05 pm
There needs to be an update script, so when this thing breaks, u just type python setup.py update, and it wgets a script file that wgets everything else, and removes whatever files, and everything by itself, and then python setup.py installs again by itself, so people dont have to keep coming here and being like, its broken, wtf, they can just type setup.py fix, and it checks for a fix, oh, a new fix as of this date, would u like to apply… or something like that.
[WM: Right you are. Not quite that easy, but here are the steps.]
1. Visit http://pygooglevoice.googlecode.com and discern the name of the latest update.
2. Log into your server as root and issue the following commands using the new filename:
cd /root
wget http://pygooglevoice.googlecode.com/files/pygooglevoice-0.5.tar.gz
tar zxvf pygooglevoice*
cd pygooglevoice-0.5 #<– Use latest filename here, too!
python setup.py install
By Xbox mania, Monday, January 18, 2010 @ 6:29 am
Yea.. am curious if any one of you have got this working on the vanilla Asterisk
By Chris, Wednesday, February 17, 2010 @ 12:09 am
If you are using a free IPkall number that doesn’t pass the correct caller ID through, when running the script enter your 10 digit IPkall number, not your Google Voice number.
If you’ve already done it and wonder why the RingBack call is ringing on another extension rather than magically joining up with your outgoing call in the parking lot, you can change this detail in extensions_custom.conf and it should work.
By Late2theParty, Monday, May 17, 2010 @ 2:50 pm
For anyone trying to set this up that can’t get it to work, here are a few pointers:
1) Make sure you have the latest pygooglevoice version - see arandomperson’s post about three entries above this one.
2) Try a call from the command line. Note that the number you are calling must be entered WITH a 1+area code (11 digits altogether), whereas the number you are directing the call to must be one of the destinations registered as a destination on your Google Voice account and is specified using only 10 digits. Further, you might need to leave an additional space and specify the type of number you are directing the call to. Permissible phone types are 1-Home, 2-Mobile, 3-Work, or 7-Gizmo. So lets say you are directing a call to a Gizmo5 number (ten digits starting with 747), here is what your entry from the command prompt should look like:
gvoice -e myemail@gmail.com -p myGVpassword call 12345551234 7470000000 7
3) If that works then you know you have to add the call type variable to the call in extensions_custom.conf. You can either add a variable for the type, or you can do what I did and eliminate the extraneous variables and hardcode everything but the extension number:
exten => _X.,n,System(gvoice -e myemail@gmail.com -p myGVpassword call ${EXTEN} 7470000000 7)
Remember, the type must match the number before it. I suspect this may be only necessary in some cases (such as when the destination is a Gizmo5 number).
4) After doing the command line test above, check the CLI or your call records to see what Caller ID was used. If this doesn’t exactly match what’s in your [custom-park] context it won’t work. By the way, it is possible to do away with custom-park altogether, but it’s rather convoluted. You have to create a Misc. Destination pointing to your parking lot code, then you create an Announcement to kill a few seconds (have it play pls-wait-connect-call) and make its destination the Misc. Destination, then you can create an inbound route with the proper DID and Caller ID (exactly as it comes in on a callback from GV) and send it to the Announcement. The inbound route then detects the DID/CID combination, sends the call to the announcement to burn a few seconds while the caller is being transferred to the parking lot, then the call goes to the parking lot slot via the Misc. Destination. As I say it’s convoluted but if you like to stay within FreePBX as much as possible, that’s one way to do it.
5) Take a few minutes reading the other comments above, there are some good hints there (like how to keep Allison from saying a couple of digits
before the call connects through).
6) Finally, on my system I set this up as a custom trunk, so I could route calls to it that are dialed in the normal manner, using the outbound route capability of FreePBX. To do that, create a new CUSTOM trunk, set Maximum Channels to 1, set dial rules to
1+NXXNXXXXXX
1aaa+NXXXXXX
if you want to convert 10 and 7 digit numbers to the proper format (change aaa to your area code, or just leave that line out if you don’t have 7 digit calls in your area or take care of this elsewhere in your dial plan), and then in the Custom Dial String textbox put this:
Local/$OUTNUM$@custom-gv
One other advantage of making it a trunk is that you can this make it first in the list of preferred trunks, and if you ever have a problem with it you can simply come back to the trunk page and check the Disable Trunk checkbox until you figure out what the problem is, and your calls will fall through to the next preferred trunk. Also, with a bit more effort you can restrict that trunk (and the route(s) that use it) to particular extensions, if you use either of the third party FreePBX modules that let you do that (Custom Contexts or Outbound Route Permissions - I happen to like the second one better, but either would work for that purpose).
By Late2theParty, Wednesday, May 19, 2010 @ 9:37 pm
A couple more pointers found after I posted my previous message:
First, you can get into the parking lot a bit faster by not waiting around for the system call to gvoice to finish executing. You do this by adding a space and ampersand just before the final parenthesis (compare the following to the similar line in item 3 of my previous post):
exten => _X.,n,System(gvoice -e myemail@gmail.com -p myGVpassword call ${EXTEN} 7470000000 7 &)
If you do this then you can probably eliminate the delay in sending the incoming call to the parking lot - in my case I was able to take out the time-wasting announcement that I inserted in step 4 (of my previous message) and go right from the inbound route to my Misc. Destination (the parking lot extension). As far as I can tell, the only reason that delay was needed is because if the incoming call from Google Voice tries to connect to the parking lot slot before your original call has been parked, everything fails. By not waiting around for the gvoice command to finish executing and going straight on to the parking lot, you avoid this possibility and your call connects faster.
Finally, if you don’t like it playing a few seconds of the default music on hold, you can change the music on hold category that is used by inserting this line in your custom-gv context just before you transfer the call to the Parking Lot:
exten => _X.,n,SetMusicOnHold(connect-gv)
Either create a music on hold category called connect-gv and upload whatever sound file you want played, or change connect-gv in the above line to the name of one of your existing music-on-hold categories. Remember that at most you’re only going to hear three or four seconds of this before the call connects through (if all is working as it should), so don’t spend a lot of time on this because more than likely nobody’s ever going to hear more than the first four or five notes. And yes, you could use a few seconds of silence, or even some old-time sounds like the phone switches used to make while completing calls back in the 70’s or earlier (that ought to freak out anyone who uses your phone and is old enough to remember those).
By Mario, Tuesday, June 1, 2010 @ 3:30 pm
I know there have been a few comments above about wanting to do this in a Vanilla Asterisk solution. I was trying to adapt what’s in this post, in the comments here and from a few other sites into a vanilla asterisk solution.
I’ve documented my entire procedure from a clean openwrt install to a functional asterisk install on a blog here:
http://supermario-world.blogspot.com/2010/06/google-voice-sip-solutions.html
By Donb, Saturday, August 28, 2010 @ 3:46 pm
The bigger question now that Gmail has free phone calls in it is when is somebody gonna figure out how to make it dial all the way through Google without any phone lines? I’m assuming Google hasn’t provided a SIP interface yet?
[WM: Funny you'd mention that. See this thread.]