hangup from LUA script
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.
1) You mean the session is not ended or the script is still running? doing a hangup doesn't automatically end the script. You can do *return 'exit'* from the script (not from within a function in the script) to exit the script. 2) Why don't you put the entire functionality in the lua script using session:playAndGetDigits() and then use a goto if you want to ask again for the order number. On Tue, Nov 24, 2020 at 12:41 PM Gandalf Corvotempesta < gandalf.corvotempesta@gmail.com> wrote:
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. _________________________________________________________________________
The FreeSWITCH project is sponsored by SignalWire https://signalwire.com Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services. Build your next product on our scalable cloud platform.
Join our online community to chat in real time https://signalwire.community
Professional FreeSWITCH Services sales@freeswitch.com https://freeswitch.com
Official FreeSWITCH Sites https://freeswitch.com/oss https://freeswitch.org/confluence https://cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users https://freeswitch.com
Il giorno mar 24 nov 2020 alle ore 20:07 Abaci B <abaci64@gmail.com> ha scritto:
1) You mean the session is not ended or the script is still running? doing a hangup doesn't automatically end the script. You can do *return 'exit'* from the script (not from within a function in the script) to exit the script.
Even with return 'exit' the calling mobile phone is still connected to the PBX. I need to close the call hanging up all sides.
2) Why don't you put the entire functionality in the lua script using session:playAndGetDigits() and then use a goto if you want to ask again for the order number.
Good idea, i'll do in that way.
participants (2)
-
Abaci B
-
Gandalf Corvotempesta