Call Forward Example

From FreeSWITCH Wiki
Jump to: navigation, search

Call Forward Example

This is an example of how to create a simple call forwarding dialplan. In this example, it utilizes hash, but you may prefer db. The choice is yours.

default.xml:

<extension name="call_forwarding_activativation">
 <condition field="destination_number" expression="^\*72$">
    <action application="play_and_get_digits" data="3 12 1 14000 # tone_stream://%(10000,0,350,440) silence_stream://250 cfwd_num \d+"/>	    
    <action application="hash" data="insert/${domain_name}-call_forward/${caller_id_number}/${cfwd_num}"/>
    <action application="playback" data="tone_stream://${bong-ring}"/>
    <action application="hangup"/>
 </condition>
</extension>
<extension name="call_forwarding_deactivation">
 <condition field="destination_number" expression="^\*73$">	     
    <action application="hash" data="delete/${domain_name}-call_forward/${caller_id_number}/${destination_number}"/>
    <action application="playback" data="tone_stream://${bong-ring}"/>
    <action application="hangup"/>
 </condition>
</extension>
<extension name="call_forwarding_number" continue="true">
 <condition>
    <action application="set" data="call_forwarding_number=${hash(select/${domain_name}-call_forward/${destination_number})}"/>
 </condition>
</extension>

features.xml:

<extension name="is_forward">
 <condition field="destination_number" expression="^is_forward$"/>
 <condition field="${call_forwarding_number}" expression="^(\d+)$">
    <action application="transfer" data="$1 XML default"/>
 </condition>
</extension>

Also, default.xml:

For instance, you can call the is_forward features before you bridge to your phone extension (You need to implement the extension of your choice). Also, you need to make sure that you have a support dialplan to dial out and terminate your forwarding number.
<action application="execute_extension" data="is_forward XML features"/>
<action application="bridge" data="user/${dialed_extension}@${domain_name}"/>


See also: