Asterisk Caller ID Blocking Recipe

By eric

Here’s another quick little Asterisk recipe that I threw together. It’s a handy because it only takes about 10 minutes to setup and is infinitely useful to the sales types. Just a note, this was done with Asterisk 1.4.8.

I wanted to do a little in AEL just to get a feel for it. It is a little AEL and a little regular extensions.conf type stuff.

The basic way that this CallerID Blocking recipe works is to use the Asterisk DB. An entry with the family of CIDBlock and the key of the dialing users extension will have a value of 1 or 0. The user initially sets their preference to either enabled (1) or disabled (0). When the number gets dialed, the preference gets checked and then the CALLERID(name)/CALLERID(number) values are set accordingly. In order for the user to enable CID Blocking, they need to dial *81. It will stay enabled until they dial *82.

How do we accomplish this? Easy. The sounds come with the asterisk sounds package.

Open up your extensions.conf and add the following lines (to whichever context works for you):

; Enable CallerID Blocking for the dialing extension
exten => *81,1,Set(DB(CIDBlock/${CHANNEL:4:4})=1)
exten => *81,2,Playback(privacy-your-callerid-is)
exten => *81,3,Playback(enabled)
exten => *81,4,Hangup()

; Disable CallerID Blocking for the dialing extension
exten => *82,1,Set(DB(CIDBlock/${CHANNEL:4:4})=0)
exten => *82,2,Playback(privacy-your-callerid-is)
exten => *82,3,Playback(disabled)
exten => *82,4,Hangup()

The last modification that needs to happen is that you have to change the exten that dials out to check the DB and react accordingly. Here is a snippet of mine (with the numbers changed to protect the innocent):

; Outbound calling for 111.222.3456 (my phone number)
exten =>_1NXXNXXXXXX,1,Set(CIDBlock=${DB(CIDBlock/${CHANNEL:4:4})})
exten =>_1NXXNXXXXXX,2,Set(${IF($[${CIDBlock} = 1]?CALLERID(name)=Unavailable:CALLERID(name)=MyCompany)})
exten =>_1NXXNXXXXXX,3,Set(${IF($[${CIDBlock} = 1]?CALLERID(number)=0-1-999:CALLERID(number)=1112223456)})
exten =>_1NXXNXXXXXX,4,DIAL(SIP/provider/${EXTEN},60,tr)
exten =>_1NXXNXXXXXX,5,Hangup

That’s really all it takes to set it up. Quick and handy.

* Note: *81 & *82 are arbitrary number combinations. Adjust to what works for you.

If you’re feeling really frisky, I added this AEL extension to check the status of your CallerID Blocking on *83. For fun, I have also included my *67 script for those who need an idea of how its done. As with almost anything in Asterisk, there are many ways to do it, this is just how I chose to accomplish this.

// Extra's for sending things outbound
context outbound-extra {
   *83 => {
            Playback(privacy-your-callerid-is);
            Set(CIDBlock=${DB(CIDBlock/${CHANNEL:4:4})});
            if(${CIDBlock} == 1) {
                Playback(enabled);
            }
            else {
                Playback(disabled);
            }   
            Hangup();
   };

   *67 => {
      // Remove the *67 from the number we are dialing
      Set(dialed_number=${EXTEN:3:11});
      Set(CALLERID(name)=Unavailable):
      Set(CALLERID(number)=0-1-999):
      DIAL(SIP/provider/${dialed_number},60,tr);
      Hangup();
   };
};

Follow My Travels

Buy My Book

Archives

  • 2020
  • 2019
  • 2017
  • 2014
  • 2013
  • 2012
  • 2011
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006

New Posts By Email

writing