[Freeswitch-users] Run a LUA script when voicemail received

Steven Schoch schoch+freeswitch.org at xwin32.com
Mon May 23 21:20:51 MSD 2016


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 at gmail.com> wrote:

> https://wiki.freeswitch.org/wiki/Mod_lua#Event_Hooks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160523/dfcd6fdb/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list