Skip to main content

Example Extension Status

About

The following dialplan example shows how to implement what is a common scenario for me:

If a particular extension is registered to the SIP server the call should be bridged to the extension immediately and sent to the answerphone after 30s if there is no answer. If the particular extension is not registered then the call should be bridged directly to the answerphone. This is the same as call forward conditional or cfc.

Click here to expand Table of Contents

Dialplan Entry

dialplan to forward conditional

<extension name="inbound-test">
<condition field="destination_number" expression="^\*45$">
<action application="set" data="call_timeout=30"/>
<action application="set" data="continue_on_fail=true"/>
<action application="set" data="hangup_after_bridge=true"/>
<action application="bridge" data="sofia/${domain}/101%${domain}"/>
<action application="javascript" data="/usr/local/freeswitch/scripts/answermachine.js ${originate_disposition}"/>
</condition>
</extension> 

The important line is the one which sets continue_on_fail to true. If we try to bridge the call to extension 101 when it is not registered then Freeswitch will generate a NO_ROUTE_DESTINATION message which would usually result in the call being hung up. With continue_on_fail set to true, the call instead drops through to the answermachine, likewise if there is no answer within 30 seconds. The hangup_after_bridge command is necessary to avoid freeswitch continuing on to the answer phone when a successful bridge connection has been made.

Call Disposition

${originate_disposition} will contain values such as "USER_BUSY", "CALL_REJECTED", "NO_ANSWER". See Hangup_Causes for a complete list.