<div dir="ltr"><div>I got it working. Ignore the rest of this message unless you want to know how I solved it.</div><div>My problem was that I was using &quot;reloadxml&quot; after I added the &quot;hook&quot; line, but after reading the mod_lua.cpp file, I found that while &quot;reloadxml&quot; loaded the whole XML include tree into the Freeswitch config structure, The mod_lua code used that config structure only on startup. The solution was to shut down freeswitch. (And thanks to the new  systemd on Debian 8, it started back up by itself.)</div><div><br></div><div>--------</div><div><br></div>It didn&#39;t work.I tried putting this line in autoload_configs/lua.conf.xml:<div><br></div><div><div>    &lt;hook event=&quot;CUSTOM&quot; subclass=&quot;vm::maintenance&quot; script=&quot;voicemail-event.lua&quot;/&gt;</div></div><div><br></div><div>I then created a &quot;voicemail-event.lua&quot; file with the following:</div><div><div>action = event:getHeader(&quot;VM-Action&quot;)</div><div>freeswitch.consoleLog(&quot;info&quot;, &quot;VM Action: &quot; .. action)</div></div><div><br></div><div>However, the log file has nothing about this script:</div><div><br></div><div><div>91307edb-28d3-4d1d-bd80-95654a327c8b 2016-05-27 15:07:47.533629 [DEBUG] switch_core_state_machine.c:710 (sofia/external/+<a href="mailto:1408xxxxxxx@fl.gg">1408xxxxxxx@fl.gg</a>) State DESTROY going to sleep</div><div>2016-05-27 15:07:47.533629 [DEBUG] mod_voicemail.c:1946 Update MWI: Messages Waiting yes</div><div>2016-05-27 15:07:47.533629 [DEBUG] mod_voicemail.c:1947 Update MWI: Update Reason NEW</div><div>2016-05-27 15:07:47.533629 [DEBUG] mod_voicemail.c:1948 Update MWI: Message Account <a href="mailto:408xxxxxxx@starnet.com">408xxxxxxx@starnet.com</a></div><div>2016-05-27 15:07:47.533629 [DEBUG] mod_voicemail.c:1949 Update MWI: Voice Message 1/0</div><div>2016-05-27 15:07:47.953635 [DEBUG] switch_utils.c:1180 Emailed file [/tmp/mail.14643868674630] to [<a href="mailto:voicemail@xxxx.com">voicemail@xxxx.com</a>]</div><div>2016-05-27 15:07:47.953635 [DEBUG] mod_voicemail.c:3038 Sending message to <a href="mailto:voicemail@xxxx.com">voicemail@xxxx.com</a></div><div>2016-05-27 15:07:48.393632 [DEBUG] switch_utils.c:1182 Emailed data to [vm-page]</div><div>2016-05-27 15:07:48.393632 [DEBUG] mod_voicemail.c:3088 Sending notify message to vm-page</div><div><br></div></div><div>The deliver_vm() function in src/mod/applications/mod_voicemail/mod_voicemail.c sends the event before the MWI update. It also sends the event at other times, including after voicemail authentication, but I don&#39;t see that it the log either.</div><div><br></div><div>Investigating a little further, in src/mod/languages/mod_lua/mod_lua.cpp, there is a function that seems to process the autoload_configs/lua.conf.xml file. It has a loop that appears to process the &quot;hook&quot; elements that includes this line:</div><div><br></div><div><div>                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;hook params: &#39;%s&#39; | &#39;%s&#39; | &#39;%s&#39;\n&quot;, event, subclass, script);</div></div><div><br></div><div>-- </div><div>Steve</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 23, 2016 at 10:20 AM, Steven Schoch <span dir="ltr">&lt;<a href="mailto:schoch+freeswitch.org@xwin32.com" target="_blank">schoch+freeswitch.org@xwin32.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks! Another thing to point me in the right direction. Investigating the source, I found in the routine deliver_vm(), it makes these calls:<div><div>                switch_event_create_subclass(&amp;message_event, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT);</div><div><div>                switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, &quot;VM-Action&quot;, &quot;leave-message&quot;);</div></div><div>...</div><div><div>                switch_event_fire(&amp;message_event);</div></div><div>This led me to the example autoload_configs/lua.conf.xml file, which has this line:</div><div><br></div><div><div>    &lt;!--&lt;hook event=&quot;CUSTOM&quot; subclass=&quot;conference::maintenance&quot; script=&quot;catch-event.lua&quot;/&gt;--&gt;</div></div><div><br></div><div>I should be able to write a script that gets called whenever something happens to a voicemail box with this line:</div><div><div>    &lt;hook event=&quot;CUSTOM&quot; subclass=&quot;vm::maintenance&quot; script=&quot;voicemail-event.lua&quot;/&gt;</div></div><div><br></div><div>Then, in my lua script, I should be able to call event:getHeader(&quot;VM-Action&quot;), and exit unless it&#39;s &quot;leave-message&quot;. There are other headers in the event that should have information such as the length of the recording.</div><div><br></div><div>Just a little confused about the &quot;event&quot; variable. Is that a global variable that&#39;s already set when my script is called?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Steve</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 22, 2016 at 9:34 AM, Abaci B <span dir="ltr">&lt;<a href="mailto:abaci64@gmail.com" target="_blank">abaci64@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><a href="https://wiki.freeswitch.org/wiki/Mod_lua#Event_Hooks" target="_blank">https://wiki.freeswitch.org/wiki/Mod_lua#Event_Hooks</a></div></blockquote></div></div></font></span></div></div>
</blockquote></div><br></div>