I followed the following steps to setup my new FreePBX Server with Google Voice.
I am happy to say it works for the most part, however inbound calls are not making it. All in all this was a good learning experience:
*UPDATE* I have made a follow up with my working configuration files
How To Add Google Voice To FreePBX
Part 1: In the shell
- Refer to the Asterisk Wiki: Calling Using Google. We’ll be following that as our guide.
- From the command line, as user root or asterisk, verify that the res_jabber and chan_gtalk modules are loaded.
[root@asterisk18 ~]# asterisk -rx "module show" | grep res_jabber
res_jabber.so AJI - Asterisk Jabber Interface 0
[root@asterisk18 ~]# asterisk -rx "module show" | grep chan_gtalk
chan_gtalk.so Gtalk Channel Driver 0- If one or both of those grep commands returns nothing, you need to build the modules (don’t forget to have OpenSSL development libraries installed) and make sure they are loading at Asterisk startup (
autoload=yes
ORload => res_jabber.so
andload=> chan_gtalk.so
in /etc/asterisk/modules.conf).
- There are three config files in /etc/asterisk to edit by hand (use
vi
,nano
,emacs
or whatever you like): jabber.conf, gtalk.conf, and extensions_custom.conf.- jabber.conf – Edit or replace jabber.conf to follow what is listed in Calling Using Google, and which I am pasting almost verbatim here. (I removed
debug=yes
.) This establishes the XMPP connection.[general]
[asterisk]
autoprune=no
autoregister=yes
type=client
serverhost=talk.google.com
username=your_google_username@gmail.com/asterisk
secret=your_google_password
port=5222
priority=1
usetls=yes
usesasl=yes
statusmessage=”I am an Asterisk Server”
timeout=100 - gtalk.conf – Again referring to the Asterisk wiki, edit gtalk.conf thus:
[general]
[guest]
context=from-google
allowguest=yes
bindaddr=0.0.0.0
;externip=1.2.3.4 ; if you know your external ip addr
stunaddr=stun01.sipphone.com ; use STUN if you're on dynamic IP and NAT
disallow=all
allow=ulaw
context=from-google
connection=asteriskSome notes about gtalk.conf:- Use context
from-google
, which we will set up in the extensions_custom.conf. connection=asterisk
must match the connection definition (in square brackets) in jabber.conf.- Use
externip
orstunaddr
to get your external IP address if you’re behind a NAT.
- Use context
- extensions_custom.conf – Make a section like this:
[from-google]
exten => s,1,Answer()
exten => s,n,Wait(2)
exten => s,n,SendDTMF(1)
exten => s,n,Set(CALLERID(num)=${CUT(CALLERID(name),@,1)})
exten => s,n,Set(CALLERID(name)=${CUT(CALLERID(name),/,1)})
exten => s,n,Goto(from-trunk,YOUR-GV-NUMBER,1)
exten => s,h,Hangup- Replace YOUR-GV-NUMBER with your Google Voice DID.
- The
Set
commands fix up the caller ID to get rid of the long XMPP ID that is passed on an inbound call.
- jabber.conf – Edit or replace jabber.conf to follow what is listed in Calling Using Google, and which I am pasting almost verbatim here. (I removed
- Once these files are in place, restart Asterisk (
amportal restart
). - Issue the following command to see that the XMPP connection to Google Talk has been established:
# asterisk -rx "jabber show connections"
Jabber Users and their status:
User: ...@gmail.com/asterisk - Connected
----
Number of users: 1 - Now you’re ready to set up a Google Voice trunk and inbound and outbound routes in FreePBX.
Part 2: FreePBX
- Add a new Custom Trunk.
- Trunk name: Google Voice
- Outbound Caller ID: put your Google Voice DID, even though this will be ignored (GV always uses your GV number for the outbound Caller ID)
- Dialed Number Manipulation Rules: Google Voice requires that the number be a full 11 digits, starting with 1. Either here or in your outbound route (or both), make sure you are sending a full 11-digit number.
- Custom Dial String: This is the most important part. Enter
gtalk/asterisk/+$OUTNUM$@voice.google.com
whereasterisk
matches the client definition in your jabber.conf (in square brackets). If you’ve followed this how-to exactly, then this line is correct. - Submit changes.
- Add a new Outbound Route.
- You can send any US domestic calls through Google Voice. Just configure an appropriate outbound route and select Google Voice as the trunk. I configured 11-, 10-, and 7-digit dialing within my own area code.
- Add a new Inbound Route.
- Refer back to this line you entered in extensions_custom.conf:
exten => s,n,Goto(from-trunk,YOUR-GV-NUMBER,1)
Whatever you entered for YOUR-GV-NUMBER will be the DID you use for your inbound route. - Description: Google Voice (or whatever you want)
- DID Number: YOUR-GV-NUMBER
- Other stuff: defaults
- Destination: wherever you want the incoming call to go.
- Refer back to this line you entered in extensions_custom.conf:
- Submit all changes and apply configuration. Done! You have added a Google Voice two-way trunk to FreePBX and can use it in your inbound and outbound routing. Don’t forget to log in to Google Voice and select Google Chat (…@gmail.com) as the phone to which your incoming calls are forwarded!
A big thanks and all credit to the guys over at PSU VoIP