Phrases: Save phrases xml and delete phrases from memcache after converting to/from base64 in app_defaults.
IVR: Using phrase greetings, DTMF tones now captured and executed, but only after playback completes (uses session:variable). Still searching for a better solution.
This commit is contained in:
parent
8fe9a0432d
commit
3b9c777d77
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
Portions created by the Initial Developer are Copyright (C) 2008-2015
|
||||||
the Initial Developer. All Rights Reserved.
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
|
|
@ -148,6 +148,27 @@ if ($domains_processed == 1) {
|
||||||
unset($sql, $prep_statement, $result, $row);
|
unset($sql, $prep_statement, $result, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//save the xml to the file system if the phrase directory is set
|
||||||
|
require_once "resources/functions/save_phrases_xml.php";
|
||||||
|
save_phrases_xml();
|
||||||
|
|
||||||
|
//delete the phrase from memcache
|
||||||
|
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||||
|
if ($fp) {
|
||||||
|
//get phrase languages
|
||||||
|
$sql = "select distinct phrase_language from v_phrases order by phrase_language asc ";
|
||||||
|
$prep_statement = $db->prepare(check_sql($sql));
|
||||||
|
$prep_statement->execute();
|
||||||
|
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
//delete memcache var
|
||||||
|
foreach ($result as $row) {
|
||||||
|
$switch_cmd .= "memcache delete languages:".$row['phrase_language'];
|
||||||
|
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||||
|
}
|
||||||
|
unset($sql, $prep_statement, $result, $row);
|
||||||
|
}
|
||||||
|
unset($fp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
@ -353,20 +353,29 @@
|
||||||
function menu()
|
function menu()
|
||||||
--increment the tries
|
--increment the tries
|
||||||
tries = tries + 1;
|
tries = tries + 1;
|
||||||
dtmf_digits = "";
|
|
||||||
min_digits = 1;
|
min_digits = 1;
|
||||||
|
session:setVariable("slept", "false");
|
||||||
if (tries == 1) then
|
if (tries == 1) then
|
||||||
if (debug["tries"]) then
|
if (debug["tries"]) then
|
||||||
freeswitch.consoleLog("notice", "[ivr_menu] greet long: " .. ivr_menu_greet_long .. "\n");
|
freeswitch.consoleLog("notice", "[ivr_menu] greet long: " .. ivr_menu_greet_long .. "\n");
|
||||||
end
|
end
|
||||||
dtmf_digits = session:playAndGetDigits(min_digits, ivr_menu_digit_len, 1, ivr_menu_timeout, ivr_menu_confirm_key, ivr_menu_greet_long, "", ".*");
|
--check if phrase
|
||||||
|
pos = string.find(ivr_menu_greet_long, ":", 0, true);
|
||||||
|
if (pos ~= nil and string.sub(ivr_menu_greet_long, 0, pos-1) == 'phrase') then
|
||||||
|
freeswitch.consoleLog("notice", "[ivr_menu] phrase detected\n");
|
||||||
|
session:playAndGetDigits(min_digits, ivr_menu_digit_len, 1, ivr_menu_timeout, ivr_menu_confirm_key, ivr_menu_greet_long, "", ".*");
|
||||||
|
dtmf_digits = session:getVariable("dtmf_digits");
|
||||||
|
session:setVariable("slept", "false");
|
||||||
|
else
|
||||||
|
dtmf_digits = session:playAndGetDigits(min_digits, ivr_menu_digit_len, 1, ivr_menu_timeout, ivr_menu_confirm_key, ivr_menu_greet_long, "", ".*");
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if (debug["tries"]) then
|
if (debug["tries"]) then
|
||||||
freeswitch.consoleLog("notice", "[ivr_menu] greet long: " .. ivr_menu_greet_short .. "\n");
|
freeswitch.consoleLog("notice", "[ivr_menu] greet long: " .. ivr_menu_greet_short .. "\n");
|
||||||
end
|
end
|
||||||
dtmf_digits = session:playAndGetDigits(min_digits, ivr_menu_digit_len, ivr_menu_max_timeouts, ivr_menu_timeout, ivr_menu_confirm_key, ivr_menu_greet_short, "", ".*");
|
dtmf_digits = session:playAndGetDigits(min_digits, ivr_menu_digit_len, ivr_menu_max_timeouts, ivr_menu_timeout, ivr_menu_confirm_key, ivr_menu_greet_short, "", ".*");
|
||||||
end
|
end
|
||||||
if (string.len(dtmf_digits) > 0) then
|
if (dtmf_digits ~= nil and string.len(dtmf_digits) > 0) then
|
||||||
if (debug["tries"]) then
|
if (debug["tries"]) then
|
||||||
freeswitch.consoleLog("notice", "[ivr_menu] dtmf_digits: " .. dtmf_digits .. "\n");
|
freeswitch.consoleLog("notice", "[ivr_menu] dtmf_digits: " .. dtmf_digits .. "\n");
|
||||||
end
|
end
|
||||||
|
|
@ -378,7 +387,7 @@
|
||||||
freeswitch.consoleLog("notice", "[ivr_menu] tries: " .. tries .. "\n");
|
freeswitch.consoleLog("notice", "[ivr_menu] tries: " .. tries .. "\n");
|
||||||
end
|
end
|
||||||
--run the menu again
|
--run the menu again
|
||||||
menu();
|
menu();
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -404,8 +413,8 @@
|
||||||
if (row.ivr_menu_option_action == "menu-exec-app") then
|
if (row.ivr_menu_option_action == "menu-exec-app") then
|
||||||
--get the action and data
|
--get the action and data
|
||||||
pos = string.find(row.ivr_menu_option_param, " ", 0, true);
|
pos = string.find(row.ivr_menu_option_param, " ", 0, true);
|
||||||
action = string.sub( row.ivr_menu_option_param, 0, pos-1);
|
action = string.sub(row.ivr_menu_option_param, 0, pos-1);
|
||||||
data = string.sub( row.ivr_menu_option_param, pos+1);
|
data = string.sub(row.ivr_menu_option_param, pos+1);
|
||||||
|
|
||||||
--check if the option uses a regex
|
--check if the option uses a regex
|
||||||
regex = string.find(row.ivr_menu_option_digits, "(", 0, true);
|
regex = string.find(row.ivr_menu_option_digits, "(", 0, true);
|
||||||
|
|
@ -422,6 +431,14 @@
|
||||||
data = data:gsub("${domain_name}", domain_name);
|
data = data:gsub("${domain_name}", domain_name);
|
||||||
end --if regex
|
end --if regex
|
||||||
end --if menu-exex-app
|
end --if menu-exex-app
|
||||||
|
if (row.ivr_menu_option_action == "phrase") then
|
||||||
|
action = 'phrase';
|
||||||
|
data = row.ivr_menu_option_param;
|
||||||
|
end
|
||||||
|
if (action == "lua") then
|
||||||
|
pos = string.find(data, " ", 0, true);
|
||||||
|
script = string.sub(data, 0, pos-1);
|
||||||
|
end
|
||||||
end --if regex match
|
end --if regex match
|
||||||
|
|
||||||
--execute
|
--execute
|
||||||
|
|
@ -432,10 +449,15 @@
|
||||||
freeswitch.consoleLog("notice", "[ivr_menu] action: " .. action .. " data: ".. data .. "\n");
|
freeswitch.consoleLog("notice", "[ivr_menu] action: " .. action .. " data: ".. data .. "\n");
|
||||||
end
|
end
|
||||||
--run the action
|
--run the action
|
||||||
if (ivr_menu_exit_sound ~= nil) then
|
if (action == 'phrase' or (script ~= nil and script == 'streamfile.lua')) then
|
||||||
session:streamFile(ivr_menu_exit_sound);
|
session:execute(action, data);
|
||||||
|
menu();
|
||||||
|
else
|
||||||
|
if (ivr_menu_exit_sound ~= nil) then
|
||||||
|
session:streamFile(ivr_menu_exit_sound);
|
||||||
|
end
|
||||||
|
session:execute(action, data);
|
||||||
end
|
end
|
||||||
session:execute(action, data);
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -470,9 +492,12 @@
|
||||||
menu();
|
menu();
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
session:streamFile(ivr_menu_invalid_sound);
|
if (action ~= 'phrase' and (script == nil or script ~= 'streamfile.lua')) then
|
||||||
|
session:streamFile(ivr_menu_invalid_sound);
|
||||||
|
end
|
||||||
menu();
|
menu();
|
||||||
end
|
end
|
||||||
|
|
||||||
end --end function
|
end --end function
|
||||||
|
|
||||||
--answer the session
|
--answer the session
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@
|
||||||
--define the on_dtmf call back function
|
--define the on_dtmf call back function
|
||||||
function on_dtmf(s, type, obj, arg)
|
function on_dtmf(s, type, obj, arg)
|
||||||
if (type == "dtmf") then
|
if (type == "dtmf") then
|
||||||
|
session:setVariable("dtmf_digits", obj['digit']);
|
||||||
freeswitch.console_log("info", "[streamfile] dtmf digit: " .. obj['digit'] .. ", duration: " .. obj['duration'] .. "\n");
|
freeswitch.console_log("info", "[streamfile] dtmf digit: " .. obj['digit'] .. ", duration: " .. obj['duration'] .. "\n");
|
||||||
if (obj['digit'] == "*") then
|
if (obj['digit'] == "*") then
|
||||||
return("false"); --return to previous
|
return("false"); --return to previous
|
||||||
|
|
@ -131,7 +132,14 @@
|
||||||
--stream file if exists
|
--stream file if exists
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
session:answer();
|
session:answer();
|
||||||
session:sleep(1000);
|
slept = session:getVariable("slept");
|
||||||
|
if (slept == nil or slept == "false") then
|
||||||
|
freeswitch.consoleLog("notice", "[ivr_menu] sleeping....\n");
|
||||||
|
session:sleep(1000);
|
||||||
|
if (slept == "false") then
|
||||||
|
session:setVariable("slept", "true");
|
||||||
|
end
|
||||||
|
end
|
||||||
session:setInputCallback("on_dtmf", "");
|
session:setInputCallback("on_dtmf", "");
|
||||||
session:streamFile(file_name);
|
session:streamFile(file_name);
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue