I've got the following Lua script working in a sense, but the
InputCallback never seems to get called while the file is being
streamed to the call recipient. I've tried moving the "vmd start"
command and set input callback around a bit, but to no avail. I'm
testing this against a cell phone voice mailbox (Verizon).<br>
<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><div style="margin-left: 40px;">
<span style="font-family: courier new,monospace;">freeswitch.consoleLog("info","########################################################\n\n");</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
number_to_call = argv[1]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
message_to_play = "/opt/freeswitch/recordings/messages/" .. argv[2]</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
voicemail_detected = false;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
function onInput(s, type, obj)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
freeswitch.consoleLog("notice","*********** Type?: " .. type .. " *************\n");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
-- freeswitch.consoleLog("notice","*********** VMD?: " .. session:getVariable("vmd_detect") .. " *************\n");</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
if(type == "event" and voicemail_detected == false) then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
freeswitch.consoleLog("notice","************ VOICE MAIL/ANSWERING MACHINE DETECTED *************\n");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
voicemail_detected = true;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
return "break";</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
function playbackMessage()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
sleep_time = 1000;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
if(voicemail_detected) then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
sleep_time = 2500;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
-- sleep a second</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
session:sleep(sleep_time);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
-- play a file</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
session:streamFile(message_to_play);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
function notify()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
session = freeswitch.Session("{ignore_early_media=true}sofia/gateway/voicenetwork/1" .. number_to_call)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
if(session:ready()) then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
-- answer the call</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
session:answer();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
session:setInputCallback("onInput", "");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
session:execute("vmd","start");</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
playbackMessage();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
if(voicemail_detected) then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
freeswitch.consoleLog("notice","************ DOING PLAYBACK FOR VOICEMAIL/ANSWERING MACHINE *************\n");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
playbackMessage();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
freeswitch.consoleLog("notice", "********* hanging up session **********\n");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
-- hangup</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
session:hangup();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
notify();</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
freeswitch.consoleLog("info","########################################################\n\n");</span><br style="font-family: courier new,monospace;" clear="all"></div></blockquote>
<br>-- <br>Michael De Lorenzo<br>