[Freeswitch-users] Lua Script with mod_vmd, setInputCallback doesn't seem to get called

Michael Collins msc at freeswitch.org
Mon Mar 1 21:07:22 PST 2010


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 at 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 at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100301/95e8a8bc/attachment-0002.html 


More information about the FreeSWITCH-users mailing list