I got it working. Ignore the rest of this message unless you want to know how I solved it. My problem was that I was using "reloadxml" after I added the "hook" line, but after reading the mod_lua.cpp file, I found that while "reloadxml" 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.) -------- It didn't work.I tried putting this line in autoload_configs/lua.conf.xml: <hook event="CUSTOM" subclass="vm::maintenance" script="voicemail-event.lua"/> I then created a "voicemail-event.lua" file with the following: action = event:getHeader("VM-Action") freeswitch.consoleLog("info", "VM Action: " .. action) However, the log file has nothing about this script: 91307edb-28d3-4d1d-bd80-95654a327c8b 2016-05-27 15:07:47.533629 [DEBUG] switch_core_state_machine.c:710 (sofia/external/+1408xxxxxxx@fl.gg) State DESTROY going to sleep 2016-05-27 15:07:47.533629 [DEBUG] mod_voicemail.c:1946 Update MWI: Messages Waiting yes 2016-05-27 15:07:47.533629 [DEBUG] mod_voicemail.c:1947 Update MWI: Update Reason NEW 2016-05-27 15:07:47.533629 [DEBUG] mod_voicemail.c:1948 Update MWI: Message Account 408xxxxxxx@starnet.com 2016-05-27 15:07:47.533629 [DEBUG] mod_voicemail.c:1949 Update MWI: Voice Message 1/0 2016-05-27 15:07:47.953635 [DEBUG] switch_utils.c:1180 Emailed file [/tmp/mail.14643868674630] to [voicemail@xxxx.com] 2016-05-27 15:07:47.953635 [DEBUG] mod_voicemail.c:3038 Sending message to voicemail@xxxx.com 2016-05-27 15:07:48.393632 [DEBUG] switch_utils.c:1182 Emailed data to [vm-page] 2016-05-27 15:07:48.393632 [DEBUG] mod_voicemail.c:3088 Sending notify message to vm-page 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't see that it the log either. 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 "hook" elements that includes this line: switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "hook params: '%s' | '%s' | '%s'\n", event, subclass, script); -- Steve On Mon, May 23, 2016 at 10:20 AM, Steven Schoch < schoch+freeswitch.org@xwin32.com> wrote:
Thanks! Another thing to point me in the right direction. Investigating the source, I found in the routine deliver_vm(), it makes these calls: switch_event_create_subclass(&message_event, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT); switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Action", "leave-message"); ... switch_event_fire(&message_event); This led me to the example autoload_configs/lua.conf.xml file, which has this line:
<!--<hook event="CUSTOM" subclass="conference::maintenance" script="catch-event.lua"/>-->
I should be able to write a script that gets called whenever something happens to a voicemail box with this line: <hook event="CUSTOM" subclass="vm::maintenance" script="voicemail-event.lua"/>
Then, in my lua script, I should be able to call event:getHeader("VM-Action"), and exit unless it's "leave-message". There are other headers in the event that should have information such as the length of the recording.
Just a little confused about the "event" variable. Is that a global variable that's already set when my script is called?
-- Steve
On Sun, May 22, 2016 at 9:34 AM, Abaci B <abaci64@gmail.com> wrote: