Archive for March, 2015

Thwarting robocallers with Freeswitch

Who doesn’t love an automated call informing us that the warranty on a car, of a brand that we do not own, is about to expire. Or that we’ve won a fabulous Caribbean vacation. Good times! Fortunately, with Freeswitch it is pretty simple to set up a whitelist to allow certain calls to ring through to an extension, while forcing unknown callers or callers with no caller ID to hit an IVR menu, sometimes referred to in phone-system jargon, as an auto-attendant. From there the callers can be asked to “Press one to continue.” within the IVR menu. I’ve been using this setup for over a year and it’s been FANTASTIC!

Let’s see how it works!

We’re assuming that we already have an IVR menu in place at extension 5001. It plays our audio file that says “You’re reached [person X], press one to continue.” And the action for pressing one transfers the caller to our desired extension or ring group.

Numbers have been changed to protect the innocent. For the purposes of this example let’s assume the following:

That our DID number is 212-555-1212. And we have a couple of friends that are not within the 212 area code that we want to explicitly whitelist. Again, for example’s sake, their numbers are 201-ABC-DEFG and 203-BCD-EFGH.

<extension name="12125551212">
        <condition field="destination_number" expression="^(12125551212)$">
                <action application="set" data="dialed_ext=$1"/>
        </condition>
        <condition field="caller_id_number" expression="^(\+1|1)?(212\d{7})|\+1201ABCDEFG|\+1203BCDEFGH$">
                <action application="ring_ready"/>
                <action application="set" data="call_timeout=18"/>
                <action application="set" data="hangup_after_bridge=true"/>
                <action application="set" data="continue_on_fail=true"/>
                <action application="bridge" data="sofia/internal/1001@${domain_name}"/>
                <action application="answer"/>
                <action application="info"/>
                <action application="sleep" data="1000"/>
                <action application="voicemail" data="default $${domain} 1001"/>
                <anti-action application="ring_ready"/>
                <anti-action application="set" data="call_timeout=10"/>
                <anti-action application="set" data="hangup_after_bridge=true"/>
                <anti-action application="set" data="continue_on_fail=true"/>
                <anti-action application="bridge" data="sofia/internal/5001@${domain_name}"/>
                <anti-action application="answer"/>
                <anti-action application="info"/>
                <anti-action application="sleep" data="1000"/>
        </condition>
</extension>

 

This xml snippet is from out default.xml dialplan.  Calls to our DID get routed here and satisfy the regex for this extension shown. Anyone from our local area code 212 gets through. And also our friends when their caller ID is not blocked.  In other words, if the caller is in the whitelist, they get transferred to extension 1001. If not, they get transferred to extension 5001 and after that, possibly a very hot and dark place with the gnashing of the teeth etc. etc.     😉