Lua Script with mod_vmd, setInputCallback doesn't seem to get called
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). freeswitch.consoleLog("info","########################################################\n\n");
number_to_call = argv[1] message_to_play = "/opt/freeswitch/recordings/messages/" .. argv[2]
voicemail_detected = false;
function onInput(s, type, obj) freeswitch.consoleLog("notice","*********** Type?: " .. type .. " *************\n"); -- freeswitch.consoleLog("notice","*********** VMD?: " .. session:getVariable("vmd_detect") .. " *************\n");
if(type == "event" and voicemail_detected == false) then freeswitch.consoleLog("notice","************ VOICE MAIL/ANSWERING MACHINE DETECTED *************\n"); voicemail_detected = true; return "break"; end end
function playbackMessage() sleep_time = 1000; if(voicemail_detected) then sleep_time = 2500; end -- sleep a second session:sleep(sleep_time); -- play a file session:streamFile(message_to_play); end
function notify() session = freeswitch.Session("{ignore_early_media=true}sofia/gateway/voicenetwork/1" .. number_to_call)
if(session:ready()) then -- answer the call session:answer(); session:setInputCallback("onInput", ""); session:execute("vmd","start");
playbackMessage(); if(voicemail_detected) then freeswitch.consoleLog("notice","************ DOING PLAYBACK FOR VOICEMAIL/ANSWERING MACHINE *************\n"); playbackMessage(); end
freeswitch.consoleLog("notice", "********* hanging up session **********\n"); -- hangup session:hangup(); end end
notify();
freeswitch.consoleLog("info","########################################################\n\n");
-- Michael De Lorenzo
I haven't played with events inside Lua yet, but here's an example: http://wiki.freeswitch.org/wiki/Examples_directory_lua_asr_tts Look at the onInput() function in that example. There it gives the syntax for extracting the event header to see what event type has come in. The other question I have: did you confirm that mod_vmd triggers properly when going to this mailbox? You could write a simple dialplan that sets mod_vmd, calls the phone, sleeps for 10 or so seconds, and then dumps the var ${vmd_detect} to see what it says. I've used mod_vmd from the XML dialplan with a fair amount of success, although to my knowledge I never actually tried it with a Verizon wireless VM box. Confirm that mod_vmd works with just the dialplan before trying to debug the Lua script. -MC On Mon, Mar 1, 2010 at 7:17 PM, Michael De Lorenzo < delorenzodesign@gmail.com> wrote:
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).
freeswitch.consoleLog("info","########################################################\n\n");
number_to_call = argv[1] message_to_play = "/opt/freeswitch/recordings/messages/" .. argv[2]
voicemail_detected = false;
function onInput(s, type, obj) freeswitch.consoleLog("notice","*********** Type?: " .. type .. " *************\n"); -- freeswitch.consoleLog("notice","*********** VMD?: " .. session:getVariable("vmd_detect") .. " *************\n");
if(type == "event" and voicemail_detected == false) then freeswitch.consoleLog("notice","************ VOICE MAIL/ANSWERING MACHINE DETECTED *************\n"); voicemail_detected = true; return "break"; end end
function playbackMessage() sleep_time = 1000; if(voicemail_detected) then sleep_time = 2500; end -- sleep a second session:sleep(sleep_time); -- play a file session:streamFile(message_to_play); end
function notify() session = freeswitch.Session("{ignore_early_media=true}sofia/gateway/voicenetwork/1" .. number_to_call)
if(session:ready()) then -- answer the call session:answer(); session:setInputCallback("onInput", ""); session:execute("vmd","start");
playbackMessage(); if(voicemail_detected) then freeswitch.consoleLog("notice","************ DOING PLAYBACK FOR VOICEMAIL/ANSWERING MACHINE *************\n"); playbackMessage(); end
freeswitch.consoleLog("notice", "********* hanging up session **********\n"); -- hangup session:hangup(); end end
notify();
freeswitch.consoleLog("info","########################################################\n\n");
-- Michael De Lorenzo
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Has anyone experienced issues with vmd or dtmf with Verizon wireless? I have another script that doesn't even register digits pressed -- it's like no keys are pressed at all. I've checked the FS log and it doesn't seem to log anything with regard to the mod_vmd other than an indication of MIN_TIME of 8000 (not sure what that does exactly). Does anyone have any sample scripts available other than what's on the FS wiki? On Mon, Mar 1, 2010 at 10:17 PM, Michael De Lorenzo < delorenzodesign@gmail.com> wrote:
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).
freeswitch.consoleLog("info","########################################################\n\n");
number_to_call = argv[1] message_to_play = "/opt/freeswitch/recordings/messages/" .. argv[2]
voicemail_detected = false;
function onInput(s, type, obj) freeswitch.consoleLog("notice","*********** Type?: " .. type .. " *************\n"); -- freeswitch.consoleLog("notice","*********** VMD?: " .. session:getVariable("vmd_detect") .. " *************\n");
if(type == "event" and voicemail_detected == false) then freeswitch.consoleLog("notice","************ VOICE MAIL/ANSWERING MACHINE DETECTED *************\n"); voicemail_detected = true; return "break"; end end
function playbackMessage() sleep_time = 1000; if(voicemail_detected) then sleep_time = 2500; end -- sleep a second session:sleep(sleep_time); -- play a file session:streamFile(message_to_play); end
function notify() session = freeswitch.Session("{ignore_early_media=true}sofia/gateway/voicenetwork/1" .. number_to_call)
if(session:ready()) then -- answer the call session:answer(); session:setInputCallback("onInput", ""); session:execute("vmd","start");
playbackMessage(); if(voicemail_detected) then freeswitch.consoleLog("notice","************ DOING PLAYBACK FOR VOICEMAIL/ANSWERING MACHINE *************\n"); playbackMessage(); end
freeswitch.consoleLog("notice", "********* hanging up session **********\n"); -- hangup session:hangup(); end end
notify();
freeswitch.consoleLog("info","########################################################\n\n");
-- Michael De Lorenzo
Hi Michael, the cell phone carriers in the US use a beep tone that is out of the range that is typically detected. i've had success using tone_detect rather than mod_vmd. if my memory serves me correctly 786 is the tone you need to listen for. the same is true for sprint and t-mobile voice mail beeps --matt freeswitch based voice broadcasting - http://www.hellohunter.com/voice_broadcast.php freeswitch based predictive dialing - http://www.hellohunter.com/predictive_dialer.php On Wed, Mar 3, 2010 at 7:04 PM, Michael De Lorenzo < delorenzodesign@gmail.com> wrote:
Has anyone experienced issues with vmd or dtmf with Verizon wireless? I have another script that doesn't even register digits pressed -- it's like no keys are pressed at all.
I've checked the FS log and it doesn't seem to log anything with regard to the mod_vmd other than an indication of MIN_TIME of 8000 (not sure what that does exactly).
Does anyone have any sample scripts available other than what's on the FS wiki?
On Mon, Mar 1, 2010 at 10:17 PM, Michael De Lorenzo < delorenzodesign@gmail.com> wrote:
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).
freeswitch.consoleLog("info","########################################################\n\n");
number_to_call = argv[1] message_to_play = "/opt/freeswitch/recordings/messages/" .. argv[2]
voicemail_detected = false;
function onInput(s, type, obj) freeswitch.consoleLog("notice","*********** Type?: " .. type .. " *************\n"); -- freeswitch.consoleLog("notice","*********** VMD?: " .. session:getVariable("vmd_detect") .. " *************\n");
if(type == "event" and voicemail_detected == false) then freeswitch.consoleLog("notice","************ VOICE MAIL/ANSWERING MACHINE DETECTED *************\n"); voicemail_detected = true; return "break"; end end
function playbackMessage() sleep_time = 1000; if(voicemail_detected) then sleep_time = 2500; end -- sleep a second session:sleep(sleep_time); -- play a file session:streamFile(message_to_play); end
function notify() session = freeswitch.Session("{ignore_early_media=true}sofia/gateway/voicenetwork/1" .. number_to_call)
if(session:ready()) then -- answer the call session:answer(); session:setInputCallback("onInput", ""); session:execute("vmd","start");
playbackMessage(); if(voicemail_detected) then freeswitch.consoleLog("notice","************ DOING PLAYBACK FOR VOICEMAIL/ANSWERING MACHINE *************\n"); playbackMessage(); end
freeswitch.consoleLog("notice", "********* hanging up session **********\n"); -- hangup session:hangup(); end end
notify();
freeswitch.consoleLog("info","########################################################\n\n");
-- Michael De Lorenzo
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
You'll need to file a jira. Include a script that exhibits the behavior. You'll also need to document it fully and the dialplan entry you're using to produce this issue. /b On Mar 13, 2010, at 7:24 PM, Matthew Fong wrote:
Hi Michael,
the cell phone carriers in the US use a beep tone that is out of the range that is typically detected. i've had success using tone_detect rather than mod_vmd. if my memory serves me correctly 786 is the tone you need to listen for. the same is true for sprint and t-mobile voice mail beeps
--matt freeswitch based voice broadcasting - http://www.hellohunter.com/voice_broadcast.php freeswitch based predictive dialing - http://www.hellohunter.com/predictive_dialer.php
participants (4)
-
Brian West
-
Matthew Fong
-
Michael Collins
-
Michael De Lorenzo