A simple script to sort incoming calls based on an LDAP entry,sort of a roll-your-own Grand Central. This is rather hackish: for example, I (ab)used the destinationIndicator field- this is an old field meant for directing telegraphs, but I didn't want to mess with my LDAP schema. The script pulls an extension name directly out of the destinationIndicator field and transfers the call there. I'm providing this script as much as anything to document some of the stuff I came across in putting it together in the hopes I can save other folks some confusion. YMMV.
The Perl Script
Now, we need to add entries to the XML files. Starting with the default configuration files from when I compiled Freeswitch, I added this to
For this to work, Freeswitch has to match the condition - in this case, "MYDID" would have to exactly match the DID number I get from my SIP provider (in my case, Gizmo). Also, the script above has to live in the Freeswitch scripts directory (you can also provide a fully-qualified path on the filesystem).
Since I hard-coded the script to transfer calls to an extension in the default context, the rest goes in
These extensions define what Freeswitch does with a call; I have three possibilities, whitelist, greylist and blacklist. Whitelist and blacklist have to be specifically set in the LDAP database, otherwise the script defaults to sending calls to the greylist. Here, the greylist extension drops the call right into the voicemail for "myid"; whitelist transfers the call to the "myid" directory entry in the default context; blacklist hangs up immediately.
The extension name parameter is, as far as I can tell, arbitrary; Freeswitch matches the call's destination based on the condition expressions for each extension, not the name, and the destination_number we match on is what the perl script sets.