[Freeswitch-users] mod_python fetching data from mysql for VM

mbsip mbsip at gazeta.pl
Sun Feb 14 06:52:03 PST 2010


Hi.

Please correct me if my approach is okay.
1. in python.conf.xml
    <param name="xml-handler-script" value="testscript"/>
    <param name="xml-handler-bindings" value="directory"/>
2. in dialplan
    <extension name="public_did_11digits">
      <condition field="destination_number" expression="^(\d{11})$">
        <action application="answer"/>
        <action application="voicemail" data="default $${domain} $1"/>
      </condition>
    </extension>
3.testscript.py (as for now only static entries)
def xml_fetch(params):

        xml = '''
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
  <section name="directory">
    <domain name="mydomainHERE">
      <params>
        <param name="dial-string"
value="{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}"/>
      </params>
      <groups>
        <group name="default">
         <users>
          <user id="12345678901">
            <params>
               <param name="vm-mailto" value="email at aaa.com"/
            </params>
          </user>
        </group>
       </users>
      </groups>
    </domain>
  </section>
</document>
'''

        return xml


Unfortunately aforemetnioned configuration does not work at all and
produce following errors:
2010-02-14 17:31:16.878878 [DEBUG] sofia.c:4110 Channel
sofia/internal/100 at 10.10.10.10 entering state [completed][200]
2010-02-14 17:31:16.878878 [DEBUG] switch_core_session.c:638 Send
signal sofia/internal/100 at 10.10.10.10 [BREAK]
2010-02-14 17:31:16.878878 [NOTICE] mod_dptools.c:715 Channel
[sofia/internal/100 at 10.10.10.10] has been answered
EXECUTE sofia/internal/100 at 10.10.10.10 voicemail(default mydomainHERE
12345678901)
2010-02-14 17:31:16.888821 [DEBUG] mod_voicemail.c:728 [default] rwlock
2010-02-14 17:31:16.888821 [NOTICE] mod_python.c:118 Invoking py module: obadamy
2010-02-14 17:31:16.888821 [DEBUG] mod_python.c:188 Call python script
2010-02-14 17:31:16.888821 [DEBUG] mod_python.c:191 Finished calling
python script
2010-02-14 17:31:16.888821 [ERR] mod_python.c:200 Error calling python script
2010-02-14 17:31:16.888821 [WARNING] mod_voicemail.c:2923 Can't find
user [12345678901 at mydomainHERE]
2010-02-14 17:31:16.888821 [DEBUG] switch_ivr_play_say.c:118 No
language specified - Using [en]
2010-02-14 17:31:16.888821 [DEBUG] sofia.c:4110 Channel
sofia/internal/100 at 10.10.10.10 entering state [ready][200]
2010-02-14 17:31:16.888821 [DEBUG] switch_ivr_play_say.c:273 Handle
play-file:[voicemail/vm-goodbye.wav] (en:en)
2010-02-14 17:31:16.888821 [DEBUG] switch_ivr_play_say.c:1158 Codec
Activated L16 at 8000hz 1 channels 20ms

The same output with simplified python script.
def xml_fetch(params):

        xml = '''
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
  <section name="directory">
    <domain name="62.29.162.90">
      <user id="48223891699">
        <params>
        </params>
      </user>
    </domain>
  </section>
</document>
'''

        return xml



As for now I have no idea how to solve this, but still digging.
Funny is that dialplan bindings work okay.

Any help pls.
Thx,
Maciej


2010/2/13 mbsip <mbsip at gazeta.pl>:
> João,
>
> Thanks for hint, because i don't know how the db fetched data could be
> used with voicemail.
> I am about to ready it carefully :P
>
> Thanks,
> Maciej
>
> 2010/2/13 João Mesquita <jmesquita at freeswitch.org>:
>> Maciej,
>>
>> Take a look at the xml_hooks we have on mod_python. Might do the trick for
>> you.
>>
>> http://svn.freeswitch.org/svn/freeswitch/trunk/src/mod/languages/mod_python/python_example.py
>>
>> JM
>>
>>
>> On Sat, Feb 13, 2010 at 6:59 PM, mbsip <mbsip at gazeta.pl> wrote:
>>>
>>> There is a lack of connection between fatched data and voicemail and I
>>> dont know how to achieve it.
>>>
>>> Thx,
>>> Maciej.
>>>
>>>
>>> 2010/2/13 mbsip <mbsip at gazeta.pl>:
>>> > Thx for prompt reply.
>>> >
>>> > The main task is to be able to use Mysql db in conjunction with VM
>>> > (but not only voicemail_msgs, voicemail_prefs).
>>> >
>>> > Lets imagine sb is calling 1000 and wants to record the message.
>>> > According to mod_voicemail settings message should be sent to some
>>> > email address.
>>> > But the information about user 1000 and his settings like email
>>> > address, passwd, quota should be fetched from Mysql db, not from
>>> > directory/default/1000.xml.
>>> > That's why I am using <action application="python" data="test"/> in my
>>> > dialplan to work with python script which in turn should do the magic.
>>> > The script should be able to gather all necessery data about user 1000
>>> > (like email address in shown example) and use them in VM.
>>> >
>>> > So the problem is how to modify the script to force voicemail app to
>>> > use data from DB.
>>> > Currently  session.execute("voicemail", "default ${domain} " +
>>> > the_dest) is still using .xml files.
>>> >
>>> > Thx,
>>> > Maciej.
>>> >
>>> >
>>> > 2010/2/13 Michael Jerris <mike at jerris.com>:
>>> >> Can you describe what your trying to accomplish, I don't understand
>>> >> what the goal is.  What feature are you looking for that does not already
>>> >> exist in mod_voiceamil.
>>> >>
>>> >> Mike
>>> >>
>>> >> On Feb 13, 2010, at 3:03 PM, mbsip wrote:
>>> >>
>>> >>> Hello,
>>> >>>
>>> >>> I am trying to use mod_python to fetch data from Mysql db (through
>>> >>> ODBC) and execute voicemail application.
>>> >>> Below a part of my script:
>>> >>>
>>> >>> db=MySQLdb.connect("localhost","root","","test")
>>> >>>       Cursor=db.cursor()
>>> >>>       sql = "SELECT email FROM VM WHERE called_num=%s" % the_dest
>>> >>>       Cursor.execute(sql)
>>> >>>       while (1):
>>> >>>               Results = Cursor.fetchone()
>>> >>>               if Results == None:
>>> >>>                       break
>>> >>>               consoleLog("debug", "Found email " + Results[0] +"\n")
>>> >>>               the_recipient = Results[0]
>>> >>>       db.close()
>>> >>>
>>> >>> Now i have email address corresponding with called number. The
>>> >>> question is how to use it for voicemail application?
>>> >>> So it also means how to omit all /directory/default/....xml, where
>>> >>> there are all VM parameters set and use fetched data.
>>> >>>
>>> >>>       session.answer()
>>> >>>       session.execute("voicemail", "default ${domain} " + the_dest)
>>> >>>
>>> >>> Is this possible or should I start all VM app in python from the
>>> >>> scratch?
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >> FreeSWITCH-users mailing list
>>> >> FreeSWITCH-users at lists.freeswitch.org
>>> >> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> >>
>>> >> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> >> http://www.freeswitch.org
>>> >>
>>> >
>>>
>>> _______________________________________________
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>
>>
>> _______________________________________________
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>




More information about the FreeSWITCH-users mailing list