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:
parent
36cce58478
commit
7a6bfcec41
|
|
@ -24,8 +24,7 @@
|
|||
|
||||
--predefined variables
|
||||
predefined_destination = "";
|
||||
max_tries = "3";
|
||||
digit_timeout = "5000";
|
||||
fallback_destination = "";
|
||||
|
||||
--define the trim function
|
||||
require "resources.functions.trim";
|
||||
|
|
@ -44,15 +43,22 @@
|
|||
--get and save the variables
|
||||
if (session:ready()) then
|
||||
sound_greeting = session:getVariable("sound_greeting");
|
||||
sound_pin = session:getVariable("sound_pin");
|
||||
sound_extension = session:getVariable("sound_extension");
|
||||
pin_number = session:getVariable("pin_number");
|
||||
sounds_dir = session:getVariable("sounds_dir");
|
||||
caller_id_name = session:getVariable("caller_id_name");
|
||||
caller_id_number = session:getVariable("caller_id_number");
|
||||
predefined_destination = session:getVariable("predefined_destination");
|
||||
fallback_destination = session:getVariable("fallback_destination");
|
||||
digit_min_length = session:getVariable("digit_min_length");
|
||||
digit_max_length = session:getVariable("digit_max_length");
|
||||
digit_timeout = session:getVariable("digit_timeout");
|
||||
context = session:getVariable("context");
|
||||
privacy = session:getVariable("privacy");
|
||||
max_tries = session:getVariable("max_tries");
|
||||
pin_tries = session:getVariable("pin_tries");
|
||||
extension_tries = session:getVariable("extension_tries");
|
||||
end
|
||||
|
||||
--set the sounds path for the language, dialect and voice
|
||||
|
|
@ -74,6 +80,30 @@
|
|||
digit_max_length = "11";
|
||||
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 (session:ready() and sound_greeting) then
|
||||
session:streamFile(sound_greeting);
|
||||
|
|
@ -84,7 +114,7 @@
|
|||
if (session:ready() and pin_number) then
|
||||
min_digits = string.len(pin_number);
|
||||
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
|
||||
--pin is correct
|
||||
else
|
||||
|
|
@ -102,7 +132,10 @@
|
|||
destination_number = predefined_destination;
|
||||
else
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue