Voicemail HELP!

Hi guys,

I need some help on this one.

Whenever the call hits the voicemail, the default recording that comes up is,

“The person at the extension XXXXX is unavailable, please leave a message after the tone, when done hangup or press the pound key”

in what file and and what context these sound files are called ?

I know the sound file name is vm-the person, etc.

I’d like to have the code call a different sound file. I’m unable to locate the context and file in which the code calls these files. It should be extensions.conf and context macro-vm ? Right ?

People any assistance on this one ?

is to login to the voicemail system, press ‘0’ for Mailbox Options, then press ‘1’ to record your own Unavailable message.

Your suppositions are not entirely correct. there IS a file called vm-theperson in var/lib/asterisk/sounds. In fact there are several, each recorded in a particular format (gsm,etc.), but that file says onle “The person at extension”. The rest of the message is concatenated from several files including the numbers representing the extensions, etc.

So simply changing out a file will not work here.

The routine that plays this unavailable message first looks in the extension voicemail directory to see if there is either a recording of a user’s name or a full user recorded unavailable message. If it sees the user’s recorded name, it uses the concatenate process as above to create a message that says …" Joe Smith is unavailable…". If there is a user recorded unavailable message, then it plays that message.

as I see it, the easiest, although somewhat labor intensive, method of creating the same custom unavailable message would be to record a single custom unavailable message, then in each user’s voicemail directory create a link to that recording. This keeps you from having to fiddle with the asterisk code and allows you to easily reverse the process if needed.

Bill/W5WAF

Not is that really the easiest, but is really the best…

Bill/W5WAF

Right !

I want to replace the vm-person with another file. That’s All !

Do you know where to make the replacement ? I am sure calling a different wav file would not hurt asterisk. No one dares to fiddle with asterisk code !

Problem is…

Do you want it to say “your new file, at extension 1234 is not available”?

Bill/W5WAF

Replacing that file will also effect other places in the code as it’s reused. The audio is called from within the voicemailmain.c module file inside asterisk.

That particular audio file is used in several other phrases like “the person” at extension is …, etc. so what you think is a simple single replacement is actually effecting about 8 other locations all at once. I think that part of the sentence is also used in meetme announcements…

so it’s not as simple as that.

Well Said!

Bill/W5WAF

Perhaps if a complete description of what is trying to be accomplished. (Not only the what but the rationale…the WHY) it might be easier to come up with a solution.

In Journalism…remember the 5 W’s for every story …(Who…What…When…Where… & …Why). Not only goes for a news story, but in describing a problem and asking for help).

Bill/W5WAF

-30-

add a V to the 5 W’s. Versions of things… ALWAYS important as some versions can do things that others can not.

Defintely, I know I can record my own message for my voicemail. Thats not an issue.

The file is going to be played for all my user voicemail boxes. Considering web meetme, I won’t be using it on this box.

The easiest way is to perhaps to rename my file as " vm-theperson.wav" and copy it in var/lib/asterisk/sounds folder. The original file would be overwrittern with mine. I can save the original file in some other directory for backup purposes.

However, I’d like to do things in a solid way rather than relying on tricks.

fskrotzki where is the file voicemailmain.c ? I mean in which directory ?

Also, from googling I found out there is another file that may be useful. It is app_voicemail.c

But where are these files ?

I am trying to use the “locate” command to get hold of them but nothing comes up. I’ve ran updatedb as well but still no luck.

I’ve a trixbox 2.6 setup. I guess it runs with Asterisk 1.4.

I’ve heard Asterisk 1.6 has better voicemail features than 1.4. I’ll try to google that out.

you are correct it’s app_voicemail.c I types it wrong. app_voicemail hasa routine called voicemailmain which is what is called and it’s all written in C. To make changes to that you’ll need to re-compile asterisk. And boy that would be one quick way to screw up a trixbox setup (past what they already do to it).

To know where every instance of that file is, you’ll need to grep all of the asterisk source (which you’d have to download and install along with the development tools) and also all of FreePBX to see where it is used.

It’s not as simple as you think.

Why would it screw trixbox ? I’ll be calling a different file only.

Would the recompile thing screw my box ?

I don’t think you understand the problem…
The vm-theperson file is just one of a number of files played during the response. Please examine my earlier post. I believe that this file only says “THE PERSON AT EXTENSION…” . Then one or more files speak each digit separately. After this, a file with only the word “UNAVAILABLE” is played, and so on through the message.

Changing the vm-theperson file will change ONLY the part that says “THE PERSON AT EXTENSION…” you’ll still get all of the rest of the message.

The simple fact is that you cannot change a SINGLE file to change the voicemail greeting.

Bill/W5WAF

recompiling asterisk has a very high likelyhood of screwing things up. As things are then not the way trixbox expects things. Then if you ever update the box and it updates asterisk you’ll loose those changes, need to download the new source, modify it again, etc…

Bill I know that the several files are played collectively to compose one message or greeting by asterisk. “vm-theperson” is just a piece of it.

My box is going to serve as a Voicemail Server only. My interest is only with voicemail and I not concerned about what happens to the rest of the apps.

I’ve got into the code and now know where is it called. I’m just worried about the recompile thingie. Definitely, I am in no mood to screw my box.

Here is the code and how voicemail routines run within asterisk,

sub version { $VERSION; }

sub new {
my ($class, %args) = @_;
my $self = {};
bless $self, ref $class || $class;

while (my ($key,$value) = each %args) { $self->set($key,$value); }

return $self;

}

sub DESTROY { }

sub spooldirectory {
my ($self, $directory) = @_;

if (defined($directory)) {
	$self->{'spooldirectory'} = $directory;
} else {
	$self->{'spooldirectory'} = '/var/spool/asterisk/vm' if (!defined($self->{'spooldirectory'}));
}

return $self->{'spooldirectory'};

}

sub sounddirectory {
my ($self, $directory) = @_;

if (defined($directory)) {
	$self->{'sounddirectory'} = $directory;
} else {
	$self->{'sounddirectory'} = '/var/lib/asterisk/sounds' if (!defined($self->{'sounddirectory'}));
}

return $self->{'sounddirectory'};

}

sub serveremail {
my ($self, $email) = @_;

$self->{'serveremail'} = $email if (defined($email));

return $self->{'serveremail'};

}

sub format {
my ($self, @formats) = @_;

if (@formats) {
	$self->{'formats'} = @formats;
}

return $self->{'formats'};

}

sub vmbox {
my ($self, $vmbox, $vmpass, $vmfn, $vmemail) = @_;

if (defined($vmbox) && (defined($vmpass) || defined($vmfn) || defined($vmemail)) ) {
	$self->{'vmbox'}{$vmbox}{'pass'} = $vmpass if (defined($vmpass));
	$self->{'vmbox'}{$vmbox}{'fn'} = $vmfn if (defined($vmfn));
	$self->{'vmbox'}{$vmbox}{'email'} = $vmemail if (defined($vmemail));
} elsif (defined($vmbox)) {
	return ($self->{'vmbox'}{$vmbox}{'pass'},
		$self->{'vmbox'}{$vmbox}{'fn'},
		$self->{'vmbox'}{$vmbox}{'email'} );
}

}

sub getfolders {
my ($self, $vmbox) = @_;

my @folders = ();

    my $spool = $self->spooldirectory();

foreach $file (<$spool/$vmbox/*>) {
	if ( -d $file ) {
		$file =~ s/$spool\/$vmbox\///;
		push(@folders, $file);
	}
}
return @folders;

}

sub configfile {
my ($self, $configfile) = @_;

if (defined($configfile)) {
	$self->{'configfile'} = $configfile;
} else {
	$self->{'configfile'} = '/etc/asterisk/voicemail.conf' if (!defined($self->{'configfile'}));
}

return $self->{'configfile'};

}

sub readconfig {
my ($self) = @_;

my $context = '';
my $line = '';

my $configfile = $self->configfile();

open(CF, "<$configfile") || die "Error loading $configfile: $!\n";
while ($line = <CF>) {
	chop($line);

	$line =~ s/;.*$//;
	$line =~ s/\s*$//;

	if ($line =~ /^;/) {
		next;
	} elsif ($line =~ /^\s*$/) {
		next;
	} elsif ($line =~ /^\[(\w+)\]$/) {
		$context = $1;
		print STDERR "Context: $context\n" if ($DEBUG>3);
	} elsif ($line =~ /^format\s*[=>]+\s*(.*)/) {
		my $formats = $1;
		$self->format(split(/|/, $formats));
	} elsif ($line =~ /^serveremail\s*[=>]+\s*(.*)/) {
		$self->serveremail($1);
	} elsif ($line =~ /^(\d+)\s*[=>]+\s*(.*)/) {
		my $vmbox = $1;
		my $vmstr = $2;
		my ($vmpass, $vmfn, $vmemail) = split(/,/, $vmstr);
		print STDERR "VM BOX ($vmbox)\n" if ($DEBUG>3);
		$self->vmbox($vmbox, $vmpass, $vmfn, $vmstr);
	} else {
		print STDERR "Unknown line: $line\n" if ($DEBUG);
	}
}

close(CF);

}

sub appendsoundfile {
my ($self, $source, $dest) = @_;

open(IN, "<$source") || return 0;
open(OUT, ">>$dest") || return 0;
while (<IN>) {
	print OUT $_;
}
close(IN);
close(OUT);
return 1;

}

sub validmailbox {
my ($self, $vmbox) = @_;

return 1 if ($self->vmbox($vmbox));
return 0;

}

sub msgcount {
my ($self, $vmbox, $folder) = @_;

my $count = 0;

return $count if (!defined($vmbox) || !defined($folder));

my $spool = $self->spooldirectory() . '/' . $vmbox . '/' . $folder;

if (opendir(DIR, $spool)) {
	my @msgs = grep(/^msg.*\.txt$/, readdir(DIR));
	$count = $#msgs+1;
	closedir(DIR);
}
return $count;

}

sub msgcountstr {
my ($self, $vmbox, $folder) = @_;

my $count = $self->msgcount($vmbox, $folder);

if ($count > 1) {
	return "$count messages";
} elsif ($count > 0) {
	return "$count message";
} else {
	return "no messages";
}

}

sub createdefaultmailbox {
my ($self, $vmbox) = @_;

my $spool = $self->spooldirectory();
my $sounddir = $self->sounddirectory();

my $vmdir = "$spool/$vmbox";


if ( -d $vmdir ) {
	print STDERR "Directory already exists: $vmdir\n" if ($DEBUG);
} else {
	mkdir($vmdir, 0755) || return 0;
	mkdir("$vmdir/INBOX", 0755) || return 0;
}

$self->appendsoundfile("$sounddir/vm-theperson.gsm", "$vmdir/unavail.gsm");
$self->appendsoundfile("$sounddir/vm-theperson.gsm", "$vmdir/busy.gsm");
$self->appendsoundfile("$sounddir/vm-extension.gsm", "$vmdir/greet.gsm");

foreach $chr (split(//, $vmbox)) {
	$self->appendsoundfile("$sounddir/digits/$chr.gsm", "$vmdir/unavail.gsm");
	$self->appendsoundfile("$sounddir/digits/$chr.gsm", "$vmdir/busy.gsm");
	$self->appendsoundfile("$sounddir/digits/$chr.gsm", "$vmdir/greet.gsm");
}

$self->appendsoundfile("$sounddir/vm-isunavail.gsm", "$vmdir/unavail.gsm");
$self->appendsoundfile("$sounddir/vm-isonphone.gsm", "$vmdir/busy.gsm");

return 1;

}

sub messages {
my ($self, $messages, $folder) = @_;

    my $path = $self->spooldirectory() . '/' . $mailbox . '/' . $folder;
    if (opendir(DIR, $path)) {
            my @msgs = sort grep(/^msg....\.txt$/, readdir(DIR));
            closedir(DIR);
            return map { s/^msg(....)\.txt$/$1/; $_ } @msgs;
    }
    return ();

Well, then, the easiest thing to do without the possibility of screwing up your box, would be to exchange all of the files that would likely be played with files with about .05 second of silence. Record your message into the “theperson” file…

Now you have the one file followed couple of 10ths of a second of silence.

I wouldn’t worry a whole lot about having to recompile asterisk, though, just make a backup of the source code, edit it, and then recompile. Then if something gets screwed, simply restore the file and recompile.

Bill/W5WAF

I’ve got a somewhat similar problem:

If someone calls the external number and gets to the voicemail (b/c no one is answering), he hears “The person is not available” … this is confusing people. Is there any chance to let it say the external DID (or any arbitrary number)?

I know I could record my own message but the computerized voice sounds better… :smiley:

Cheers,
-mARKUS