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

Steven Schoch schoch+freeswitch.org at xwin32.com
Wed Jun 1 03:35:47 MSD 2016


I'm back to working on the voicemail notification.
The lua script is being called, and I can get important variables with
these calls:

action = event:getHeader("VM-Action")
if action ~= "leave-message" then return end
user = event:getHeader("VM-User")
caller_id_name = event:getHeader("VM-Caller-ID-Name")
caller_id_number = event:getHeader("VM-Caller-ID-Number")
uuid = event:getHeader("VM-UUID")
message_len = event:getHeader("VM-Message-Len")
timestamp = event:getHeader("VM-Timestamp")

I have some of the important information here, like which voicemail box got
the message, who's it from, when, and how long it was. At this point I'd
like to send this information as an SMS message using a CURL call into the
Flowroute SMS API. The important bit of data is to whom to send the SMS
message.

I put the SMS number into the directory XML structure, like this:
<include>
  <user id="1004">
    <params>
      <param name="vm-mailto" value="user at example.com"/>
    </params>
    <variables>
      <variable name="effective_caller_id_name" value="Joe Smith"/>
      <variable name="effective_caller_id_number" value="1004"/>
      <variable name="outbound_caller_id_name"
value="$${outbound_caller_name}"/>
      <variable name="outbound_caller_id_number"
value="$${outbound_caller_id}"/>
      <variable name="vm-notify-sms" value="1408497xxxx"/>
    </variables>
  </user>
</include>

I'd like to pull that vm-notify-sms variable that I created. The documented
way to get variables from a lua script is the session:getVariable()
function, but the session variable is not defined when this event hook is
called. However, the log file shows my script is being called before the
session is destroyed, so I'm thinking perhaps I can access it from the uuid
variable. How do I do this? I also looked for an "env" object, which is
created when a hangup hook is called, but it seems that is only set on a
hangup hook, not an event hook.

How can I access the session or directory variables?

-- 
Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20160531/cb5a3962/attachment-0001.html 


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