<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2176/25/9/_/styles/combined.css?spaceKey=AST&amp;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?focusedCommentId=22087987#comment-22087987">Calling using Google</a></h2>
    <h4>Comment edited by             <a href="https://wiki.asterisk.org/wiki/display/~mdavenport">Malcolm Davenport</a>
     :</h4>
    <br/>
                        <h4>Changes (4)</h4>
                                
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >The code below picks up the phone, strip whatever is after the @ when the caller id comes (xxxxx@voice.google.com), and sets the name to External so I know it&#39;s an external call (vs internal): <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{noformat} <br></td></tr>
            <tr><td class="diff-unchanged" >exten =&gt; youraccount@gmail.com,1,Answer() <br>        same =&gt; n,Wait(1) <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >        same =&gt; n,Set(CALLERID(num)=${CUT(CALLERID(name),@,1)}) <br>        same =&gt; n,Set(CALLERID(name)=External) <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{noformat} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-unchanged" >The code below check if there is only 1 char in the num (which would mean it&#39;s blocked). If yes, then I remove the char to make an empty string, if not I keep it as is. Then the PrivacyManager is called. If there is a caller ID, it does not do anything. If there is none, it will catch it. Finally, I checked the caller id against my blacklist.  <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{noformat} <br></td></tr>
            <tr><td class="diff-unchanged" >same =&gt; n,Set(CALLERID(num)=${IF($[${LEN(${CALLERID(num)})}=1]?:${CALLERID(num)})}) <br>        same =&gt; n,Set(CALLERID(name)=${IF($[${LEN(${CALLERID(num)})}=0]?Anonymous:${CALLERID(name)})}) <br>        same =&gt; n,PrivacyManager() <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{noformat} <br></td></tr>
            <tr><td class="diff-unchanged" > <br> <br></td></tr>
            <tr><td class="diff-unchanged" >After that, you can handle the call the way you want.  <br>IE: same =&gt; n,Dial(...) <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                          <div class="notificationGreySide">
            <p>The caller ID tricks above are not working for incoming calls that block their caller ID. </p>

<p>If a calls comes with blocked ID, the solution above from Andrew will present the call as +@voice.go</p>

<p>The solution is to use the CUT function.</p>

<p>Below is the solution I have for my home system using Google voice, and digium phones. </p>

<p>If a call comes, I strip out the @voice.google.com , this is so I can use the function CALL BACK correctly. </p>

<p>If a call comes with blocked ID, I make the caller ID an empty string and call the function PrivacyManager(), which will ask the caller to enter their phone number.</p>

<p>On my phone, the call will then have the number they entered (which could be false), and Privacy Manager as a name.</p>

<p>You do not need to use the PrivacyManager, but it's a cool feature to play with. </p>



<p>The code below picks up the phone, strip whatever is after the @ when the caller id comes (xxxxx@voice.google.com), and sets the name to External so I know it's an external call (vs internal):</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>exten =&gt; youraccount@gmail.com,1,Answer()
        same =&gt; n,Wait(1)
        same =&gt; n,SendDTMF(1)
        same =&gt; n,Set(CALLERID(num)=${CUT(CALLERID(name),@,1)})
        same =&gt; n,Set(CALLERID(name)=External)
</pre>
</div></div>

<p>The code below check if there is only 1 char in the num (which would mean it's blocked). If yes, then I remove the char to make an empty string, if not I keep it as is. Then the PrivacyManager is called. If there is a caller ID, it does not do anything. If there is none, it will catch it. Finally, I checked the caller id against my blacklist. </p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>same =&gt; n,Set(CALLERID(num)=${IF($[${LEN(${CALLERID(num)})}=1]?:${CALLERID(num)})})
        same =&gt; n,Set(CALLERID(name)=${IF($[${LEN(${CALLERID(num)})}=0]?Anonymous:${CALLERID(name)})})
        same =&gt; n,PrivacyManager()
</pre>
</div></div>


<p>After that, you can handle the call the way you want. <br/>
IE: same =&gt; n,Dial(...)</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?focusedCommentId=22087987#comment-22087987">View Online</a>
              |
       <a id="reply-22087987" href="https://wiki.asterisk.org/wiki/display/AST/Calling+using+Google?replyToComment=22087987#comment-22087987">Reply To This</a>
           </div>

</div>
</div>
</div>
</div>
</body>
</html>