**** Enabling VoiceMail between a2billing SIP/IAX friends ****
This is possible editing the ClassA2billing.php file.
Code:
vi /var/lib/asterisk/agi-bin/libs_a2billing/Class.A2Billing.php
Find all concurrences (only 1):
Code:
} elseif ($k+1 == $sip_buddies+$iax_buddies){
$prompt="prepaid-dest-unreachable";
$agi-> stream_file($prompt, '#');
}
And replace with:
Code:
} elseif ($k+1 == $sip_buddies+$iax_buddies){
// Modificado para habilitar voicemail entre sip/iax friends
$prompt="prepaid-dest-unreachable";
//$agi-> stream_file($prompt, '#');
$buddy="u".$this->destination;
$agi-> exec(VoiceMail,$buddy);
}
If the extension is
not answered find all the concurrences (2) for:
Code:
} elseif ($this->dialstatus == "NOANSWER") {
$answeredtime=0;
$agi-> stream_file('prepaid-noanswer', '#');
And replace with:
Code:
} elseif ($this->dialstatus == "NOANSWER") {
$answeredtime=0;
// Modificado para permitir VoiceMail entre SIP/IAX friends
//$agi-> stream_file('prepaid-noanswer', '#');
$buddyu="u".$this->destination;
$agi-> exec(VoiceMail,$buddyu);
When the extension is
busy find all the concurrences (2) for:
Code:
if ($dialstatus == "BUSY") {
$answeredtime=0;
$agi-> stream_file('prepaid-isbusy', '#');
And replace with:
Code:
if ($dialstatus == "BUSY") {
$answeredtime=0;
// Modificado para permitir voicemail cuando la extension este ocupada
// $agi-> stream_file('prepaid-isbusy', '#');
$buddyb="b".$this->destination;
$agi-> exec(VoiceMail,$buddyb);
Setting up realtime.To avoid editing the file /etc/asterisk/voicemail.conf every time that one customer is created, we can use realtime.
What we have to do?
1.- Add one table called voicemail_users into the mya2billing database:
Code:
CREATE TABLE `voicemail_users` (
`uniqueid` int(11) NOT NULL auto_increment,
`customer_id` int(11) NOT NULL default '0',
`context` varchar(50) NOT NULL default '',
`mailbox` varchar(15) NOT NULL default '0',
`password` varchar(4) NOT NULL default '1234',
`fullname` varchar(50) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`pager` varchar(50) NOT NULL default '',
`stamp` timestamp(14) NOT NULL,
PRIMARY KEY (`uniqueid`),
KEY `mailbox_context` (`mailbox`,`context`)
) TYPE=MyISAM;
Is easier if we fill the create process into one file called voicemail_users.sql and later run:
Code:
mysql -u a2billinguser -pa2billing mya2billing < voicemail_users.sql
2.- We must have to syncronize mya2billing tables with voicemail_users table.
This sentence must have to be executed every N time to make the syncronize task possible.
Code:
truncate table voicemail_users;
insert into voicemail_users(customer_id,context,mailbox ,fullname,email)
select A.id_cc_card,'default',A.name, concat(B.lastname,' ',B.firstname),B.email from cc_sip_buddies A,cc_card B where A.id_cc_card =B.id ;
Is more easy in the following way, creating one text file at /etc/asterisk called a2billingvoicemail.sql containing the syncronize sentense, later creating one text file a /etc/asterisk called a2billingvoicemail.sh containint the following sentense:
Code:
mysql -u a2billinguser -pa2billing mya2billing < /etc/asterisk/a2billingvoicemail.sql
chmod it to be executable:
Code:
chmod a+x a2billingvoicemail.sh
And program the tast to run every 5 minutes, you can define the time, 5 minutes is working fine for me:
Code:
vi /etc/crontab
Add the following lines to the file:
Code:
# Sincronizar mysql cada 5 minutos
5 * * * * /etc/asterisk/a2billingvoicemail.sh
3.- Add into /etc/asterisk/extconfig.conf the following:
Code:
voicemail =>mysql,mya2billing,voicemail_users
The same with /etc/asterisk/res_mysql.conf :
Code:
[general]
dbhost = 127.0.0.1
dbname = mya2billing
dbuser = a2billinguser
dbpass = a2billing
dbport = 3306
;dbsock = /tmp/mysql.sock
4.- Modify the a2billing context to look like this:
Code:
exten => _X.,1,GotoIf($["${EXTEN}" = "9999"]? 4)
exten => _X.,2,DeadAGI(a2billing.php|1)
exten => _X.,3,Hangup
exten => _X.,4,VoicemailMain()
exten => _X.,5,Hangup
Do not forget to reload asterisk to apply the changes.
If the SIP/IAX frien dial 9999 will be taken to the voicemail main menu, you will be asked about your extension number and password, the default password is 1234, the user must have to change it from the voicemail menu.
If you don't want to insert your account/extension number, modify the context to look like this:
Code:
exten => _X.,1,GotoIf($["${EXTEN}" = "9999"]? 4)
exten => _X.,2,DeadAGI(a2billing.php|1)
exten => _X.,3,Hangup
exten => _X.,4,VoiceMailMain(${CALLERID(num)}@default)
exten => _X.,5,Hangup
When you dial 9999 the voicemail app will be requesting only your password.
Sorry for my poor english