[Freeswitch-users] hangup from LUA script

Gandalf Corvotempesta gandalf.corvotempesta at gmail.com
Tue Nov 24 09:08:37 UTC 2020


Hi guys,
i'm trying to make a very simple IVR with a lua script. I'm calling the lua
script in this way:

<action application="play_and_get_digits" data="6 12 10 7000 # say:'Please
inser order number.' silence_stream://250 order_number \d+" />
<action application="lua" data="myivr.lua"/>


And myivr.lua has something like this:

----------------------------------------------------------------

if session:getVariable("order_number") ~= "1234567" then
   session:speak("Error");
   session:hangup("NO_ROUTE_DESTINATION")
end
session:speak("connecting to customer. Please wait");
session:setAutoHangup(false);
session:execute("bridge",
"{ignore_early_media=true,bridge_generate_comfort_noise=true,effective_caller_id=anonymous,hangup_after_bridge=true}sofia/gateway/mygateway/123456789");

--------------------------------------------------------------------

Now, the questions:

1) Biggest issue is that when I call session:hangup() , the call is still
running, how can I force hangup ?

2) as this lua script is called after a "play_and_get_digits" (in
dialplan), how can I replace the "Error" inside IF with something that will
re-execute the dialplan from scratch asking for a new number ? In other
words, if numbers are not "1234567", I have to ask for the numbers again.

3) how can I set the bridge to be anonymous on the remote phone ? I don't
want the remote user to be able to see the caller number. It would be
better if remote user will se MY number and not the origin number (it's a
bridge: ORIGIN -> PBX -> REMOTE, the remote will see origin number. I want
to be anonymous or PBX number)

Tnx in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20201124/71c9324c/attachment.html>


More information about the FreeSWITCH-users mailing list