Add voicemail skip_instructions, and skip_greetings they both work the same as FreeSWITCH's mod_voicemail. Fix a problem session:ready check was preventing the voicemail from being saved and emailed.
This commit is contained in:
@@ -61,6 +61,8 @@
|
|||||||
destination_number = session:getVariable("destination_number");
|
destination_number = session:getVariable("destination_number");
|
||||||
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");
|
||||||
|
skip_instructions = session:getVariable("skip_instructions");
|
||||||
|
skip_greeting = session:getVariable("skip_greeting");
|
||||||
|
|
||||||
--set the sounds path for the language, dialect and voice
|
--set the sounds path for the language, dialect and voice
|
||||||
default_language = session:getVariable("default_language");
|
default_language = session:getVariable("default_language");
|
||||||
@@ -234,6 +236,11 @@
|
|||||||
table.insert(actions, {app="playAndGetDigits",data="voicemail/vm-record_message.wav"});
|
table.insert(actions, {app="playAndGetDigits",data="voicemail/vm-record_message.wav"});
|
||||||
table.insert(actions, {app="tone_stream",data="L=1;%(1000, 0, 640)"});
|
table.insert(actions, {app="tone_stream",data="L=1;%(1000, 0, 640)"});
|
||||||
end
|
end
|
||||||
|
--beep
|
||||||
|
if (name == "record_beep") then
|
||||||
|
actions = {}
|
||||||
|
table.insert(actions, {app="tone_stream",data="L=1;%(1000, 0, 640)"});
|
||||||
|
end
|
||||||
--to listen to the recording press 1
|
--to listen to the recording press 1
|
||||||
if (name == "to_listen_to_recording") then
|
if (name == "to_listen_to_recording") then
|
||||||
actions = {}
|
actions = {}
|
||||||
@@ -582,9 +589,12 @@
|
|||||||
|
|
||||||
--save the recording
|
--save the recording
|
||||||
function record_message()
|
function record_message()
|
||||||
if (session:ready()) then
|
|
||||||
--record your message at the tone press any key or stop talking to end the recording
|
--record your message at the tone press any key or stop talking to end the recording
|
||||||
|
if (skip_greeting == "true") then
|
||||||
|
result = macro(session, "record_beep", 1, 100);
|
||||||
|
else
|
||||||
result = macro(session, "record_message", 1, 100);
|
result = macro(session, "record_message", 1, 100);
|
||||||
|
end
|
||||||
|
|
||||||
--start epoch
|
--start epoch
|
||||||
start_epoch = os.time();
|
start_epoch = os.time();
|
||||||
@@ -626,8 +636,15 @@
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--record menu 1 listen to the recording, 2 save the recording, 3 re-record
|
--instructions press 1 to listen to the recording, press 2 to save the recording, press 3 to re-record
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
|
if (skip_instructions == "true") then
|
||||||
|
--save the message
|
||||||
|
macro(session, "message_saved", 1, 100, '');
|
||||||
|
macro(session, "goodbye", 1, 100, '');
|
||||||
|
--hangup the call
|
||||||
|
session:hangup();
|
||||||
|
else
|
||||||
record_menu();
|
record_menu();
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -865,6 +882,9 @@
|
|||||||
if (voicemail_action == "save") then
|
if (voicemail_action == "save") then
|
||||||
|
|
||||||
--voicemail prompt
|
--voicemail prompt
|
||||||
|
if (skip_greeting == "true") then
|
||||||
|
--skip the greeting
|
||||||
|
else
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
if (string.len(greeting_id) > 0) then
|
if (string.len(greeting_id) > 0) then
|
||||||
--play the greeting
|
--play the greeting
|
||||||
@@ -874,14 +894,12 @@
|
|||||||
result = macro(session, "person_not_available_record_message", 1, 100);
|
result = macro(session, "person_not_available_record_message", 1, 100);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--save the recording
|
|
||||||
if (session:ready()) then
|
|
||||||
record_message();
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--save the recording
|
||||||
|
record_message();
|
||||||
|
|
||||||
--save the message to the voicemail messages
|
--save the message to the voicemail messages
|
||||||
if (session:ready()) then
|
|
||||||
if (message_length > 2) then
|
if (message_length > 2) then
|
||||||
local sql = {}
|
local sql = {}
|
||||||
table.insert(sql, "INSERT INTO v_voicemail_messages ");
|
table.insert(sql, "INSERT INTO v_voicemail_messages ");
|
||||||
@@ -916,26 +934,21 @@
|
|||||||
end
|
end
|
||||||
dbh:query(sql);
|
dbh:query(sql);
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
--set the message waiting event
|
--set the message waiting event
|
||||||
if (session:ready()) then
|
|
||||||
if (message_length > 2) then
|
if (message_length > 2) then
|
||||||
local event = freeswitch.Event("message_waiting");
|
local event = freeswitch.Event("message_waiting");
|
||||||
event:addHeader("MWI-Messages-Waiting", "yes");
|
event:addHeader("MWI-Messages-Waiting", "yes");
|
||||||
event:addHeader("MWI-Message-Account", "sip:"..voicemail_id.."@"..domain_name);
|
event:addHeader("MWI-Message-Account", "sip:"..voicemail_id.."@"..domain_name);
|
||||||
event:fire();
|
event:fire();
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
--send the email with the voicemail recording attached
|
--send the email with the voicemail recording attached
|
||||||
if (session:ready()) then
|
|
||||||
if (message_length > 2) then
|
if (message_length > 2) then
|
||||||
if (string.len(voicemail_mail_to) > 3) then
|
if (string.len(voicemail_mail_to) > 3) then
|
||||||
send_email(uuid);
|
send_email(uuid);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
--local after email is false so delete the recording file
|
--local after email is false so delete the recording file
|
||||||
if (voicemail_local_after_email == "false") then
|
if (voicemail_local_after_email == "false") then
|
||||||
|
|||||||
Reference in New Issue
Block a user