From ecfea29b48d9581725bd6d8a8eb25b090f25b55e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 26 Mar 2013 15:53:56 +0100 Subject: voicemail_check dialplan function --- misc/freeswitch/scripts/dialplan/functions.lua | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan/functions.lua') diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua index a47d9d3..6399c5e 100644 --- a/misc/freeswitch/scripts/dialplan/functions.lua +++ b/misc/freeswitch/scripts/dialplan/functions.lua @@ -756,31 +756,28 @@ function Functions.voicemail_message_leave(self, caller, phone_number) end -function Functions.voicemail_check(self, caller, phone_number) +function Functions.voicemail_check(self, caller, number) + require 'dialplan.voicemail'; local voicemail_account = nil; local voicemail_authorized = false; - - require 'dialplan.voicemail' - - if phone_number then - voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_number(phone_number); - else - if caller.auth_account_type == 'SipAccount' then - voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_sip_account_id(caller.auth_account.id); - voicemail_authorized = true; - end + + if number then + voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_number(number); + elseif caller.auth_account and tostring(caller.auth_account.class):lower() == 'sipaccount' then + voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_sip_account_id(caller.auth_account.id); + voicemail_authorized = true; end if not voicemail_account then + self.log:notice('FUNCTION_VOICEMAIL_CHECK - mailbox not found'); return { continue = false, code = 404, phrase = 'Mailbox not found', no_cdr = true } end - voicemail_account:menu(caller, voicemail_authorized); - - return { continue = false, code = 200, phrase = 'OK', no_cdr = true } + return voicemail_account:menu_main(caller, voicemail_authorized); end + function Functions.acd_membership_toggle(self, caller, agent_id, phone_number) -- Find caller's SipAccount local caller_sip_account = self:ensure_caller_sip_account(caller); -- cgit v1.2.3 From 6c8f3e9536da2e8364de6696f8e0bb38032d067c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Mar 2013 09:09:57 +0100 Subject: vmplay dialplan function added --- misc/freeswitch/scripts/dialplan/functions.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'misc/freeswitch/scripts/dialplan/functions.lua') diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua index 6399c5e..ce99953 100644 --- a/misc/freeswitch/scripts/dialplan/functions.lua +++ b/misc/freeswitch/scripts/dialplan/functions.lua @@ -102,6 +102,8 @@ function Functions.dialplan_function(self, caller, dialed_number) result = self:voicemail_message_leave(caller, parameters[3]); elseif fid == "vmcheck" then result = self:voicemail_check(caller, parameters[3]); + elseif fid == "vmplay" then + result = self:voicemail_play(caller, tostring(parameters[3]) .. '-' .. tostring(parameters[4]) .. '-' .. tostring(parameters[5]) .. '-' .. tostring(parameters[6]) .. '-' .. tostring(parameters[7])); elseif fid == "vmtg" then result = self:call_forwarding_toggle(caller, nil, parameters[3]); elseif fid == "acdmtg" then @@ -777,6 +779,18 @@ function Functions.voicemail_check(self, caller, number) end +function Functions.voicemail_play(self, caller, uuid) + require 'dialplan.voicemail'; + + local voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_sip_account_id(caller.auth_account.id); + + if voicemail_account then + local message = voicemail_account:message_play(caller, uuid); + end + + return { continue = false, code = 200, phrase = 'OK', no_cdr = true } +end + function Functions.acd_membership_toggle(self, caller, agent_id, phone_number) -- Find caller's SipAccount -- cgit v1.2.3 From 1b5cd43bcabd516f98117a16d44d2a7f1bf70600 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 8 Apr 2013 15:36:30 +0200 Subject: dtmf test --- misc/freeswitch/scripts/dialplan/functions.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'misc/freeswitch/scripts/dialplan/functions.lua') diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua index ce99953..2edc131 100644 --- a/misc/freeswitch/scripts/dialplan/functions.lua +++ b/misc/freeswitch/scripts/dialplan/functions.lua @@ -116,6 +116,8 @@ function Functions.dialplan_function(self, caller, dialed_number) result = self:call_parking_inout(caller, parameters[3], parameters[4]); elseif fid == "cpai" then result = self:call_parking_inout_index(caller, parameters[3]); + elseif fid == "test" then + result = self:test(caller, parameters[3]); end return result or { continue = false, code = 505, phrase = 'Error executing function', no_cdr = true }; @@ -912,3 +914,20 @@ function Functions.call_parking_inout_index(self, caller, stall_index) return { continue = false, code = 200, phrase = 'OK', no_cdr = true } end + + +function Functions.test(self, caller, name) + if tostring(name) == 'dtmf' then + while caller:ready() do + local digits = caller.session:read(1, 1, '', 30000, ''); + if digits == "" then + break; + end + caller:send_display('DTMF: ', digits); + caller.session:say(digits, "en", "number", "pronounced"); + self.log:devel('DTMF: ', digits); + end + end + + return { continue = false, code = 200, phrase = 'OK', no_cdr = true } +end -- cgit v1.2.3 From 8d8bf48aa95f979da8f67d274b66d5c207b8b667 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 8 Apr 2013 16:01:52 +0200 Subject: dtmf test --- misc/freeswitch/scripts/dialplan/functions.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'misc/freeswitch/scripts/dialplan/functions.lua') diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua index 2edc131..0c30b86 100644 --- a/misc/freeswitch/scripts/dialplan/functions.lua +++ b/misc/freeswitch/scripts/dialplan/functions.lua @@ -918,14 +918,21 @@ end function Functions.test(self, caller, name) if tostring(name) == 'dtmf' then + local digits = ''; while caller:ready() do - local digits = caller.session:read(1, 1, '', 30000, ''); - if digits == "" then - break; + if digits == '' then + caller:playback('ivr/ivr-love_those_touch_tones.wav'); end - caller:send_display('DTMF: ', digits); - caller.session:say(digits, "en", "number", "pronounced"); + digits = caller.session:read(1, 1, '', 5000, ''); self.log:devel('DTMF: ', digits); + caller:send_display('DTMF: ', digits); + if digits == '*' then + caller:playback('digits/star.wav'); + elseif digits == '#' then + caller:playback('digits/pound.wav'); + elseif digits ~= '' then + caller.session:say(digits, "en", "number", "pronounced"); + end end end -- cgit v1.2.3 From d6adfbba723de9732f24efd71f80c422ae1a40f0 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 8 Apr 2013 16:05:16 +0200 Subject: dtmf test --- misc/freeswitch/scripts/dialplan/functions.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'misc/freeswitch/scripts/dialplan/functions.lua') diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua index 0c30b86..7519ff9 100644 --- a/misc/freeswitch/scripts/dialplan/functions.lua +++ b/misc/freeswitch/scripts/dialplan/functions.lua @@ -918,13 +918,15 @@ end function Functions.test(self, caller, name) if tostring(name) == 'dtmf' then + self.log:info('FUNCTION_TEST_DTMF'); local digits = ''; + caller:answer(); while caller:ready() do if digits == '' then caller:playback('ivr/ivr-love_those_touch_tones.wav'); end digits = caller.session:read(1, 1, '', 5000, ''); - self.log:devel('DTMF: ', digits); + self.log:info('DTMF: ', digits); caller:send_display('DTMF: ', digits); if digits == '*' then caller:playback('digits/star.wav'); -- cgit v1.2.3 From f89becb96fdfe7a247f04b6f472496972ba5827e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 4 Jun 2013 11:22:24 +0200 Subject: pager function added --- misc/freeswitch/scripts/dialplan/functions.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'misc/freeswitch/scripts/dialplan/functions.lua') diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua index 7519ff9..efd1f05 100644 --- a/misc/freeswitch/scripts/dialplan/functions.lua +++ b/misc/freeswitch/scripts/dialplan/functions.lua @@ -118,6 +118,8 @@ function Functions.dialplan_function(self, caller, dialed_number) result = self:call_parking_inout_index(caller, parameters[3]); elseif fid == "test" then result = self:test(caller, parameters[3]); + elseif fid == "pager" then + result = self:pager(caller, parameters[3]); end return result or { continue = false, code = 505, phrase = 'Error executing function', no_cdr = true }; @@ -940,3 +942,20 @@ function Functions.test(self, caller, name) return { continue = false, code = 200, phrase = 'OK', no_cdr = true } end + + +function Functions.pager(self, caller, pager_group_id) + require 'common.pager'; + local pager = common.pager.Pager:new{ log = self.log, database = self.database, caller = caller }:find_by_id(pager_group_id); + + if not pager then + self.log:notice('FUNCTION_PAGER not found - pager_group=', pager_group_id); + return { continue = false, code = 404, phrase = 'No such pager group', no_cdr = true } + end + + self.log:info('FUNCTION_PAGER pager_group=', pager_group_id); + caller:answer(); + pager:enter(); + + return { continue = false, code = 200, phrase = 'OK', no_cdr = true } +end -- cgit v1.2.3