Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FreePBX as stand-alone voicemail for Avaya Definity

Status
Not open for further replies.

Duaneness

Technical User
Apr 12, 2001
216
US
Asterisk 13.22.0
FreePBX 14.0.13.26
Avaya Definity v9.5si, IP enabled (but not SIP capable)

I am an old Avaya guy, and a newbie to Asterisk and Perl scripting. And I apologize profusely for the length of this post.

I am trying to set up FreePBX as a standalone voicemail server for an Avaya Definity PBX, v9.5si.

I have an ISDN PRI between the Definity and the FreePBX server. I am successfully sending calls over the PRI to the FreePBX server and am successfully leaving messages in mailboxes.

The issue is getting Message Waiting Indication from FreePBX to the Avaya. FreePBX is calling the Avaya, but is not sending any digits.

I have the PRI set up in two groups - channels 1 through 22, and channel 23 in it's own group (on both ends). Channel 24 for signalling. I use only channel 23 for MWI (dahdi/g1/).

I am using the following Perl script for MWI. I added the line numbers to this for clarity (they are not in the actual script).


Code:
001	#!/usr/bin/perl			
002	#			
003	#   vmnotify.pl v0.1, Copyright (C) Mike Cathey			
004	#			
005	#   ChangeLog			
006	#			
007	#   Use this at your own risk!			
008	#			
009	#   This program is free software; you can redistribute it and/or modify			
010	#   it under the terms of the GNU General Public License as published by			
011	#   the Free Software Foundation; either version 2 of the License, or			
012	#   (at your option) any later version.			
013	#			
014	#   This program is distributed in the hope that it will be useful,			
015	#   but WITHOUT ANY WARRANTY; without even the implied warranty of			
016	#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the			
017	#   GNU General Public License for more details.			
018	#			
019	#   You should have received a copy of the GNU General Public License			
020	#   along with this program; if not, write to the Free Software			
021	#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA			
022	#			
023	my $DEBUG = 1;			
024	open(OUT, ">>","/tmp/asterisk.log");			
025				
026	my $callFile = "Channel: dahdi/g1/			
027	MaxRetries: 6			
028	RetryTime: 60			
029	WaitTime: 5			
030	Context: vmnotify			
031	Extension: s			
032	Callerid: VM Notify <(123) 555-1234>			
033	Priority: 2";			
034				
035	my $notifyFileP = "Channel: dahdi/g1/9			
036	MaxRetries: 0			
037	RetryTime: 300			
038	WaitTime:30			
039	Context: default			
040	Extension: s			
041	Callerid: VM Notific <(123) 555-1234>			
042	Priority: 2";			
043				
044	my $notifyFileM = "Channel: dahdi/g1/9			
045	MaxRetries: 0			
046	RetryTime: 300			
047	WaitTime:30			
048	Context: default			
049	Application: VoicemailMain			
050	Data: sEXTENSION			
051	Callerid: VM Notifica <(123) 555-1234>			
052	Priority: 2";			
053				
054				
055	my $currentMessageDir = "/var/spool/asterisk/mwi/";			
056	my $currentNotifyDir = "/var/spool/asterisk/notify/";			
057	my $rand = $$;			
058	my $callFileTEMP = "/var/tmp/asterisk.callfile." . $rand;			
059	$rand2 = $rand + 1;			
060	my $callFileTEMP2 = "/var/tmp/asterisk.callfile." . $rand2;			
061				
062				
063	my $date = `date`;			
064	print OUT $date;			
065				
066				
067	if ($DEBUG > 0) {			
068		print OUT "\$callFileTEMP = $callFileTEMP\n";		
069		print OUT "\$callFileTEMP2 = $callFileTEMP2\n";		
070		for my $arg (@ARGV) {		
071			print OUT "\t$arg\n";	
072		}		
073	}			
074				
075	shift;			
076	my $mailboxTEMP = shift;			
077	my $messages = shift;			
078	chomp $mailbox;			
079	chomp $messages;			
080				
081	my ($mailbox,$context) = split(/\@/, $mailboxTEMP);			
082				
083	# testing			
084	# $mailbox = 2235;			
085	# $context = "default";			
086	# $messages = 0;			
087				
088	$CMDPath = $currentMessageDir . $context . "/" . $mailbox;			
089	my $currentMessages = 0;			
090	if ( -e $CMDPath ) {			
091		open(CURRENT, "<$CMDPath");		
092		$currentMessages = <CURRENT>;		
093		close CURRENT;		
094		chomp $currentMessages;		
095		print OUT "currentMessages = \"$currentMessages\"\n" if $DEBUG > 0;		
096	} else {			
097		$currentMessages = 0;		
098	}			
099				
100	# create the call file			
101	open(CF, ">$callFileTEMP");			
102				
103	if ( $messages > $currentMessages ) { # they have messages			
104		$callFile =~ s/CALLTHISNUMBER/\106$mailbox/;		
105		# print "Turning ON MWI for $mailbox\@$context\n" if $DEBUG > 0;		
106		print OUT "Turning ON MWI for $mailbox\@$context\n";		
107		print OUT $callFile if $DEBUG > 0;		
108				
109		open(CF2, ">$callFileTEMP2");		
110		my $notifyNumber = getNotifyNumber($mailbox);		
111		my $notifyMethod = $notifyNumber;		
112		$notifyMethod = substr($notifyNumber,0,1);		
113		$notifyNumber = substr($notifyNumber,1,7);		
114		my $notifyFile = "";		
115		my $qFile = "/var/spool/asterisk/outgoing/asterisk." . $rand2;		
116		print OUT "\$qfile = $qFile\n" if $DEBUG > 0;		
117		if ($notifyMethod eq 'm') {		
118			$notifyFile = $notifyFileM;	
119		} elsif ( $notifyMethod eq 'p' ) {		
120			$notifyFile = $notifyFileP;	
121		}		
122				
123		if ( $notifyNumber != 0 ) {		
124			$notifyFile =~ s/CALLTHISNUMBER/$notifyNumber/;	
125			if ($notifyMethod eq 'p' ) {	
126				$notifyFile =~ s/EXTENSION/$mailbox/;
127			} else {	
128				$notifyFile =~ s/EXTENSION/$mailbox\@$context/;
129			}	
130			print CF2 $notifyFile;	
131			if ($DEBUG > 0 ) {	
132				print OUT "---\n";
133				print OUT $notifyFile;
134				print OUT "---\n";
135			}	
136			close CF2;	
137			rename($callFileTEMP2, $qFile) or print(OUT "ERROR: Can't rename callfile($callFileTEMP2): $!\n");	
138		}		
139				
140	} else {			
141		$callFile =~ s/CALLTHISNUMBER/\107$mailbox/;		
142		#print "Turning OFF MWI for $mailbox\@$context\n" if $DEBUG > 0;		
143		print OUT "Turning OFF MWI for $mailbox\@$context\n";		
144		print OUT $callFile if $DEBUG > 0;		
145	}			
146	print CF $callFile;			
147	close CF;			
148				
149	# put it in the outgoing queue			
150	rename($callFileTEMP, "/var/spool/asterisk/outgoing/asterisk.$$") or print(OUT "ERROR: Can't rename callfile($callFileTEMP): $!\n");			
151				
152	# update the new message count			
153	open(UPDATECMD, ">$CMDPath");			
154	print UPDATECMD $messages;			
155	close UPDATECMD;			
156	print OUT "-"x80 . "\n";			
157	close OUT;			
158				
159	sub getNotifyNumber {			
160		my $NotifyPath = $currentNotifyDir . $context . "/" . $mailbox;		
161		if ( -e $NotifyPath ) {		
162			open(CURRENT, "<$NotifyPath");	
163			$notifyNumber = <CURRENT>;	
164			close CURRENT;	
165			chomp $notifyNumber;	
166			print OUT "notifyNumber = \"$notifyNumber\"\n" if $DEBUG > 0;	
167			return $notifyNumber;	
168		} else {		
169			return 0;	
170		}		
171	}


On line 23 I set $DEBUG to "1", but the file "/tmp/asterisk.log" is not created.

The block from line 026 through 033 seems to work, as I see the caller ID name and number in the trace on the Avaya side. Asterisk shows the call completed successfully.

On line 104 I set the MWI On code to "106".
On line 141 I set the MWI Off code to "107".

I am expecting FreePBX to send 7 digits - MWI ON code + 4-digit extension.For Testing, on the Avaya side, I am checking for the number of incoming digits, then route the call to a vector that routes the calls to the string of digits received. Unfortunately, I am getting zero digits.

The only time I receive digits are when I manually add them to the end of line 026, such as
Code:
my $callFile = "Channel: dahdi/g1/1062234
Then I get 7 digits. But that's not the way.

Any experts out there have any suggestions?

Thanks in advance -

- Duaneness
 
Great idea. Have thought the same, with the cost of voicemail systems going crazy, this is awesome.

Is there a way to insert a pause in your digit string? Like 106,,,2234. If you manually dial the mwi codes from an analog phone, is it code [tone] extension?

Have you giving console permission, COS, to the asterisk ports? Have you tweeked the MWI option in system hospitality I think?



 
Additional question, instead of setting up as a trunk, would it work better to setup as 24 separate stations?

Should still get the callerid from phone system. I am not sure Definity will take MWI feature code from a trunk. Years ago I setup a call center off of a Definity with Asterisk in between. Agents used cheap sip phones to sell condos down in Carribean.

 
With Avaya Audix, it used a CLan interface and analog ports. Would it be best to put a network hub in between a working interface like this, use something like wireshark to capture the interactions and then use a CLan interface instead of T1/PRI?

 
I don't know if Asterisk will allow a pause to be programmed. Everything in my original post was found in a variety of different places on the web.

If I dial 1062235 from another phone on the system, I turn on the MWI on the phone for 2235. I don't currently have any analog stations on the system to test from - only digital sets. then dialing 1072235 turns off the MWI. So I know that the codes work.

I'll test console permissions on the MWI port today.

I did try to set up the single PRI channel as an analog (DS1FD), but didn't get anything. I'll play with it some more today. I'm also looking at an SMDI device that would connect to the asterisk server COM1 port and a Definity digital set port. The FreePBX software has SMDI options included.

- Duaneness

 
So dialing 1062235 from a Freepbx phone turns a light on? or from Avaya phone?

 
I would set up a single channel off of the T1 to look like a 24 single stations on the Definity side. Connect to FreePbx as 24 separate trunks so that you can, if need be select which of the 24 trunks, you send the calls out.

Connect a sip phone to Freepbx, send 1062235 out over a select trunk/station on the Definity side. On the Definity side list trace the station to see if the digits are coming across.

Additionally, change station COS to give console permissions and change system features to give that station system wide message permissions.

 
An additional thought, are message waiting lights even necessary? Are you thinking too traditionally? Now days, people want the voicemail emailed to them as an attachment. They no longer want to play the voicemail from their phone anyway.

If you are getting the call from Avaya and putting it in the correct voicemail box on the FreePbx side, then just configure to send the voicemail as an attachment and delete.


 
There are no phones on the FreePBX/Asterisk box. It is strictly being used for voicemail.

It's an older Avaya system in a school environment. During class hours, calls to teachers are sent directly to voicemail. Need the indicator lights to alert teachers to new messages. Don't have infrastructure in place to support sending emails.

Will play with analog stations instead of trunks.

- Duaneness
 
Understand about no phones connected to Asterisk. I would set one up for testing, dialing the message on / off digits. Could even set up softphone on your pc. My gut tells me Definity requires a station to turn the lights on with the code, not a trunk.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top