Call Us Today! 877.742.2583




Page tree
Skip to end of metadata
Go to start of metadata

About

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.

Initial author: Sud0er

Requirements: mod_perl

The Perl Script

ldaplookup.pl  Expand source

Dialplan

Public

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 conf/dialplan/public.xml:

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).

Default

Since I hard-coded the script to transfer calls to an extension in the default context, the rest goes in conf/dialplan/default.xml:

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.