[Freeswitch-users] LUA script providing dynamic directory information

Maciej Bylica mbsip at gazeta.pl
Sat Feb 20 09:48:44 PST 2010


Hello,

I am trying to use mod_lua to provide dynamic directory information
(binding in mod_lua.conf.xml)
Here is my script.
#!/usr/local/bin/lua
-- load driver
require "luasql.odbc"
-- create environment object
env = luasql.odbc();
-- connect to data source
conn = env:connect("freeswitch","root");
-- reset our table
if ( conn ~= nil ) then
cur = conn:execute(string.format("SELECT email from VM where
called_num='48112223344'"));

if ( cur ~= nil ) then
row = cur:fetch({}, "a");
if ( row ~= nil ) then

freeswitch.consoleLog("info", " Email fetched from DB is = "..
row.email .."\n");

cur:close(); conn:close(); env:close();

mydialplan = [[
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
  <section name="directory">
    <domain name="10.10.10.1">
      <user id="48112223344">
        <params>
          <param name="vm-email-all-messages" value="true"/>
          <param name="vm-attach-file" value="true"/>
          <param name="vm-disk-quota" value="0"/>
          <param name="vm-email-all-messages" value="true"/>
          <param name="vm-mailto" value=".. row.email .."/>
          <param name="vm-keep-local-after-email" value="false"/>
        </params>
      </user>
    </domain>
  </section>
</document>
]]

XML_STRING = mydialplan
end
end
end


I've encountered a problem how to pass row.email gathered from DB
directly to XML (vm-mailto).
As you can see below configuration I have does not work properly.

2010-02-20 20:37:03.267071 [DEBUG] mod_voicemail.c:2358 Deliver VM to
48112223344 at 10.10.10.1
2010-02-20 20:37:03.276533 [INFO] switch_cpp.cpp:1129  Email fetched
from DB is = hereis at MyEmaill.com
2010-02-20 20:37:03.435902 [DEBUG] switch_utils.c:631 Emailed file
[/tmp/mail.1266694623f261] to [.. row.email ..]
2010-02-20 20:37:03.435902 [DEBUG] mod_voicemail.c:2526 Sending
message to .. row.email ..

I tried with:
<param name="vm-mailto" value=.. row.email ../>
<param name="vm-mailto" value="".. row.email ..""/>
Both of them do not produce any "Sending message" output at all.


Any thoughts?
Thanks in advance.
Maciej




More information about the FreeSWITCH-users mailing list