{"id":419,"date":"2010-06-13T23:32:01","date_gmt":"2010-06-14T03:32:01","guid":{"rendered":"http:\/\/protofusion.org\/wordpress\/?p=419"},"modified":"2010-06-13T23:33:53","modified_gmt":"2010-06-14T03:33:53","slug":"google-voice-and-asterisk","status":"publish","type":"post","link":"http:\/\/protofusion.org\/wordpress\/2010\/06\/google-voice-and-asterisk\/","title":{"rendered":"Google Voice and Asterisk"},"content":{"rendered":"<p><a href=\"http:\/\/protofusion.org\/wordpress\/wp-content\/uploads\/2010\/06\/gvheader.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-436\" title=\"\" src=\"http:\/\/protofusion.org\/wordpress\/wp-content\/uploads\/2010\/06\/gvheader-500x205.png\" alt=\"Google Voice &amp; Asterisk\" width=\"500\" height=\"205\" srcset=\"http:\/\/protofusion.org\/wordpress\/wp-content\/uploads\/2010\/06\/gvheader-500x205.png 500w, http:\/\/protofusion.org\/wordpress\/wp-content\/uploads\/2010\/06\/gvheader-300x123.png 300w, http:\/\/protofusion.org\/wordpress\/wp-content\/uploads\/2010\/06\/gvheader.png 858w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>There are numerous guides about setting up Google Voice and an incoming sip number for free outgoing calling. Sadly, all of the guides I found were written for FreePBX or some other Asterisk bundle, and also used a shell script to do much of the work (scary!). I have compiled the minimal amount that you need to put in your asterisk conf files to make things work, GUI-free and variant-independent.<\/p>\n<p><!--more--><\/p>\n<h2>Prerequisites<\/h2>\n<p><a href=\"http:\/\/sipgate.com\/\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"size-large wp-image-444 alignright\" title=\"sipgate logo\" src=\"http:\/\/protofusion.org\/wordpress\/wp-content\/uploads\/2010\/06\/sipgate-logo-500x187.jpg\" alt=\"sipgate logo\" width=\"225\" height=\"84\" srcset=\"http:\/\/protofusion.org\/wordpress\/wp-content\/uploads\/2010\/06\/sipgate-logo-500x187.jpg 500w, http:\/\/protofusion.org\/wordpress\/wp-content\/uploads\/2010\/06\/sipgate-logo-300x112.jpg 300w, http:\/\/protofusion.org\/wordpress\/wp-content\/uploads\/2010\/06\/sipgate-logo.jpg 1414w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><\/p>\n<p>First off, you need a sip number. I recommend <a href=\"http:\/\/sipgate.com\/\" target=\"_blank\">sipgate<\/a> or <a href=\"http:\/\/ipkall.com\/\">ipkall<\/a> (I use sipgate, it&#8217;s much more user-friendly). If you google around, you&#8217;ll find out how to set up your sipgate\/ipkall number as an incoming number in asterisk, I won&#8217;t waste time covering it here.<\/p>\n<p>Secondly, you need a google voice number. Once you get said number, turn off call presentation. Also, assign the account a password that you don&#8217;t mind having plaintext in a conf file. In addition, you <strong><em>must<\/em><\/strong> add your incoming sip number as a phone in google  voice. I&#8217;d recommend connecting a softphone to your sip number to set this up with google&#8217;s verification call, or redirect all incoming calls in Asterisk to your extension.<\/p>\n<p>Thirdly, you need <a href=\"http:\/\/code.google.com\/p\/pygooglevoice\/\" target=\"_blank\">pygooglevoice<\/a>. Download and install it, or use python&#8217;s easy_install command.<\/p>\n<h2>The outgoing rule<\/h2>\n<p>Now for the actual configuration. First you need to set up an outgoing call rule, so all calls to the outside world (in this case, 10-digit numbers preceded with a &#8220;9&#8221;) are directed though google voice.<\/p>\n<blockquote>\n<p style=\"padding-left: 30px;\">[CallingRule_LocalCalls]<br \/>\nexten = _9XXXXXXXXXX,1,Goto(custom-gv,${EXTEN:-10},1)<\/p>\n<\/blockquote>\n<p><em><strong>Explanation:<\/strong> Any outgoing 10-digit number prefixed with a 9 will match this rule and go to the custom-gv section which we will set up later. The number that was dialed is passed (the &#8220;-10&#8221; excludes the 9 prefix from this) at the first dialplan rule.<\/em><\/p>\n<h2>The GV dialer<em><br \/>\n<\/em><\/h2>\n<p>Now we need to set up the custom-gv section:<\/p>\n<blockquote>\n<p style=\"padding-left: 30px;\">[custom-gv]<br \/>\nexten =&gt; _X.,1,Verbose(0, Custom-GV Preparing to call and park call at number ${EXTEN})<br \/>\nexten =&gt; _X.,n,Wait(1)<br \/>\nexten =&gt; _X.,n,Playback(pls-wait-connect-call)<br \/>\nexten =&gt; _X.,n,System(gvoice -e <span style=\"text-decoration: line-through;\">me@me.com<\/span> -p <span style=\"text-decoration: line-through;\">GVPassword<\/span> call ${EXTEN} <span style=\"text-decoration: line-through;\">IncomingNum<\/span> &amp;)<br \/>\nexten =&gt; _X.,n,Set(PARKINGEXTEN=701)<br \/>\nexten =&gt; _X.,n,Park()<\/p>\n<\/blockquote>\n<p><em><strong>Explanation:<\/strong> After you dial an outgoing number, you&#8217;ll be dropped in here. The Verbose() function tosses some output in debug level 0 and up (see the console for this output). The System() command dials the number with google voice. Make sure you change the items in <span style=\"text-decoration: line-through;\">strikethrough<\/span> to your own personal information. The call is then parked on extension 701 (70X extensions for parking are default. Switch to your parking extension range if you are using non-default options).<\/em><\/p>\n<h2>Routing GV callbacks<em><br \/>\n<\/em><\/h2>\n<p>Now you need to set up an incoming call rule. Direct all incoming calls from your sip number at this rule.<\/p>\n<blockquote>\n<p style=\"padding-left: 30px;\">[incoming-call-sifter]<br \/>\nexten = s,1,NoOp(CIDredirect)<br \/>\nexten = s,2,Verbose(0, Got incoming CID ${CALLERID(num)}, redirecting&#8230;)<br \/>\nexten = s,3,GotoIf($[&#8220;${CALLERID(num)}&#8221; == &#8220;<span style=\"text-decoration: line-through;\">GVNumber<\/span>&#8220;]?custom-park,s,1)<br \/>\nexten = s,4,Goto(<span style=\"text-decoration: line-through;\">section-to-route-normal-incoming-calls<\/span>,s,1)<\/p>\n<\/blockquote>\n<p><em><strong>Explanation:<\/strong> If your google voice number rings your PBX, you know that it&#8217;s connecting you to the call you just dialed, so we need to reconnect it to the extension you dialed from. We&#8217;ll handle linking of the incoming GV call and your outgoing call (which is now parked) in the next section (custom-park).<\/em><\/p>\n<h2>Bringing it all together<em><br \/>\n<\/em><\/h2>\n<p>The custom-park section links a google voice incoming call (which is actually ringing the person you originally dialed) with your original outgoing call (which is parked).<\/p>\n<blockquote>\n<p style=\"padding-left: 30px;\">[custom-park]<br \/>\nexten =&gt; s,1,Verbose(0, Got incoming GV Callback! Connecting to your original outgoing call&#8230;)<br \/>\nexten =&gt; s,2,ParkedCall(701)<\/p>\n<\/blockquote>\n<p><em><strong>Explanation:<\/strong> After you dialed your external number, your call was parked as google voice started dialing the other number. This section joins your outgoing call with google voice&#8217;s incoming call, so you are connected to the party you originally dialed.<\/em><\/p>\n<h2>You&#8217;re done!<\/h2>\n<p>[pullquote]Have comments, questions, or need clarification? Leave a  comment![\/pullquote]<\/p>\n<p>Well that turned out to be a bit longer than I expected, but if you know what you&#8217;re doing, you can just ignore the italicized text.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are numerous guides about setting up Google Voice and an incoming sip number for free outgoing calling. Sadly, all of the guides I found were written for FreePBX or some other Asterisk bundle, and also used a shell script<span class=\"ellipsis\">&hellip;<\/span><\/p>\n<div class=\"read-more\"><a href=\"http:\/\/protofusion.org\/wordpress\/2010\/06\/google-voice-and-asterisk\/\">Read more &#8250;<\/a><\/div>\n<p><!-- end of .read-more --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kadence_starter_templates_imported_post":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7,40],"tags":[74,250,254],"class_list":["post-419","post","type-post","status-publish","format-standard","hentry","category-linux","category-technology","tag-asterisk","tag-linux","tag-technology"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pNjAs-6L","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/protofusion.org\/wordpress\/wp-json\/wp\/v2\/posts\/419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/protofusion.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/protofusion.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/protofusion.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/protofusion.org\/wordpress\/wp-json\/wp\/v2\/comments?post=419"}],"version-history":[{"count":28,"href":"http:\/\/protofusion.org\/wordpress\/wp-json\/wp\/v2\/posts\/419\/revisions"}],"predecessor-version":[{"id":454,"href":"http:\/\/protofusion.org\/wordpress\/wp-json\/wp\/v2\/posts\/419\/revisions\/454"}],"wp:attachment":[{"href":"http:\/\/protofusion.org\/wordpress\/wp-json\/wp\/v2\/media?parent=419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/protofusion.org\/wordpress\/wp-json\/wp\/v2\/categories?post=419"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/protofusion.org\/wordpress\/wp-json\/wp\/v2\/tags?post=419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}