mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Add new features to disa.lua (#2961)
1. Allow custom sound_pin & sound_extension 2. Allow customization of max_tries, pin_tries & extension_tries 3. Add fallback_destination - fall to it if caller did not entered extension number 4. Allow custom digit_timeout
This commit is contained in:
@@ -24,8 +24,7 @@
|
|||||||
|
|
||||||
--predefined variables
|
--predefined variables
|
||||||
predefined_destination = "";
|
predefined_destination = "";
|
||||||
max_tries = "3";
|
fallback_destination = "";
|
||||||
digit_timeout = "5000";
|
|
||||||
|
|
||||||
--define the trim function
|
--define the trim function
|
||||||
require "resources.functions.trim";
|
require "resources.functions.trim";
|
||||||
@@ -44,15 +43,22 @@
|
|||||||
--get and save the variables
|
--get and save the variables
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
sound_greeting = session:getVariable("sound_greeting");
|
sound_greeting = session:getVariable("sound_greeting");
|
||||||
|
sound_pin = session:getVariable("sound_pin");
|
||||||
|
sound_extension = session:getVariable("sound_extension");
|
||||||
pin_number = session:getVariable("pin_number");
|
pin_number = session:getVariable("pin_number");
|
||||||
sounds_dir = session:getVariable("sounds_dir");
|
sounds_dir = session:getVariable("sounds_dir");
|
||||||
caller_id_name = session:getVariable("caller_id_name");
|
caller_id_name = session:getVariable("caller_id_name");
|
||||||
caller_id_number = session:getVariable("caller_id_number");
|
caller_id_number = session:getVariable("caller_id_number");
|
||||||
predefined_destination = session:getVariable("predefined_destination");
|
predefined_destination = session:getVariable("predefined_destination");
|
||||||
|
fallback_destination = session:getVariable("fallback_destination");
|
||||||
digit_min_length = session:getVariable("digit_min_length");
|
digit_min_length = session:getVariable("digit_min_length");
|
||||||
digit_max_length = session:getVariable("digit_max_length");
|
digit_max_length = session:getVariable("digit_max_length");
|
||||||
|
digit_timeout = session:getVariable("digit_timeout");
|
||||||
context = session:getVariable("context");
|
context = session:getVariable("context");
|
||||||
privacy = session:getVariable("privacy");
|
privacy = session:getVariable("privacy");
|
||||||
|
max_tries = session:getVariable("max_tries");
|
||||||
|
pin_tries = session:getVariable("pin_tries");
|
||||||
|
extension_tries = session:getVariable("extension_tries");
|
||||||
end
|
end
|
||||||
|
|
||||||
--set the sounds path for the language, dialect and voice
|
--set the sounds path for the language, dialect and voice
|
||||||
@@ -74,6 +80,30 @@
|
|||||||
digit_max_length = "11";
|
digit_max_length = "11";
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (not digit_timeout) then
|
||||||
|
digit_timeout = "5000";
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not sound_pin) then
|
||||||
|
sound_pin = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-please_enter_pin_followed_by_pound.wav";
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not sound_extension) then
|
||||||
|
sound_extension = sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-enter_destination_telephone_number.wav";
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not max_tries) then
|
||||||
|
max_tries = "3";
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not pin_tries) then
|
||||||
|
pin_tries = max_tries;
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not extension_tries) then
|
||||||
|
extension_tries = max_tries;
|
||||||
|
end
|
||||||
|
|
||||||
--if the sound_greeting is provided then play it
|
--if the sound_greeting is provided then play it
|
||||||
if (session:ready() and sound_greeting) then
|
if (session:ready() and sound_greeting) then
|
||||||
session:streamFile(sound_greeting);
|
session:streamFile(sound_greeting);
|
||||||
@@ -84,7 +114,7 @@
|
|||||||
if (session:ready() and pin_number) then
|
if (session:ready() and pin_number) then
|
||||||
min_digits = string.len(pin_number);
|
min_digits = string.len(pin_number);
|
||||||
max_digits = string.len(pin_number)+1;
|
max_digits = string.len(pin_number)+1;
|
||||||
digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-please_enter_pin_followed_by_pound.wav", "", "\\d+");
|
digits = session:playAndGetDigits(min_digits, max_digits, pin_tries, digit_timeout, "#", sound_pin, "", "\\d+");
|
||||||
if (digits == pin_number) then
|
if (digits == pin_number) then
|
||||||
--pin is correct
|
--pin is correct
|
||||||
else
|
else
|
||||||
@@ -102,7 +132,10 @@
|
|||||||
destination_number = predefined_destination;
|
destination_number = predefined_destination;
|
||||||
else
|
else
|
||||||
dtmf = ""; --clear dtmf digits to prepare for next dtmf request
|
dtmf = ""; --clear dtmf digits to prepare for next dtmf request
|
||||||
destination_number = session:playAndGetDigits(digit_min_length, digit_max_length, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-enter_destination_telephone_number.wav", "", "\\d+");
|
destination_number = session:playAndGetDigits(digit_min_length, digit_max_length, extension_tries, digit_timeout, "#", sound_extension, "", "\\d+");
|
||||||
|
if (string.len(destination_number) == 0 and fallback_destination) then
|
||||||
|
destination_number = fallback_destination;
|
||||||
|
end
|
||||||
--if (string.len(destination_number) == 10) then destination_number = "1"..destination_number; end
|
--if (string.len(destination_number) == 10) then destination_number = "1"..destination_number; end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user