<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hi Guys!</div><div>Does anyone can point me the right direction to work on changing remote Hangup Cause and give my FS customer another Hangup Cause?</div><div><br></div><div>I'm lost :(</div><div>Thank you so much</div><div>Max</div><div><br></div><div><br></div><br><div><br><div>-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>Hi,<br>I'm creating a Lua script for managing different call scenario.<br>At the moment I'm stuck with a problem regarding the interoperability between Freeswitch and some potential customer. The problem regards the hangup cause that Freeswitch is sending to their softswitch, to allow a their automatic rerouting based on some Hangup Cause.<br>I got a request to send different Hangup Cause, so the Customer switch can automatically reroute call to another carrier. Here is the explaination<br><font class="Apple-style-span" color="#0064c3"><br><br></font><b>The scenario is:</b><br>All the endpoints are using a Public IP and no NAT is involved in these steps.<br><font class="Apple-style-span" color="#0064c3"><br></font>CUSTOMER ------------------&gt; &nbsp; MY_FREESWITCH &nbsp;&nbsp;-----------------&gt; &nbsp; REMOTE_CARRIER<br><font class="Apple-style-span" color="#0064c3"><br><br></font><b>What happen now:</b><br>The customer can send calls. On My freeswitch I will route calls based on Dialled Prefix to a Remote Carrier.&nbsp;<br>In my Lua script there is a conditional IF to check for remote disconnect cause, however it seems that the Release Cause is already sent (CALL_REJECTED) when I'm checking with my IF and so, even if the cause has been already sent it's sent again but what "win" is the first hangup sent.<br><font class="Apple-style-span" color="#0064c3"><br><br></font><b>What should be:</b><br>If the remote carrier will send me a&nbsp;CALL_REJECTED (isdn 21) I need to send to the remote customer another Hangup Cause for example:&nbsp;NORMAL_CIRCUIT_CONGESTION (isdn 34).<br>How to implement that?<br>I can create this remapping using a Diaplan XML configuration, but as I'm using a Lua script to manage the call, I found that is a Lua task to deal with the Hangup Cause, the dialplan rules are ignored.<br>The "telephony" part of the Lua script is working, what I'm trying to change is the release cause to make my customer happy as with a different release cause he can route traffic correctly and I will not loose my reputation :)<br><font class="Apple-style-span" color="#0064c3"><br><br></font><b>Below there is my Lua script (just the routing part)</b><br><font class="Apple-style-span" color="#0064c3"><br></font>Thank you so much!<br>Cheers<br>Max<br><font class="Apple-style-span" color="#0064c3"><br><br><br><br><br></font><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="font-family: Courier; ">function string.starts(String,Start)</span><br><span class="Apple-style-span" style="font-family: Courier; ">&nbsp; &nbsp;return string.sub(String,1,string.len(Start))==Start</span><br><span class="Apple-style-span" style="font-family: Courier; ">end</span><br><font class="Apple-style-span" color="#007527" face="Courier"><br></font><span class="Apple-style-span" style="font-family: Courier; ">session:execute("set","hangup_after_bridge=true")</span><br><span class="Apple-style-span" style="font-family: Courier; ">called_number = session:getVariable("destination_number")</span><br><font class="Apple-style-span" color="#007527" face="Courier"><br><br></font><span class="Apple-style-span" style="font-family: Courier; ">while session:answered()==false and session:ready()==true do</span><br><span class="Apple-style-span" style="font-family: Courier; white-space: pre; ">        </span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">        </span>if string.starts(called_number, "393") then</span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">                </span>-- ITALY MOBILE</span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">                </span>route_dial_string = "sofia/gateway/REMOTE_CARRIER/" ..called_number</span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">        </span>else</span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">                </span>-- OTHER DESTINATIONS</span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">                </span>route_dial_string = "sofia/gateway/OTHER_CARRIER/" ..called_number</span><br><div><font class="Apple-style-span" face="Courier"><span class="Apple-tab-span" style="white-space:pre">        </span>end</font></div><span class="Apple-style-span" style="font-family: Courier; white-space: pre; ">        </span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">        </span>session:execute("bridge",""..route_dial_string.."")</span><br><span class="Apple-style-span" style="font-family: Courier; white-space: pre; ">        </span><br><span class="Apple-style-span" style="font-family: Courier; white-space: pre; ">        </span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">        </span>-- ATTEMPT TO REMAP RELEASE CAUSE</span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">        </span>if ( session:getVariable("last_bridge_hangup_cause") == "CALL_REJECTED" ) then</span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">                </span>session:hangup("NORMAL_CIRCUIT_CONGESTION");</span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">        </span>end &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><br><span class="Apple-style-span" style="font-family: Courier; white-space: pre; ">        </span><br><span class="Apple-style-span" style="font-family: Courier; white-space: pre; ">        </span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">        </span>if session:ready()==false then</span><br><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-tab-span" style="white-space:pre">                </span>session:hangup();</span><br><font class="Apple-style-span" color="#007527" face="Courier"><br></font><span class="Apple-style-span" style="font-family: Courier; ">&nbsp; &nbsp;</span><br><span class="Apple-style-span" style="font-family: Courier; ">end</span><br><font class="Apple-style-span" color="#007527" face="Courier"><br><br></font><span class="Apple-style-span" style="font-family: Courier; ">session:hangup();</span><br><div><font class="Apple-style-span" face="Courier">freeswitch.consoleLog("info", "That's all folks!");</font></div></div></div></blockquote><font class="Apple-style-span" color="#0064c3"><br><br><br><br></font><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div></div></div><br></body></html>