Sometimes you want or need an extension in a public place that needs to block outgoing calls some of the time. For instance one client has a fax machine that also has a handset built into the unit. There’s no way to disable the handset unless you use a super cumbersome locking mechanism built into the firmware. One approach might be to use a secret dialing prefix for this one extension. However, dialed numbers appear on the fax confirmation printouts so a simple dialplan_prefix-as_access_code might not stay secret for very long. My solution was to have a secret extension that the user dials before sending. This flips a bit and allows one call to be made. After the call is made the bit is flipped back. Freeswitch custom variables are destroyed after a call has ended so we cannot pass on our bit with the dialplan alone. We need a little help. If you’re already using mysql or postgres you might consider storing it there. I was not in this camp so I just opted for a file.
<extension name="enable a fax out" > <condition field="destination_number" expression="^(6789)$"> <action application="answer"/> <action application="sleep" data="500"/> <action application="playback" data="ivr/ivr-you_may.wav"/> <action application="playback" data="ivr/ivr-send_fax_now.wav"/> <action application="set" data="${system(/bin/echo 1 > /var/fax/faxsetting)} "/> <action application="set" data="faxout_status=${system(/bin/cat /var/fax/faxsetting)} "/> <action application="sleep" data="1000"/> <action application="log" data="point1 Faxout status set to [${destination_number}] , ${faxout_status}"/> <action application="playback" data="voicemail/vm-goodbye.wav"/> <action application="sleep" data="550"/> <action application="hangup"/> </condition> </extension>
After you’ve dialed the obscure extension number, you’re allowed one outgoing call from extension 1016. We’ve set our bit to 1.
<extension name="faxout route route, x1016"> <condition field="caller_id_number" expression="^(1016)$" require-nested="true"/> <condition field="destination_number" expression="^91(1{0,1}\d{10})$"> <action application="set" data="faxout_status=${system(/bin/cat /var/fax/faxsetting)} "/> <action application="log" data="point2, faxout status set to ${faxout_status}"/> <action application="set" data="my_dest=${destination_number:2}"/> <action application="log" data="my_dest is set to ${my_dest}"/> <action application="execute_extension" data="1016_${faxout_status}"/> </condition> </extension>
Here we’ve put our bit from the file into a variable and route accordingly.
If it’s set to 1 we route here:
<extension name="1016_1" > <condition field="destination_number" expression="^(1016_1)$"> <action application="set" data="${system(/bin/echo 0 > /var/fax/faxsetting)} "/> <action application="export" data="suppress_cng=true"/> <action application="set" data="sip_h_X-accountcode=${accountcode}"/> <action application="set" data="sip_h_X-Tag="/> <action application="set" data="call_direction=outbound"/> <action application="set" data="hangup_after_bridge=true"/> <action application="set" data="effective_caller_id_number=YOURCALLERIDHERE"/> <action application="set" data="inherit_codec=true"/> <action application="set" data="continue_on_fail=true"/> <action application="log" data="my_dest is set to ${my_dest}"/> <action application="bridge" data="sofia/gateway/flowroute/1${my_dest}"/> </condition> </extension>
If not then send them here:
<extension name="1016_0" > <condition field="destination_number" expression="^(1016_0)$"> <action application="answer"/> <action application="sleep" data="500"/> <action application="playback" data="ivr/ivr-not_have_permission.wav"/> <action application="playback" data="voicemail/vm-goodbye.wav"/> <action application="sleep" data="550"/> <action application="hangup"/> </condition> </extension>
bub-bye!
If you have another way to handle this situation, or have any improvements feel free to comment!
Thanks!