Call Us Today! 877.742.2583




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

About

by Steve Ward

How to use force_transfer_context in a dialplan.

 

 Click here to expand Table of Contents

Getting the page started...

Example: Making a transfer-handling context

<?xml version="1.0" encoding="utf-8"?>
<!--
    This context is designed only to be accessed by channels which are bridged and receive a
    transfer/REFER.  The force_transfer_context channel variable is set prior to executing a
    bridge so that the channel's ROUTING state will process this context for handling a transfer/REFER.

    This context is NOT designed to be associated with any SIP profile.  If that is maintained, no call sent to
    this box can directly access this context (at least that is one way to implement this).
    
    When a channel performs a bridge in another context (e.g. the default context), do your bridge something like this:
    <action application="set" data="force_transfer_context=transfer_handler"/>
    <action application="bridge" data="YOUR DESTINATION!!!"/>
    
    However, BEWARE!!!  Leaving force_transfer_context set to this context will affect ANY transfer of a channel
    for the time that force_transfer_context is set.
    
    So, for example, if you have some kind of continuation after a bridge, you may want to do something like:
    
    <action application="set" data="force_transfer_context=transfer_handler"/>
    <action application="bridge" data="YOUR DESTINATION!!!"/>
    <action application="unset" data="force_transfer_context"/>
--> 
<include>
  <context name="transfer_handler">

    <!-- transfer_handler extensions explicitly defined in this file go here.  -->
    <!-- Any extensions here will be processed first.                          -->
    <extension name="unloop">
      <condition field="${unroll_loops}" expression="^true$"/>
      <condition field="${sip_looped_call}" expression="^true$">
        <action application="deflect" data="${destination_number}"/>
      </condition>
    </extension>

    <!-- Set ringback and transfer_ringback to provide US ringback.      -->
    <!-- If this freeswitch server receives a 180, US ringback will be   -->
    <!-- locally generated and the caller to this freeswitch server will -->
    <!-- hear it.  (If a 183 is received, the associated media is passed -->
    <!-- to the original caller.)                                        -->
    <extension name="set_default_ringback" continue="true">
      <condition field="destination_number" expression="^.*$" break="never">
        <action application="set" data="ringback=${us-ring}"/>
        <action application="set" data="transfer_ringback=${us-ring}"/>
      </condition>
    </extension>

    <!-- The following logic defined in the below TRANSFER extension makes it -->
    <!-- so that ANY ARBITRARY destination to which a channel is transferred  -->
    <!-- will be accepted and bridged to via the dial string in the bridge    -->
    <!-- command.                                                             -->
    <extension name="TRANSFER">
      <condition field="destination_number" expression="^(.*)$">
        <!-- CHANGE THE DIAL STRING TO SUIT YOUR NEEDS!  THIS ONE DEPENDS ON A GATEWAY DEFINED AS 'rtr-1' -->
        <action application="bridge" data="sofia/gateway/rtr-1/$1"/>
        <action application="hangup"/>
      </condition>
    </extension>

    <!-- Extensions defined in other files:                                    -->
    <NOLOAD-X-PRE-PROCESS cmd="include" data="transfer_handler/*.xml"/>

  </context>
</include>