From fc96e3ae77a84c52ab6ade9e8846293364896f9d Mon Sep 17 00:00:00 2001 From: Luis Daniel Lucio Quiroz Date: Tue, 16 Mar 2021 15:43:21 -0400 Subject: [PATCH] DTMF handling this will give the dtmf_history (similar to the transfer_history variable) the use cases of this are only limited to the imagination --- .../resources/scripts/dtmf_handler.lua | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 app/scripts/resources/scripts/dtmf_handler.lua diff --git a/app/scripts/resources/scripts/dtmf_handler.lua b/app/scripts/resources/scripts/dtmf_handler.lua new file mode 100644 index 0000000000..d286c9690a --- /dev/null +++ b/app/scripts/resources/scripts/dtmf_handler.lua @@ -0,0 +1,37 @@ +require "resources.functions.split"; +require "resources.functions.trim"; + +local s = event:serialize("xml") +local name = event:getHeader("Event-Name") +--freeswitch.consoleLog("NOTICE", "Got event! " .. name) + +--freeswitch.consoleLog("NOTICE", "Serial!\n" .. s) + + +local name = event:getHeader("Event-Name"); +local channel_state = event:getHeader("Channel-State") or '[nil]'; +local original_channel_state = event:getHeader("Original-Channel-Call-State") or '[nil]'; +local channel_name = event:getHeader("Channel-Name") or '[nil]'; +local channel_call_uuid = event:getHeader("Channel-Call-UUID"); +local channel_timestamp = event:getHeader("Event-Date-Timestamp"); +local body = event:getBody(); +--freeswitch.consoleLog("NOTICE", "[dtmf_handler] event-name " .. name); +--freeswitch.consoleLog("NOTICE", "[dtmf_handler] original-channel-state " .. original_channel_state); +--freeswitch.consoleLog("NOTICE", "[dtmf_handler] channel-state " .. channel_state); +--freeswitch.consoleLog("NOTICE", "[dtmf_handler] channel-name " .. channel_name); +--freeswitch.consoleLog("NOTICE", "[dtmf_handler] channel-call-uuid " .. channel_call_uuid); +--freeswitch.consoleLog("NOTICE", "[dtmf_handler] channel_timestamp " .. channel_timestamp); +--freeswitch.consoleLog("NOTICE", "[dtmf_handler] body " .. body); + +session = freeswitch.Session(channel_call_uuid); +local v = split(body,"\n",true); +--freeswitch.consoleLog("NOTICE", "[dtmf_handler] type: " .. v[1]); +--freeswitch.consoleLog("NOTICE", "[dtmf_handler] type: " .. v[2]); +local vv = split(v[1],'=',true); +local dtmf_value = trim(vv[2]); +freeswitch.consoleLog("NOTICE", "[dtmf_handler] DTMF value: " .. dtmf_value); +local history = channel_timestamp .. ':' .. dtmf_value .. "\n"; +session:execute("push", "dtmf_history="..history); + +-- lua.conf.xml +--