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(&quot;info&quot;,&quot;########################################################\n\n&quot;);</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 = &quot;/opt/freeswitch/recordings/messages/&quot; .. 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(&quot;notice&quot;,&quot;*********** Type?: &quot; .. type .. &quot; *************\n&quot;);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
    -- freeswitch.consoleLog(&quot;notice&quot;,&quot;*********** VMD?: &quot; .. session:getVariable(&quot;vmd_detect&quot;) .. &quot; *************\n&quot;);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
    if(type == &quot;event&quot; and voicemail_detected == false) then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        freeswitch.consoleLog(&quot;notice&quot;,&quot;************ VOICE MAIL/ANSWERING MACHINE DETECTED *************\n&quot;);</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 &quot;break&quot;;</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(&quot;{ignore_early_media=true}sofia/gateway/voicenetwork/1&quot; .. 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(&quot;onInput&quot;, &quot;&quot;);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        session:execute(&quot;vmd&quot;,&quot;start&quot;);</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(&quot;notice&quot;,&quot;************ DOING PLAYBACK FOR VOICEMAIL/ANSWERING MACHINE *************\n&quot;);</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(&quot;notice&quot;, &quot;********* hanging up session **********\n&quot;);</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(&quot;info&quot;,&quot;########################################################\n\n&quot;);</span><br style="font-family: courier new,monospace;" clear="all"></div></blockquote>












<br>-- <br>Michael De Lorenzo<br>