Voicemail tutorial (#2451)

* Update macro.lua

Add additional macros for the tutorial.

* Create tutorial.lua

* Update index.lua

* Update record_greeting.lua

Add menu variable to route back to appropriate place in the flow.

* Update record_menu.lua

Add menu variable to accommodate the tutorial.

* Update change_password.lua

Add menu variable to accommodate the tutorial.

* Update record_name.lua

Add menu variable to accommodate the tutorial.

* Update voicemail_edit.php

Add option to play tutorial on next login.

* Update app_languages.php

* Update app_config.php

Add voicemail_tutorial to database.

* Update extension_edit.php

Set "voicemail_tutorial" to true for new extensions.
This commit is contained in:
konradSC
2017-03-25 01:06:16 -04:00
committed by FusionPBX
parent be308e40bd
commit 5dcd3a1d2e
11 changed files with 339 additions and 20 deletions

View File

@@ -200,6 +200,7 @@
voicemail_attach_file = row["voicemail_attach_file"];
voicemail_local_after_email = row["voicemail_local_after_email"];
voicemail_transcription_enabled = row["voicemail_transcription_enabled"];
voicemail_tutorial = row["voicemail_tutorial"];
end);
--set default values
if (voicemail_local_after_email == nil) then
@@ -264,6 +265,7 @@
require "app.voicemail.resources.functions.record_name";
require "app.voicemail.resources.functions.message_count"
require "app.voicemail.resources.functions.mwi_notify";
require "app.voicemail.resources.functions.tutorial";
--send a message waiting event
if (voicemail_action == "mwi") then
@@ -314,7 +316,11 @@
--send to the main menu
timeouts = 0;
main_menu();
if (voicemail_tutorial == "true") then
tutorial("intro");
else
main_menu();
end
end
end

View File

@@ -24,7 +24,7 @@
-- POSSIBILITY OF SUCH DAMAGE.
--check the voicemail password
function change_password(voicemail_id)
function change_password(voicemail_id, menu)
if (session:ready()) then
--flush dtmf digits from the input buffer
session:flushDigits();
@@ -48,6 +48,11 @@
macro(session, "password_changed", 20, 3000, password);
--advanced menu
timeouts = 0;
advanced();
if (menu == "advanced") then
advanced();
end
if (menu == "tutorial") then
tutorial("record_greeting");
end
end
end
end

View File

@@ -264,7 +264,42 @@
if (name == "goodbye") then
table.insert(actions, {app="streamFile",data="voicemail/vm-goodbye.wav"});
end
--Tutorial
--Tutorial intro
if (name == "tutorial_intro") then
table.insert(actions, {app="streamFile",data="voicemail/vm-tutorial_yes_no.wav"});
end
--Tutorial to record your name 1
if (name == "tutorial_to_record_name") then
table.insert(actions, {app="streamFile",data="voicemail/vm-tutorial_record_name.wav"});
table.insert(actions, {app="streamFile",data="voicemail/vm-record_name2.wav"});
table.insert(actions, {app="streamFile",data="voicemail/vm-press.wav"});
table.insert(actions, {app="streamFile",data="digits/1.wav"});
end
--Tutorial to change your password press 1
if (name == "tutorial_change_password") then
table.insert(actions, {app="streamFile",data="voicemail/vm-tutorial_change_pin.wav"});
table.insert(actions, {app="streamFile",data="voicemail/vm-change_password.wav"});
table.insert(actions, {app="streamFile",data="voicemail/vm-press.wav"});
table.insert(actions, {app="streamFile",data="digits/1.wav"});
end
--Tutorial to record your greeting press 1
if (name == "tutorial_record_greeting") then
table.insert(actions, {app="streamFile",data="voicemail/vm-to_record_greeting.wav"});
table.insert(actions, {app="streamFile",data="voicemail/vm-press.wav"});
table.insert(actions, {app="streamFile",data="digits/1.wav"});
end
--Tutorial To skip
if (name == "tutorial_skip") then
table.insert(actions, {app="streamFile",data="ivr/ivr-to_skip.wav"});
table.insert(actions, {app="streamFile",data="voicemail/vm-press.wav"});
table.insert(actions, {app="streamFile",data="digits/2.wav"});
end
--if actions table exists then process it
if (actions) then
--set default values

View File

@@ -28,7 +28,7 @@
local Settings = require "resources.functions.lazy_settings"
--define a function to record the greeting
function record_greeting(greeting_id)
function record_greeting(greeting_id, menu)
local db = dbh or Database.new('system')
local settings = Settings.new(db, domain_name, domain_uuid)
@@ -88,7 +88,7 @@
--option to play, save, and re-record the greeting
if (session:ready()) then
timeouts = 0;
record_menu("greeting", voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".tmp.wav", greeting_id);
record_menu("greeting", voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".tmp.wav", greeting_id, menu);
end
else
--invalid greeting_id
@@ -101,10 +101,17 @@
if (session:ready()) then
timeouts = timeouts + 1;
if (timeouts < max_timeouts) then
record_greeting();
record_greeting(nil, menu);
else
timeouts = 0;
advanced();
if (menu == "tutorial") then
tutorial("finish")
end
if (menu == "advanced") then
advanced();
else
advanced();
end
end
end
end
@@ -116,4 +123,4 @@
end
end
end
end

View File

@@ -24,7 +24,7 @@
-- POSSIBILITY OF SUCH DAMAGE.
--record message menu
function record_menu(type, tmp_file, greeting_id)
function record_menu(type, tmp_file, greeting_id, menu)
if (session:ready()) then
--clear the dtmf digits variable
dtmf_digits = '';
@@ -55,7 +55,7 @@
session:streamFile(tmp_file);
--session:streamFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
--record menu (1=listen, 2=save, 3=re-record)
record_menu(type, tmp_file, greeting_id);
record_menu(type, tmp_file, greeting_id, menu);
elseif (dtmf_digits == "2") then
--save the message
dtmf_digits = '';
@@ -161,10 +161,21 @@
voicemail_id = voicemail_id};
dbh:query(sql, params);
advanced();
if (menu == "advanced") then
advanced();
end
if (menu == "tutorial") then
tutorial("finish")
end
end
if (type == "name") then
advanced();
if (menu == "advanced") then
advanced();
end
if (menu == "tutorial") then
tutorial("change_password")
end
end
elseif (dtmf_digits == "3") then
--re-record the message
@@ -178,10 +189,10 @@
if (file_exists(tmp_file)) then
os.remove(tmp_file);
end
record_greeting(greeting_id);
record_greeting(greeting_id, menu);
end
if (type == "name") then
record_name();
record_name(menu);
end
elseif (dtmf_digits == "*") then
if (type == "greeting") then
@@ -200,7 +211,7 @@
if (session:ready()) then
timeouts = timeouts + 1;
if (timeouts < max_timeouts) then
record_menu(type, tmp_file, greeting_id);
record_menu(type, tmp_file, greeting_id, menu);
else
if (type == "message") then
dtmf_digits = '';
@@ -213,10 +224,20 @@
if (file_exists(tmp_file)) then
os.remove(tmp_file);
end
advanced();
if (menu == "advanced") then
advanced();
end
if (menu == "tutorial") then
tutorial("finish")
end
end
if (type == "name") then
advanced();
if (menu == "advanced") then
advanced();
end
if (menu == "tutorial") then
tutorial("change_password")
end
end
end
end

View File

@@ -24,7 +24,7 @@
-- POSSIBILITY OF SUCH DAMAGE.
--define a function to record the name
function record_name()
function record_name(menu)
if (session:ready()) then
--flush dtmf digits from the input buffer
@@ -92,7 +92,7 @@
--option to play, save, and re-record the name
if (session:ready()) then
timeouts = 0;
record_menu("name", voicemail_dir.."/"..voicemail_id.."/recorded_name.wav");
record_menu("name", voicemail_dir.."/"..voicemail_id.."/recorded_name.wav",nil, menu);
if (storage_type == "base64") then
--delete the greeting
os.remove(voicemail_dir.."/"..voicemail_id.."/recorded_name.wav");

View File

@@ -0,0 +1,197 @@
-- Part of FusionPBX
-- Copyright (C) 2013 Mark J Crane <markjcrane@fusionpbx.com>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
--define function main menu
function tutorial (menu)
if (voicemail_uuid) then
--intro menu
if (menu == "intro") then
--clear the value
dtmf_digits = '';
--flush dtmf digits from the input buffer
session:flushDigits();
--play the tutorial press 1, to skip 2
if (session:ready()) then
if (string.len(dtmf_digits) == 0) then
dtmf_digits = macro(session, "tutorial_intro", 1, 3000, '');
end
end
--process the dtmf
if (session:ready()) then
if (dtmf_digits == "1") then
timeouts = 0;
tutorial("record_name");
elseif (dtmf_digits == "2") then
timeouts = 0;
tutorial("finish");
else
if (session:ready()) then
timeouts = timeouts + 1;
if (timeouts < max_timeouts) then
tutorial("intro");
else
timeouts = 0;
tutorial("finish");
end
end
end
end
end
--record name menu
if (menu == "record_name") then
--clear the value
dtmf_digits = '';
--flush dtmf digits from the input buffer
session:flushDigits();
--play the record name press 1
if (session:ready()) then
if (string.len(dtmf_digits) == 0) then
dtmf_digits = macro(session, "tutorial_to_record_name", 1, 100, '');
end
end
--skip the name and go to password press 2
if (session:ready()) then
if (string.len(dtmf_digits) == 0) then
dtmf_digits = macro(session, "tutorial_skip", 1, 3000, '');
end
end
--process the dtmf
if (session:ready()) then
if (dtmf_digits == "1") then
timeouts = 0;
record_name("tutorial");
elseif (dtmf_digits == "2") then
timeouts = 0;
tutorial("change_password");
else
if (session:ready()) then
timeouts = timeouts + 1;
if (timeouts < max_timeouts) then
tutorial("record_name");
else
tutorial("change_password");
end
end
end
end
end
--change password menu
if (menu == "change_password") then
--clear the value
dtmf_digits = '';
--flush dtmf digits from the input buffer
session:flushDigits();
--to change your password press 1
if (session:ready()) then
if (string.len(dtmf_digits) == 0) then
dtmf_digits = macro(session, "tutorial_change_password", 1, 100, '');
end
end
--skip the password and go to greeting press 2
if (session:ready()) then
if (string.len(dtmf_digits) == 0) then
dtmf_digits = macro(session, "tutorial_skip", 1, 3000, '');
end
end
--process the dtmf
if (session:ready()) then
if (dtmf_digits == "1") then
timeouts = 0;
change_password(voicemail_id, "tutorial");
elseif (dtmf_digits == "2") then
timeouts = 0;
tutorial("record_greeting");
else
if (session:ready()) then
timeouts = timeouts + 1;
if (timeouts < max_timeouts) then
tutorial("change_password");
else
tutorial("record_greeting");
end
end
end
end
end
--change greeting menu
if (menu == "record_greeting") then
--clear the value
dtmf_digits = '';
--flush dtmf digits from the input buffer
session:flushDigits();
--to record a greeting press 1
if (session:ready()) then
if (string.len(dtmf_digits) == 0) then
dtmf_digits = macro(session, "tutorial_record_greeting", 1, 100, '');
end
end
--skip the record greeting press 2. finishes the tutorial and routes to main menu
if (session:ready()) then
if (string.len(dtmf_digits) == 0) then
dtmf_digits = macro(session, "tutorial_skip", 1, 3000, '');
end
end
--process the dtmf
if (session:ready()) then
if (dtmf_digits == "1") then
timeouts = 0;
record_greeting(nil, "tutorial");
elseif (dtmf_digits == "2") then
timeouts = 0;
tutorial("finish");
else
if (session:ready()) then
timeouts = timeouts + 1;
if (timeouts < max_timeouts) then
tutorial("record_greeting");
else
tutorial("finish");
end
end
end
end
end
if (menu == "finish") then
--clear the value
dtmf_digits = '';
--flush dtmf digits from the input buffer
session:flushDigits();
--update play tutorial in the datebase
local sql = [[UPDATE v_voicemails
set voicemail_tutorial = 'false'
WHERE domain_uuid = :domain_uuid
AND voicemail_id = :voicemail_id
AND voicemail_enabled = 'true' ]];
local params = {domain_uuid = domain_uuid,
voicemail_id = voicemail_id};
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
end
dbh:query(sql, params);
--go to main menu
main_menu();
end
end
end