VOCP System - CallerID - Filtering


You can setup VOCP so that calls from a given number start at some arbitrary box and message, instead of the default root box (box 001).

To direct incoming calls to different boxes based on the caller ID (CID) information, you need to do two things. Edit /etc/vocp/vocp.conf and make sure the callid_filter parameter is uncommented (no '#' at the start of the line) and pointing to the correct file:

#### Caller ID Filter ####
# If you have caller id and your modem groks it and you'd like
# to shunt particular callers to specific boxes (instead of starting
# at the root, 001, box), uncomment this line and edit the file
# it points to
callid_filter /etc/vocp/cid-filter.conf

Now, fire up vi (or emacs, nedit or whatever) and edit /etc/vocp/cid-filter.conf

This file has a format similar to vocp.conf:

# Lines starting with '#' are ignored
REGEX WHITESPACE[S] BOXNUM 

REGEX is a regular expression that will be checked against caller id info.
WHITESPACE[S] is 1 or more (space or tab) characters
BOXNUM is a sequence of digits that indicates the box number to jump to if a match is made.

Replace REGEX on each line with some Perl magic - a regular expression that will match the incoming phone number. Here is a simple example regexp:

555[\s\-]*1212


Regular Expressions

 

Notice that stuff in the [square brackets]? If you're new to Perl and regular expressions, [\s\-]* simply means "0 or more spaces and/or dashes" (that '\-' isn't strictly required, you just could use '-' but it's a good habit to escape dashes unless you mean to use them for a range of values). So

5551212
555-1212
and
555 1212

would all match this regex. If I know that my phone company always sends the caller id info in the same way, I can simplify the regex. For instance, to match '555-1212', I can just use:

555\-1212

Take note of the '\-' to match '-'; this is because the '-' character is special in regexland, so it must be escaped to actually mean "the '-' character".

Supposing I would like calls from this number to start off directly in box 300, the cid-filter.conf line would be:

555[\s\-]*1212		300

That's it. The hardest part is figuring out your regular expressions (and it's not that hard, really). The advantage of using regexes is that they can be very powerful. Here's one:

(^\s*9\d9|555[\s\-]*1234|555[\s\-]*9876)     700

This expressions says that all calls from:

555-1234
555-9876
and all calls from the 9X9 area codes (909, 919, 929, ...) shall be started in box 700. Take a look at this regex tutorial or do a perldoc perlfaq6 to learn more about regular expressions.


Notes on cid-filter.conf

The cid-filter.conf file is documented, so take a peek inside. The important points are:

  • Get your regexes right. They will depend on the format for numbers as reported by your telco.
  • Keep to the "REGEXP BOXNUM" format
  • Order your filters from most specific to least specific. This last point is important. If you have these lines in cid-filter.conf
    ^514 600 
    514[\s\-]*555[\s\-]*1212 200
    
    You are saying "All calls from the 514 area code go to 600, calls from 514-555-1212 go to 200" - this won't work, because calls from 514-555-1212 will match the "All calls from 514 area code" first and go straight to box 600. The correct config in this case would be:
    514[\s\-]*555[\s\-]*1212   200 
    ^514  600
    


Testing your filters

After you've set up a few filters, it's time to testtesttest. You won't need to ask everybody to call you up in order to test that your CID filters are working - just use VOCPLocal. See the box configuration testing page or the included vocplocal.txt file for details on using the local VOCP interface, which allows you to interact with your voice system using your keyboard and speakers. The important part, in our case, is that you can edit the /usr/local/vocp/bin/vocplocal.pl file and set the $CALLER_ID variable to any value you like. Then you just launch vocplocal.pl to see if your filter is doing what you expect.

Go Back


© 2000-2003 Psychogenic inc. All rights reserved.