Using Database to store VoiceMail with Asterisk

In order to use database as the storage for voicemails in asterisk, you would need to compile asterisk with odbc storage support.

Dependencies :  unixODBC

yum install unixODBC

Setup:

Run make menuselect when making asterisk and make sure you
select odbc_storage under voicemail build options.

Edit voicemail.conf to have these two lines :

vi /etc/asterisk/voicemail.conf
odbcstorage=asterisk 
odbctable=voicemessages

Note : The database name (from /etc/asterisk/res_odbc.conf) is in the “odbcstorage” variable in the general section.

Create Database to store Voicemails

CREATE TABLE voicemessages (
id bigint generated always as identity NOT NULL,
dbdate timestamp not null default current timestamp,
dir varchar(80) default '',
msgnum bigint NOT NULL default 0,
context varchar(80) default '',
macrocontext varchar(80) default '',
callerid varchar(40) default '',
origtime varchar(40) default '',
duration varchar(20) default '',
mailboxuser varchar(80) default '',
mailboxcontext varchar(80) default '',
recording blob,
PRIMARY KEY  (id)
);

create index idx_voicemsgs on voicemessages(dir,msgnum);