title: Transferring Calls between FreeSWITCH and Session Manager
body: <p>Transferring Calls between FreeSWITCH and Session Manager</p>
  
  <p>We have a Avaya Session Manager and a FreeSWITCH as a feature Server connected with it.</p>
  
  <ul>
  <li>Call from the Avaya CM World routed to the FreeSWITCH via Avaya Session Manager.</li>
  <li>In FreeSWITCH we do some processing (replace the Caller ID) and</li>
  <li>send it back to the Session Manager</li>
  </ul>
  
  <p>FreeSWITCH handles the Call the as follows </p>
  
  <p>Call come from SM 1.2.3.4</p>
  
  <ul>
  <li>a dialplan calls a lua script 
  ** dnis may be 19131913</li>
  <li>this lua script does the processing (db lookup, and so on ...)</li>
  <li>finally it calls <code>session:transfer("tosm" .. dnis, "XML", "AS5850")</code>; to transfer the call</li>
  <li>a dialplan matching tosm19131913 does a bridge back to SM 1.2.3.4</li>
  </ul>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;extension name="AVAYA SM"&gt;
     &lt;condition field="destination_number" expression="^tosm(\d*)$"&gt;
        &lt;action application="bridge" data="sofia/AS5850/0*$1@1.2.3.4"/&gt;
     &lt;/condition&gt;
  &lt;/extension&gt;
  </code></pre>
  
  <p>This works relatively fine but the problem is that FS still holds the call with two channels as long as the call exists. This consumes two channels on the Session Manager wich is expensive.</p>
  
  <p>It is possible on FreeSWITCH commandline to drop the channels so that the call leaves the FS completely. The command to do this is uuid_simplify.</p>
  
  <p>I've tried to execute that command from lua script with </p>
  
  <pre><code>  my_fs_api = freeswitch.API()
    my_exec_result = my_fs_api:executeString("sofia status")
    my_exec_result = my_fs_api:executeString("uuid_simplify " .. my_ssession_uuid)
    freeswitch.consoleLog("notice","\n\n[1c]   result " .. my_exec_result .. "\n\n")
  </code></pre>
  
  <p>but it does not work.</p>
  
  <p>I've tried to remove <code>session:tranfer</code> from session transfer and use deflect on the dialplan. This also dosn't work.</p>
  
  <p>Any ideas?</p>