Page 316 - Asterisk™: The Future of Telephony
P. 316

return new;
                         end if;
                       end$$
                       LANGUAGE plpgsql;
               We’re going to create a table called voicemessages where the voicemail information will
               be stored:
                   CREATE TABLE voicemessages
                   (
                     uniqueid serial PRIMARY KEY,
                     msgnum int4,
                     dir varchar(80),
                     context varchar(80),
                     macrocontext varchar(80),
                     callerid varchar(40),
                     origtime varchar(40),
                     duration varchar(20),
                     mailboxuser varchar(80),
                     mailboxcontext varchar(80),
                     recording lo,
                     label varchar(30),
                     "read" bool DEFAULT false
                   );
               And now we need to associate a trigger with our newly created table in order to perform
               cleanup whenever we make a change or deletion from the voicemessages table:
                   CREATE TRIGGER vm_cleanup AFTER DELETE OR UPDATE ON voicemessages FOR EACH ROW EXECUTE
                   PROCEDURE vm_lo_cleanup();

               Configuring voicemail.conf for ODBC Storage

               There isn’t much to add to the voicemail.conf file to enable the ODBC voicemail storage.
               In fact, it’s only three lines! Generally, you probably have multiple format types defined
               in the [general] section of voicemail.conf, however we need to set this to a single format.
               The wav49 format is a compressed WAV file format that should be playable on both
               Linux and Microsoft Windows desktops.
               The odbcstorage option points at the name you defined in the res_odbc.conf file (if
               you’ve been following along in this chapter, then we called it asterisk). The odbctable
               option refers to the table where voicemail information should be stored. In the examples
               in this chapter we use the table named voicemessages:
                   [general]
                   format=wav49
                   odbcstorage=asterisk
                   odbctable=voicemessages
               You may want to create a separate voicemail context, or you can utilize the default
               voicemail context:
                   [default]
                   1000 => 1000,J.P. Wiser


               288 | Chapter 12: Relational Database Integration
   311   312   313   314   315   316   317   318   319   320   321