Asterisk Voicemail

From MetaWiki

Jump to: navigation, search

Here's how I've been able to get Asterisk working with the Meta as a voicemail server, and have working MWI indicators, I used a normal application server and SIP binding (using the Default MG model in the Meta) on the MetaSwitch side.. 2012030000 is the directory number for the Application Server configured in the MetaSwitch. It actually works quite well, on business groups w/ Polycoms you could even tell how many messages you had... (although Urgent support doesn't work with this due to some asterisk limitations on how it can call the externnotify script). I haven't tried this in Asterisk 1.4 yet, however...

Asterisk Config:

voicemail.conf:

externnotify=/usr/local/bin/notify_metaswitch.pl
[metaswitch]
;Mailboxes:
6155284208 => 1111,Test User,testuser@domain.com

extensions.conf:

[metaswitch_in]    ;; Voicemail!
exten => 2012030000,1,NoOp,${RDNIS}
exten => 2012030000,2,NoOp,${CALLERIDNUM}
exten => 2012030000,3,Answer()
exten => 2012030000,4,Playback(silence/1)
exten => 2012030000,6,GotoIf(${RDNIS}?100)
exten => 2012030000,7,VoiceMailMain(${CALLERIDNUM}@metaswitch)
exten => 2012030000,100,Voicemail(u${RDNIS}@metaswitch)
exten => 2012030000,101,Playback(vm-goodbye)
exten => 2012030000,102,Hangup()

sip.conf:

[metaswitch]
type=friend
host=10.64.96.65
context=metaswitch_in
allow=all
insecure=very
canreinvite=yes
dtmfmode=auto
disallow=all
allow=ulaw


Perl script to send NOTIFY when it receives a voicemail notify_metaswitch.pl (really hacked up, and done in a hurry for a demo back in December, could be re-written better, but *shrugs*):

#!/usr/bin/perl

use strict;
use IO::Socket::INET;

##
my $sock;
my $port        = '5060';               # UDP Port to Use
my $sipserver   = '10.64.96.65';        # MetaSwitch IP
my $localip     = '10.16.16.71';        # Our IP to send FROM
my $sip_to      = $ARGV[1];             # Get ARGV[0] as where to send our NOTIFY
my $vm          = $ARGV[2];             # ARGV[1] is how many messages we have
my $sip_from    = '2012030000';         # our SIP_FROM
my $tm          = time();               # Time
my $call_id     = $tm . "msgto$sip_to"; # Generate a callid
my $vmyn;
my $length;
my $msg;

if ($vm == '0') {
$vmyn = 'no';
$length = 36;
$msg         = "NOTIFY sip:$sip_to\@$sipserver:5060 SIP/2.0
Via: SIP/2.0/UDP $localip\
Max-Forwards: 10
To: <sip:$sip_to\@$sipserver:5060>
From: <sip:$sip_from\@10.16.16.71>
Call-ID: $call_id
Cseq: 11 NOTIFY
Contact: <sip:$sip_from\@10.16.16.71>
Event: message-summary
Content-Type: application/simple-message-summary
Content-Length: $length

Messages-waiting: $vmyn
Voicemail: 0/0\r\n";
}
else {
$vmyn = 'yes';
$length = 23 + length("$vm/$vm");
$msg         = "NOTIFY sip:$sip_to\@$sipserver:5060 SIP/2.0
Via: SIP/2.0/UDP $localip\
Max-Forwards: 10
To: <sip:$sip_to\@$sipserver:5060>
From: <sip:$sip_from\@10.16.16.71>
Call-ID: $call_id
Cseq: 11 NOTIFY
Contact: <sip:$sip_from\@10.16.16.71>
Event: message-summary
Content-Type: application/simple-message-summary
Content-Length: $length

Messages-waiting: $vmyn
Voicemail: $vm\/$vm\r\n";
}

$sock = IO::Socket::INET->new(  PeerAddr => $sipserver,
                               PeerPort => $port,
                               Proto => "udp",
                               LocalAddr => $localip);

die "$!" unless $sock;

print $sock "$msg";

#print $msg;

close($sock);
Personal tools