Google Voice Talk on Asterisk 1.8 (with FreePBX) and a flexible dialplan


Google Voice Talk on Asterisk 1.8 (with FreePBX) and a flexible dialplan [Updated 12-04-2012]

Ok so you’ve got a 1.4 or 1.6 Asterisk with FreePBX running somewhere? Now you wish to use GoogleVoice/Talk with Asterisk 1.8. Here’s how.
This guide is more for a Debian system, so if you are running other than, do a little google.
Firstly, get your FreePBX updated to v2.8, other versions apparently won’t support Asterisk 1.8.
After that, start the Asterisk upgrade process. (from Mikael Carlsson, FreePBX Development Team @ this article) and the necessary dependencies for Asterisk’s chan_gtalk and chan_jabber

You’ve done your 1.8 setup which is ready for google voice/talk
Now, here are some configuration files you can simply copy paste in /etc/asterisk/. You can follow exactly the same as i have to make things work first.
Edit /etc/asterisk/gtalk.conf, paste the following, modify accordingly. Note, for newer versions of FreePBX, it supports inbound routes with names (typically it would be numbers). So you can actually send the call to for example from-pstn or from-dahdi or from-trunnk, then you can add this “inbound route to route to a specific extension” as you would do with a normal DID for instance.
;####start####
[general]
context=google-incoming ;;##use from-trunk if using newer FBX 2.8 or higher
allowguests=yes
bindaddr=<yourinternalIP>
[guest]
disallow=all
allow=ulaw
context=google-incoming ;;##use from-trunk if using newer FBX 2.8 or higher
connection=sanjay-ac1
;####end####
Save and exit.
Now, edit, /etc/asterisk/jabber.conf, paste the following, modify accordingly
;####start####
[general]
debug=yes
autoprune=no
autoregister=yes
[sanjay-ac1]
type=client
serverhost=talk.google.com
[email protected]/Talk
secret=mysecretPassword
port=5222
usetls=yes
usesasl=yes
statusmessage=”[email protected]
timeout=100
[sanjay-ac2]
type=client
serverhost=talk.google.com
[email protected]/Talk2
secret=mysecretPassword
port=5222
usetls=yes
usesasl=yes
statusmessage=”[email protected]
timeout=100
;####end###
And finally, edit your custom dialplan e.g. /etc/asterisk/extensions_custom.conf, paste the following, modify accordingly. Yo u only do this below if you are not using FreePBX latest version 2.8 or higher. For FreePBX 2.8 or higher, see below this dialplan.
;####start####
[from-internal-custom]
include => google-outgoing
[google-incoming]
;this for internal gmail user [email protected], ring her 1001 extension
exten => [email protected],1,Macro(user-callerid,)
exten => [email protected],n,Answer()
exten => [email protected],n,Wait(2)
exten => [email protected],n,Set(Thiscallchan=${CALLERID(name)})
exten => [email protected],n,Set(CALLERID(name)=${CUT(Thiscallchan,/,1)})
exten => [email protected],n,Set(CALLERID(num)=g${CUT(CALLERID(name),@,1)})
exten => [email protected],n,SendDTMF(1)
exten => [email protected],n,Goto(from-internal,1001,1) or ,n,DIAL(SIP/1001)
; end gmail user [email protected]

;this for internal gmail user [email protected], ring her 1002 extension
exten => [email protected],1,Answer()
exten => [email protected],n,Wait(2)
exten => [email protected],n,Set(Thiscallchan=${CALLERID(name)})
exten => [email protected],n,Set(CALLERID(name)=${CUT(Thiscallchan,/,1)})
exten => [email protected],n,Set(CALLERID(num)=g
${CUT(CALLERID(name),@,1)})
exten => [email protected],n,SendDTMF(1)
exten => [email protected],n,Goto(from-internal,1002,1) # or ,n,DIAL(SIP/1002)
; end gmail user [email protected]
[google-outgoing]
; Set the outgoing account per jabber.conf
exten => _g*.,1,Macro(user-callerid,SKIPTTL)
; Add more users here
exten => _g*.,n,ExecIf($[“${AMPUSER}” = “1001”]?Set(gmailoutaccount=sanjay-ac1))
exten => _g*.,n,ExecIf($[“${AMPUSER}” = “1002”]?Set(gmailoutaccount=sanjay-ac2))
;
; Normal outbound calling, g is prefixed so it will call google talk,
; and call other places using google voice, like below, a US number
exten => _g*.,n,Dial(gtalk/${gmailoutaccount}/${EXTEN:2}@gmail.com)
exten => _1XXXXXXXXXX,n,Dial(gtalk/${gmailoutaccount}/${EXTEN}@voice.google.com)
;
;
; Dialplan for sending messages
exten => _t*.,1,Macro(user-callerid,SKIPTTL)
exten => _t*.,n,ExecIf($[“${AMPUSER}” = “1001”]?Set(gmailoutaccount=sanjay-ac1))
exten => _t*.,n,ExecIf($[“${AMPUSER}” = “1002”]?Set(gmailoutaccount=sanjay-ac2))
;
exten => _t*.,n,JABBERSend(${gmailoutaccount},[email protected],”${EXTEN:2}”)
exten => h,1,(Hangup)
;####end####
 
At this point be sure to stop and start Asterisk (amportal kill / amportal start). Infact most settings made on gtalk.conf needs to restart Asterisk, not just reload.
With FreePBX 
When using FreePBX 2.8 or higher, you don’t need to write manual dialplans for INBOUND (incoming) calls. You only need to customize the dialplan if you are planning to make outbound calls on Gtalk through Asterisk. Here below is a sample inbound route created in FreePBX.
Remember, this is for INCOMING only that will be handled by FreePBX, here any calls destined to [email protected] I will attempt to send to an extension (or anywhere as you please). As you can see below, if I set the context to from-trunk, I will see it like below in my cli
image
Notice the DID value there is [email protected] which mean, it is as simple as adding an Inbound Route in FreePBX like below;
image
 
Extra information manual dialplan creation
1) You must specify incoming and outgoing google accounts.
2) Incoming connections will dial internal extensions or just about anywhere you have designed in FreePBX, in this case, they are extensions.
3) Outgoing calls are matched based on the extension that is dialling (supports user/device mode as well) so that if extension 1001 is dialing out, the recipient will see highsecurity calling and if extension 1002 dialling, he/she will see stunningsimplicity
4) Anyone without that specific dialplan set for outbound can be limited to a failurecode (not defined in this sample here).
5) If someone wants to dial out, he/she dial g*<user> like for example gs*anjayws will dial the gmail user sanjayws. The g* is used as a prefix for dialling out so it is a clear path to dial google.  To make redials easier, when an incoming call comes through the dialplan, we’ve added the g* at the begining of the callerID(name) field so that when a person redials, it will engage the outbound route. Notice that we do a CUT in there and that is to remove certain characters through a delimiter character.
6) Of course, you can also specify calling to other google voice numbers if you have google voice credits to those outgoing accounts created in jabber.conf. This example above, does US calls as it is free for now. Feel free to add any other calling matches to use google voice.
Done.
Do send your feedback to [email protected]
Thank you.
Resources:
http://forums.digium.com/viewtopic.php?f=1&t=76250
https://wiki.asterisk.org/wiki/display/AST/Calling+using+Google
http://www.freepbx.org/forum/freepbx/installation/asterisk-1-8-installation

1 Comment

Comments are closed.