提交 9cf12686 authored 作者: Chad Phillips's avatar Chad Phillips

add 'exact_match' parameter to get_digits action -- convenience parameter which…

add 'exact_match' parameter to get_digits action -- convenience parameter which configures min_digits, max_digits, and digits_regex parameters for best user experience when the digits to be entered are already known.  useful for password validation.
上级 d9afb497
...@@ -16,7 +16,16 @@ function get_digits(action) ...@@ -16,7 +16,16 @@ function get_digits(action)
end end
local bad_input = action.bad_input or "ivr/ivr-that_was_an_invalid_entry.wav" local bad_input = action.bad_input or "ivr/ivr-that_was_an_invalid_entry.wav"
local digits_regex = action.digits_regex or "\\d+" local digits_regex = action.digits_regex or "\\d+"
local exact_match = action.exact_match
local key = action.storage_key or "digits" local key = action.storage_key or "digits"
-- Since exact match was passed, we can use it's length to set min and max
-- digits, and save the user any timeout wait.
if exact_match then
local digit_length = string.len(exact_match)
min_digits = digit_length
max_digits = digit_length
digits_regex = "^" .. exact_match .. "$"
end
local digits = session:playAndGetDigits(min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input, digits_regex) local digits = session:playAndGetDigits(min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input, digits_regex)
jester.debug_log("Got digits: %s", digits) jester.debug_log("Got digits: %s", digits)
jester.set_storage("get_digits", key, digits) jester.set_storage("get_digits", key, digits)
......
...@@ -10,6 +10,7 @@ jester.help_map.get_digits.actions.get_digits.description_long = [[This action c ...@@ -10,6 +10,7 @@ jester.help_map.get_digits.actions.get_digits.description_long = [[This action c
jester.help_map.get_digits.actions.get_digits.params = { jester.help_map.get_digits.actions.get_digits.params = {
min_digits = [[(Optional) The minimum number of digits to collect. Default is 1.]], min_digits = [[(Optional) The minimum number of digits to collect. Default is 1.]],
max_digits = [[(Optional) The maximum number of digits to collect. Default is 10.]], max_digits = [[(Optional) The maximum number of digits to collect. Default is 10.]],
exact_match = [[(Optional) If set, the entered digits must be an exact match to the value of this parameter. Setting this overrides the min_digits, max_digits, and digits_regex parameters.]],
max_tries = [[(Optional) The maximum amount of times that validation will fail before giving up. Default is 3.]], max_tries = [[(Optional) The maximum amount of times that validation will fail before giving up. Default is 3.]],
timeout = [[(Optional) Number of seconds to wait for max_digits before trying to validate. Default is 3.]], timeout = [[(Optional) Number of seconds to wait for max_digits before trying to validate. Default is 3.]],
terminators = [[(Optional) A string of keys that the user can use to end the collection before the timeout. Multiple values keys can be used, eg. '*' or '*#'. To accept no terminators, pass an empty string. Default is '#'.]], terminators = [[(Optional) A string of keys that the user can use to end the collection before the timeout. Multiple values keys can be used, eg. '*' or '*#'. To accept no terminators, pass an empty string. Default is '#'.]],
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论