<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/AST/Calling+using+Google">Calling using Google</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~mdavenport">Malcolm Davenport</a>
</h4>
<br/>
<h4>Changes (58)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-unchanged" >{warning} <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Note that Google's changes to their Google Voice system have rendered much of these capabilities inoperable, in many cases, or unreliable, in most cases. As such, building a business based on Google Voice calling using Asterisk is not something that would be recommended. Additionally, ongoing maintenance of Google Talk integration with Asterisk is not provided by Digium and is instead in the charge of the community. <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">This new page replaces the old page [AST:Old Calling using Google]. The old page documents behavior that is not functional or supported going forward. This new page documents behavior as of Asterisk 11. For more information, please see the blog posting [http://blogs.digium.com/2012/07/24/asterisk-11-development-the-motive-for-motif/] <br></td></tr>
<tr><td class="diff-unchanged" >{warning} <br> <br>h2. Prerequisites <br> <br></td></tr>
<tr><td class="diff-changed-lines" >Asterisk communicates with Google Voice and Google Talk using the <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">chan_gtalk</span> <span class="diff-added-words"style="background-color: #dfd;">chan_motif</span> Channel Driver and the <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">res_jabber</span> <span class="diff-added-words"style="background-color: #dfd;">res_xmpp</span> Resource module. Before proceeding, please ensure that both are compiled and part of your installation. Compilation of <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">res_jabber</span> <span class="diff-added-words"style="background-color: #dfd;">res_xmpp</span> and <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">chan_gtalk</span> <span class="diff-added-words"style="background-color: #dfd;">chan_motif</span> for use with Google Talk / Voice are dependant on the iksemel library files as well as the OpenSSL development libraries presence on your system. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Calling using Google Voice or via the Google Talk web client requires the use of Asterisk 1.8.1.1 or greater. The 1.6.x versions of Asterisk only support calls made using the legacy GoogleTalk external client. <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">Calling using Google Voice or via the Google Talk web client requires the use of Asterisk 11.0 or greater. Older versions of Asterisk will not work. <br></td></tr>
<tr><td class="diff-unchanged" > <br>For basic calling between Google Talk web clients, you need a Google Mail account. <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >Google Voice can now be used with Google Apps accounts. <br> <br></td></tr>
<tr><td class="diff-changed-lines" >h2. <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Gtalk</span> <span class="diff-added-words"style="background-color: #dfd;">Motif</span> configuration <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The chan_gtalk Channel Driver is configured with the gtalk.conf configuration file, typically located in /etc/asterisk. What follows is the minimum required configuration for successful operation. <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">The Motif channel driver is configured with the motif.conf configuration file, typically located in /etc/asterisk. What follows is an example configuration for successful operation. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h5. Minimum Gtalk Configuration <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">h5. Example Motif Configuration <br></td></tr>
<tr><td class="diff-unchanged" > <br>{noformat} <br></td></tr>
<tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">[general]</span> <span class="diff-added-words"style="background-color: #dfd;">[google]</span> <br><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">context=local</span> <span class="diff-added-words"style="background-color: #dfd;">context=incoming-motif</span> <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">allowguest=yes <br>bindaddr=0.0.0.0 <br>externip=216.208.246.1 <br> <br>[guest] <br></td></tr>
<tr><td class="diff-unchanged" >disallow=all <br>allow=ulaw <br></td></tr>
<tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">context=local</span> <span class="diff-added-words"style="background-color: #dfd;">connection=google</span> <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">connection=asterisk <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br> <br> <br>This general section of this configuration specifies several items. <br></td></tr>
<tr><td class="diff-changed-lines" ># That calls will terminate to or originate from the <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">*local*</span> <span class="diff-added-words"style="background-color: #dfd;">*incoming-motif*</span> context; <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">context=local</span> <span class="diff-added-words"style="background-color: #dfd;">context=incoming-motif</span> <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;"># That guest calls are allowd; allowguest=yes <br># That RTP sessions will be bound to a local address (an IPv4 address must be present); bindaddr=0.0.0.0 <br># (optional) That your external (the one outside of your NAT) IP address is defined; externip=216.208.246.1 <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;"># That all codecs are first explicitly disallowed <br># That G.711 ulaw is allowed <br># The an XMPP connection called "google" is to be used <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The guest section of this configuration specifies several items. <br># That no codecs are allowed; disallow=all <br># That the ulaw codec is explicitly allowed; allow=ulaw <br># That calls received by the guest user will be terminated into the *local* context; context=local <br># That the Jabber connection used for guest calls is called "asterisk;" connection=asterisk <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">Google lists supported audio codecs on this page - [https://developers.google.com/talk/open_communications] <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h2. Jabber Configuration <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">Per section, 5, the supported codecs are: <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The res_jabber Resource is configured with the jabber.conf configuration file, typically located in /etc/asterisk. What follows is the minimum required configuration for successful operation. <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;"># PCMA <br># PCMU <br># G.722 <br># GSM <br># iLBC <br># Speex <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h5. Minimum Jabber Configuration <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">Our experience shows this not to be the case. Rather, the codecs, supported by Asterisk, and seen in an invite from Google Chat are: <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;"># PCMA <br># PCMU <br># G.722 <br># iLBC <br># Speex 16kHz <br># Speex 8kHz <br> <br>It should be noted that calling using Google Voice requires the G.711 ulaw codec. So, if you want to make sure Google Voice calls work, allow G.711 ulaw, at a minimum. <br> <br> <br>h2. XMPP Configuration <br> <br>The res_xmpp Resource is configured with the xmpp.conf configuration file, typically located in /etc/asterisk. What follows is an example configuration for successful operation. <br> <br>h5. Example XMPP Configuration <br> <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br>[general] <br></td></tr>
<tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">autoregister=yes</span> <span class="diff-added-words"style="background-color: #dfd;">[google]</span> <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;"> <br>[asterisk] <br></td></tr>
<tr><td class="diff-unchanged" >type=client <br>serverhost=talk.google.com <br></td></tr>
<tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">username=your_google_username@gmail.com/Talk</span> <span class="diff-added-words"style="background-color: #dfd;">username=example@gmail.com</span> <br><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">secret=your_google_password</span> <span class="diff-added-words"style="background-color: #dfd;">secret=examplepassword</span> <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">priority=1 <br></td></tr>
<tr><td class="diff-unchanged" >port=5222 <br>usetls=yes <br>usesasl=yes <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">statusmessage="I am an Asterisk Server" <br></td></tr>
<tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">timeout=100</span> <span class="diff-added-words"style="background-color: #dfd;">status=available</span> <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">statusmessage="I am available" <br>timeout=5 <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The general section of this configuration specifies several items. <br># Debug mode is enabled, so that XMPP messages can be seen on the Asterisk CLI; debug=yes <br># Automated buddy pruning is disabled, otherwise buddies will be automatically removed from your list; autoprune=no <br># Automated registration of users from the buddy list is enabled; autoregister=yes <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">The default general section does not need any modification. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-changed-lines" >The <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">asterisk</span> <span class="diff-added-words"style="background-color: #dfd;">google</span> section of this configuration specifies several items. <br></td></tr>
<tr><td class="diff-unchanged" ># The type is set to client, as we're connecting to Google as a service; type=client <br># The serverhost is Google's talk server; serverhost=talk.google.com <br></td></tr>
<tr><td class="diff-changed-lines" ># Our username is configured as <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">your_google_username@gmail.com/resource, where our resource is "Talk;" username=your_google_username@gmail.com/Talk</span> <span class="diff-added-words"style="background-color: #dfd;">your_google_username@gmail.com; username=your_google_username@gmail.com</span> <br></td></tr>
<tr><td class="diff-unchanged" ># Our password is configured using the secret option; secret=your_google_password <br># Google's talk service operates on port 5222; port=5222 <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;"># Our priority is set to 1; priority=1 <br></td></tr>
<tr><td class="diff-unchanged" ># TLS encryption is required by Google; usetls=yes <br># Simple Authentication and Security Layer (SASL) is used by Google; usesasl=yes <br></td></tr>
<tr><td class="diff-changed-lines" ># We set a status message so other Google chat users can see that we're an Asterisk server; statusmessage="I am <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">an Asterisk Server"</span> <span class="diff-added-words"style="background-color: #dfd;">available"</span> <br># We set a timeout for receiving message from Google that allows for plenty of time in the event of network delay; <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">timeout=100</span> <span class="diff-added-words"style="background-color: #dfd;">timeout=5</span> <br></td></tr>
<tr><td class="diff-unchanged" > <br> <br>h2. Phone configuration <br> <br></td></tr>
<tr><td class="diff-changed-lines" >Now, let's <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">place</span> <span class="diff-added-words"style="background-color: #dfd;">create</span> a <span class="diff-changed-words">phone<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;"> into the same context as the Google calls</span>.</span> The configuration of a SIP device for this purpose would, in sip.conf, typically located in /etc/asterisk, look something like: <br></td></tr>
<tr><td class="diff-unchanged" > <br>{noformat} <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > <br>{noformat} <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">[incoming-motif] <br>exten => s,1,Wait(1) <br></td></tr>
<tr><td class="diff-unchanged" >exten => s,1,Answer() <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">exten => s,n,Wait(2) <br></td></tr>
<tr><td class="diff-unchanged" >exten => s,n,SendDTMF(1) <br>exten => s,n,Dial(SIP/malcolm,20) <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > <br>{note} <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Note that you might have to adjust the "Wait" time from 2 (in seconds) to something larger, like 8, depending on the current mood of Google. Otherwise, your incoming calls might not be successfully picked up. <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">Did you know that the Google Chat client does this same thing; it waits, and then sends a DTMF 1. Really. <br></td></tr>
<tr><td class="diff-unchanged" >{note} <br> <br></td></tr>
<tr><td class="diff-changed-lines" >This example uses the "s" unmatched extension, because <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Google does not forward any DID when it sends the call to Asterisk.</span> <span class="diff-added-words"style="background-color: #dfd;">we're only configuring one client connection in this example.</span> <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">In this example, we're Answering the call, Waiting 2 seconds, sending the DTMF "1" back to Google, and *then* dialing the call. <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">In this example, we're Waiting 1 second, answering the call, sending the DTMF "1" back to Google, and *then* dialing the call. <br></td></tr>
<tr><td class="diff-unchanged" >We do this, because inbound calls from Google enable, even if it's disabled in your Google Voice control panel, call screening. <br>Without this SendDTMF event, you'll have to confirm with Google whether or not you want to answer the call. <br> <br>{tip:title=Using Google's voicemail} <br></td></tr>
<tr><td class="diff-changed-lines" >Another method for accomplishing the sending of the DTMF event is to use <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">the D dial option.</span> <span class="diff-added-words"style="background-color: #dfd;">Dial option "D."</span> The D option tells Asterisk to send a specified DTMF string after the called party has answered. DTMF events specified before a colon are sent to the *called* party. DTMF events specified after a colon are sent to the *calling* party. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-changed-lines" >In this example then, one does not need to actually answer the call <span class="diff-changed-words">first<span class="diff-added-chars"style="background-color: #dfd;">, though one should still wait at least a second for things, like STUN setup, to finish</span>.</span> This means that if the called party doesn't answer, Google will resort to sending the call to one's Google Voice voicemail box, instead of leaving it at Asterisk. <br></td></tr>
<tr><td class="diff-unchanged" >{code} <br>exten => s,1,Dial(SIP/malcolm,20,D(:1)) <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
<tr><td class="diff-changed-lines" >First, we set a variable called *crazygooglecid* to be equal to the name field of the CALLERID function. Next, we use the CUT function to grab everything that's before the @ symbol, and save it in a new variable called *stripcrazysuffix.* <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;"> </span> We'll set this new variable to the CALLERID that we're going to use for our Dial. Finally, we'll actually Dial our internal destination. <br></td></tr>
<tr><td class="diff-unchanged" >{tip} <br> <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > <br>{noformat} <br></td></tr>
<tr><td class="diff-changed-lines" >exten => <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">100,1,Dial(gtalk/asterisk/mybuddy@gmail.com)</span> <span class="diff-added-words"style="background-color: #dfd;">100,1,Dial(Motif/google/mybuddy@gmail.com,,r)</span> <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
<tr><td class="diff-changed-lines" >Where the technology is <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">"gtalk,"</span> <span class="diff-added-words"style="background-color: #dfd;">"Motif,"</span> the dialing peer is <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">"asterisk"</span> <span class="diff-added-words"style="background-color: #dfd;">"google"</span> as defined in <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">jabber.conf,</span> <span class="diff-added-words"style="background-color: #dfd;">xmpp.conf,</span> and the dial string is the Google account name. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">We use the Dial option "r" because Google doesn't provide ringing indications. <br> <br></td></tr>
<tr><td class="diff-unchanged" >Outgoing calls made to Google Voice take the form of: <br> <br>{noformat} <br></td></tr>
<tr><td class="diff-changed-lines" >exten => <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">_1XXXXXXXXXX,1,Dial(gtalk/asterisk/+${EXTEN}@voice.google.com)</span> <span class="diff-added-words"style="background-color: #dfd;">_1XXXXXXXXXX,1,Dial(Motif/google/${EXTEN}@voice.google.com,,r)</span> <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Where the technology is "gtalk," the dialing peer is "asterisk" as defined in jabber.conf, and the dial string is a full E.164 number (plus character followed by country code, followed by the rest of the digits). <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">Where the technology is "Motif," the dialing peer is "google" as defined in xmpp.conf, and the dial string is a full E.164 number, sans the plus character. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h3. Interactive Voice with Text Response (IVTR) <br> <br>Because the Google Talk web client provides both audio and text interface, you can use it to provide a text-based way of traversing Interactive Voice Response (IVR) menus. This is necessary since the client does not have any DTMF inputs. <br> <br>In the following dialplan example, we will answer the call, wait a bit, send some text that will show up in the caller's Google Talk client, play back a prompt, capture the caller's text-based response, and then dial the appropriate SIP device. <br> <br>{code} <br>exten => s,1,Answer() <br>exten => s,n,SendText("If you know the extension of the party you wish to reach, dial it now.") <br>exten => s,n,Background(if-u-know-ext-dial) <br>exten => s,n,Set(OPTION=${JABBER_RECEIVE(asterisk,${CALLERID(name)::15},5)}) <br>exten => s,n,Dial(SIP/${OPTION},20) <br>{code} <br> <br>Note that with the JABBER_RECEIVE function, we're receiving the text from *asterisk* which we defined earlier in this page as our connection to Google. We're also specifying with *$\{CALLERID(name)::15\}* that we want to strip off the last 15 characters from the CallerID name string - which is the number of characters that Google is appending, as of this writing, to represent an internal call ID number, and that we want to wait *5* seconds for a response. <br> <br>h3. Webinar <br> <br>A Webinar was conducted on Tuesday, March 24, 2011 detailing Asterisk configuration for calling using Google as well as several usage cases. A copy of the slides, in PDF format, is available here - [^Google Calling Webinar - Public.pdf] <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">Again, we use Dial option "r" because Google doesn't provide ringing indications. <br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>This new page replaces the old page <a href="/wiki/display/AST/Old+Calling+using+Google" title="Old Calling using Google">Old Calling using Google</a>. The old page documents behavior that is not functional or supported going forward. This new page documents behavior as of Asterisk 11. For more information, please see the blog posting <a href="http://blogs.digium.com/2012/07/24/asterisk-11-development-the-motive-for-motif/" class="external-link" rel="nofollow">http://blogs.digium.com/2012/07/24/asterisk-11-development-the-motive-for-motif/</a></td></tr></table></div>
<h2><a name="CallingusingGoogle-Prerequisites"></a>Prerequisites</h2>
<p>Asterisk communicates with Google Voice and Google Talk using the chan_motif Channel Driver and the res_xmpp Resource module. Before proceeding, please ensure that both are compiled and part of your installation. Compilation of res_xmpp and chan_motif for use with Google Talk / Voice are dependant on the iksemel library files as well as the OpenSSL development libraries presence on your system.</p>
<p>Calling using Google Voice or via the Google Talk web client requires the use of Asterisk 11.0 or greater. Older versions of Asterisk will not work.</p>
<p>For basic calling between Google Talk web clients, you need a Google Mail account.</p>
<p>For calling to and from the PSTN, you will need a Google Voice account.</p>
<p>In your Google account, you'll want to change the Chat setting from the default of "Automatically allow people that I communicate with often to chat with me and see when I'm online" to the second option of "Only allow people that I've explicitly approved to chat with me and see when I'm online."</p>
<p>IPv6 is currently not supported. Use of IPv4 is required.</p>
<p>Google Voice can now be used with Google Apps accounts.</p>
<h2><a name="CallingusingGoogle-Motifconfiguration"></a>Motif configuration</h2>
<p>The Motif channel driver is configured with the motif.conf configuration file, typically located in /etc/asterisk. What follows is an example configuration for successful operation.</p>
<h5><a name="CallingusingGoogle-ExampleMotifConfiguration"></a>Example Motif Configuration</h5>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[google]
context=incoming-motif
disallow=all
allow=ulaw
connection=google
</pre>
</div></div>
<p>This general section of this configuration specifies several items.</p>
<ol>
        <li>That calls will terminate to or originate from the <b>incoming-motif</b> context; context=incoming-motif</li>
        <li>That all codecs are first explicitly disallowed</li>
        <li>That G.711 ulaw is allowed</li>
        <li>The an XMPP connection called "google" is to be used</li>
</ol>
<p>Google lists supported audio codecs on this page - <a href="https://developers.google.com/talk/open_communications" class="external-link" rel="nofollow">https://developers.google.com/talk/open_communications</a></p>
<p>Per section, 5, the supported codecs are:</p>
<ol>
        <li>PCMA</li>
        <li>PCMU</li>
        <li>G.722</li>
        <li>GSM</li>
        <li>iLBC</li>
        <li>Speex</li>
</ol>
<p>Our experience shows this not to be the case. Rather, the codecs, supported by Asterisk, and seen in an invite from Google Chat are:</p>
<ol>
        <li>PCMA</li>
        <li>PCMU</li>
        <li>G.722</li>
        <li>iLBC</li>
        <li>Speex 16kHz</li>
        <li>Speex 8kHz</li>
</ol>
<p>It should be noted that calling using Google Voice requires the G.711 ulaw codec. So, if you want to make sure Google Voice calls work, allow G.711 ulaw, at a minimum.</p>
<h2><a name="CallingusingGoogle-XMPPConfiguration"></a>XMPP Configuration</h2>
<p>The res_xmpp Resource is configured with the xmpp.conf configuration file, typically located in /etc/asterisk. What follows is an example configuration for successful operation.</p>
<h5><a name="CallingusingGoogle-ExampleXMPPConfiguration"></a>Example XMPP Configuration</h5>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[general]
[google]
type=client
serverhost=talk.google.com
username=example@gmail.com
secret=examplepassword
priority=1
port=5222
usetls=yes
usesasl=yes
status=available
statusmessage="I am available"
timeout=5
</pre>
</div></div>
<p>The default general section does not need any modification.</p>
<p>The google section of this configuration specifies several items.</p>
<ol>
        <li>The type is set to client, as we're connecting to Google as a service; type=client</li>
        <li>The serverhost is Google's talk server; serverhost=talk.google.com</li>
        <li>Our username is configured as your_google_username@gmail.com; username=your_google_username@gmail.com</li>
        <li>Our password is configured using the secret option; secret=your_google_password</li>
        <li>Google's talk service operates on port 5222; port=5222</li>
        <li>Our priority is set to 1; priority=1</li>
        <li>TLS encryption is required by Google; usetls=yes</li>
        <li>Simple Authentication and Security Layer (SASL) is used by Google; usesasl=yes</li>
        <li>We set a status message so other Google chat users can see that we're an Asterisk server; statusmessage="I am available"</li>
        <li>We set a timeout for receiving message from Google that allows for plenty of time in the event of network delay; timeout=5</li>
</ol>
<h2><a name="CallingusingGoogle-Phoneconfiguration"></a>Phone configuration</h2>
<p>Now, let's create a phone. The configuration of a SIP device for this purpose would, in sip.conf, typically located in /etc/asterisk, look something like:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[malcolm]
type=peer
secret=my_secure_password
host=dynamic
context=local
</pre>
</div></div>
<h2><a name="CallingusingGoogle-Dialplanconfiguration"></a>Dialplan configuration</h2>
<h5><a name="CallingusingGoogle-Incomingcalls"></a>Incoming calls</h5>
<p>Next, let's configure our dialplan to receive an incoming call from Google and route it to the SIP phone we created. To do this, our dialplan, extensions.conf, typically located in /etc/asterisk, would look like:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[incoming-motif]
exten => s,1,Wait(1)
exten => s,1,Answer()
exten => s,n,SendDTMF(1)
exten => s,n,Dial(SIP/malcolm,20)
</pre>
</div></div>
<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Did you know that the Google Chat client does this same thing; it waits, and then sends a DTMF 1. Really.</td></tr></table></div>
<p>This example uses the "s" unmatched extension, because we're only configuring one client connection in this example.</p>
<p>In this example, we're Waiting 1 second, answering the call, sending the DTMF "1" back to Google, and <b>then</b> dialing the call.<br/>
We do this, because inbound calls from Google enable, even if it's disabled in your Google Voice control panel, call screening.<br/>
Without this SendDTMF event, you'll have to confirm with Google whether or not you want to answer the call.</p>
<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Using Google's voicemail</b><br />Another method for accomplishing the sending of the DTMF event is to use Dial option "D." The D option tells Asterisk to send a specified DTMF string after the called party has answered. DTMF events specified before a colon are sent to the <b>called</b> party. DTMF events specified after a colon are sent to the <b>calling</b> party.
<p>In this example then, one does not need to actually answer the call first, though one should still wait at least a second for things, like STUN setup, to finish. This means that if the called party doesn't answer, Google will resort to sending the call to one's Google Voice voicemail box, instead of leaving it at Asterisk.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">exten => s,1,Dial(SIP/malcolm,20,D(:1))</pre>
</div></div></td></tr></table></div>
<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Filtering Caller ID</b><br />The inbound CallerID from Google is going to look a bit nasty, e.g.:
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>+15555551212@voice.google.com/srvres-MTAuMjE4LjIuMTk3Ojk4MzM=
</pre>
</div></div>
<p>Your VoIP client (SIPDroid) might not like this, so let's simplify that Caller ID a bit, and make it more presentable for your phone's display. Here's the example that we'll step through:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => s,1,Set(crazygooglecid=${CALLERID(name)})
exten => s,n,Set(stripcrazysuffix=${CUT(crazygooglecid,@,1)})
exten => s,n,Set(CALLERID(all)=${stripcrazysuffix})
exten => s,n,Dial(SIP/malcolm,20,D(:1))
</pre>
</div></div>
<p>First, we set a variable called <b>crazygooglecid</b> to be equal to the name field of the CALLERID function. Next, we use the CUT function to grab everything that's before the @ symbol, and save it in a new variable called <b>stripcrazysuffix.</b> We'll set this new variable to the CALLERID that we're going to use for our Dial. Finally, we'll actually Dial our internal destination.</p></td></tr></table></div>
<h5><a name="CallingusingGoogle-Outgoingcalls"></a>Outgoing calls</h5>
<p>Outgoing calls to Google Talk users take the form of:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => 100,1,Dial(Motif/google/mybuddy@gmail.com,,r)
</pre>
</div></div>
<p>Where the technology is "Motif," the dialing peer is "google" as defined in xmpp.conf, and the dial string is the Google account name.</p>
<p>We use the Dial option "r" because Google doesn't provide ringing indications.</p>
<p>Outgoing calls made to Google Voice take the form of:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten => _1XXXXXXXXXX,1,Dial(Motif/google/${EXTEN}@voice.google.com,,r)
</pre>
</div></div>
<p>Where the technology is "Motif," the dialing peer is "google" as defined in xmpp.conf, and the dial string is a full E.164 number, sans the plus character.</p>
<p>Again, we use Dial option "r" because Google doesn't provide ringing indications.</p>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Calling+using+Google">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=5996698&revisedVersion=40&originalVersion=39">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Calling+using+Google?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>