Page 1 of 1

voicemail for inbound calls

PostPosted: Thu Mar 05, 2009 9:46 pm
by xedlinux
hi matt,

i just want to have an idea on how to enable voicemail in inbound calls and where to get the voicemail files. thanks a lot.

PostPosted: Fri Mar 06, 2009 4:07 am
by mflorell
Well, that depends on how you have set it up in Asterisk.

Have you set up your voicemail.conf to have the mailboxes you need, and do you want those voicemails to go to an email address?

What is the version and build of your admin.php?

voicemail for inbound calls

PostPosted: Sun Mar 08, 2009 9:36 am
by xedlinux
hi matt,

i didnt set up my voicemail.conf yet.

i want the voicemail to be send to ftp or one directory in the vicidial server.

i using VERSION: 2.0.4-121 BUILD: 80424-0442


Thanks matt.

PostPosted: Sun Mar 08, 2009 11:46 am
by mflorell
There is nothing that will file transfer voicemail files easily at this point, you can email them, or you could write a script to take the files from the Asterisk voicemail directory and transfer them to where you want them to go.

PostPosted: Sun Mar 08, 2009 6:07 pm
by okli
For the same purpose I quickly edited AST_CRON_audio_3_ftp.pl a while ago and have been using it for months.

That's a quick and dirty edit of Matt's original file, a lot could be cleaned up. Need to use --WAV in order to work as our voicemails are recorded in WAV. If not using --DELETE option amend the path to ALL directory accordingly.
Puts all files from the voicemail directory (/var/spool/asterisk/voicemail/default/888308XXXX/INBOX to the FTP server given in astguiclient.conf.

I have VARFTP_dir => VOICEMAIL in astguiclient.conf, this script runs on a server, which has not vicidial scripts running. Create another variable or hardcode the path.
Amend accordingly per your needs:
Code: Select all
#!/usr/bin/perl
#
# AST_CRON_audio_3_ftp.pl
#
# This is a STEP-3 program in the audio archival process
#
# runs every 3 minutes and copies the recording files to an FTP server
#
# put an entry into the cron of of your asterisk machine to run this script
# every 3 minutes or however often you desire
#
# ### recording mixing/compressing/ftping scripts
##0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_mix.pl
# 0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57 * * * * /usr/share/astguiclient/AST_CRON_audio_1_move_VDonly.pl
# 1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * /usr/share/astguiclient/AST_CRON_audio_2_compress.pl --GSM
# 2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,56,59 * * * * /usr/share/astguiclient/AST_CRON_audio_3_ftp.pl --GSM
#
# FLAGS FOR COMPRESSION FILES TO TRANSFER
# --GSM = GSM 6.10 files
# --MP3 = MPEG Layer3 files
# --OGG = OGG Vorbis files
# --WAV = WAV files
#
# FLAG FOR NO DATE DIRECTORY ON FTP
# --NODATEDIR
#
# make sure that the following directories exist:
# /var/spool/asterisk/monitorDONE   # where the mixed -all files are put
#
# This program assumes that recordings are saved by Asterisk as .wav
#
# Copyright (C) 2008  Matt Florell <vicidial@gmail.com>    LICENSE: AGPLv2
#
#
# 80302-1958 - First Build
# 80317-2349 - Added FTP debug if debugX
# 80731-2253 - Changed size comparisons for more efficiency
#
# slightly modified by I. Taushanov, 16.Nov.2008- added size check of the transferred file and option --DELETE (delete successfully transferred files)
#if file size matches, and --DELETE is used files will be deleted from source directory
#if file size matches, and --DELETE is NOT used, files will be moved to \FTP directory as normal
#if file size does NOT match, error message with file name is displayed and files are not moved nor deleted

$GSM=0;   $MP3=0;   $OGG=0;   $WAV=0;   $NODATEDIR=0;

# Default variables for FTP
$VARFTP_host = '10.0.0.4';
$VARFTP_user = 'cron';
$VARFTP_pass = 'test';
$VARFTP_port = '21';
$VARFTP_dir  = 'RECORDINGS';
$VARHTTP_path = 'http://10.0.0.4';


### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
   $i=0;
   while ($#ARGV >= $i)
   {
   $args = "$args $ARGV[$i]";
   $i++;
   }

   if ($args =~ /--help/i)
   {
   print "allowed run time options:\n  [--DELETE] = delete successfully transferred files\n [--debug] = debug\n  [--debugX] = super debug\n  [-t] = test\n  [--GSM] = copy GSM files\n  [--MP3] = copy MPEG-Layer-3 files\n  [--OGG] = copy OGG Vorbis files\n  [--WAV] = copy WAV files\n  [--NODATEDIR] = do not put into dated directories\n\n";
   exit;
   }
   else
   {
      if ($args =~ /--debug/i)
      {
      $DB=1;
      print "\n----- DEBUG -----\n\n";
      }
      if ($args =~ /--debugX/i)
      {
      $DBX=1;
      print "\n----- SUPER DEBUG -----\n\n";
      }
      if ($args =~ /-t/i)
      {
      $T=1;   $TEST=1;
      print "\n----- TESTING -----\n\n";
      }
      if ($args =~ /-nodatedir/i)
      {
      $NODATEDIR=1;
      if ($DB) {print "\n----- NO DATE DIRECTORIES -----\n\n";}
      }
      if ($args =~ /--GSM/i)
      {
      $GSM=1;
      if ($DB) {print "GSM audio files\n";}
      }
      else
      {
         if ($args =~ /--MP3/i)
         {
         $MP3=1;
         if ($DB) {print "MP3 audio files\n";}
         }
         else
         {
            if ($args =~ /--OGG/i)
            {
            $OGG=1;
            if ($DB) {print "OGG audio files\n";}
            }
            else
            {
               if ($args =~ /--WAV/i)
               {
               $WAV=1;
               if ($DB) {print "WAV audio files\n";}
               }
            }
         }
      }
      if ($args =~ /--DELETE/i)
      {
      $DEL=1;
      if ($DB) {print "\n----- DELETE transferred files -----\n\n";}
      }
   }
}
else
{
#print "no command line options set\n";
$WAV=1;
}


# default path to astguiclient configuration file:
$PATHconf =      '/etc/astguiclient.conf';

open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
@conf = <conf>;
close(conf);
$i=0;
foreach(@conf)
   {
   $line = $conf[$i];
   $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
   if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
      {$PATHhome = $line;   $PATHhome =~ s/.*=//gi;}
   if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
      {$PATHlogs = $line;   $PATHlogs =~ s/.*=//gi;}
   if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
      {$PATHagi = $line;   $PATHagi =~ s/.*=//gi;}
   if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
      {$PATHweb = $line;   $PATHweb =~ s/.*=//gi;}
   if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
      {$PATHsounds = $line;   $PATHsounds =~ s/.*=//gi;}
   if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
      {$PATHmonitor = $line;   $PATHmonitor =~ s/.*=//gi;}
   if ( ($line =~ /^PATHDONEmonitor/) && ($CLIDONEmonitor < 1) )
      {$PATHDONEmonitor = $line;   $PATHDONEmonitor =~ s/.*=//gi;}
   if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
      {$VARserver_ip = $line;   $VARserver_ip =~ s/.*=//gi;}
   if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
      {$VARDB_server = $line;   $VARDB_server =~ s/.*=//gi;}
   if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
      {$VARDB_database = $line;   $VARDB_database =~ s/.*=//gi;}
   if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
      {$VARDB_user = $line;   $VARDB_user =~ s/.*=//gi;}
   if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
      {$VARDB_pass = $line;   $VARDB_pass =~ s/.*=//gi;}
   if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
      {$VARDB_port = $line;   $VARDB_port =~ s/.*=//gi;}
   if ( ($line =~ /^VARFTP_host/) && ($CLIFTP_host < 1) )
      {$VARFTP_host = $line;   $VARFTP_host =~ s/.*=//gi;}
   if ( ($line =~ /^VARFTP_user/) && ($CLIFTP_user < 1) )
      {$VARFTP_user = $line;   $VARFTP_user =~ s/.*=//gi;}
   if ( ($line =~ /^VARFTP_pass/) && ($CLIFTP_pass < 1) )
      {$VARFTP_pass = $line;   $VARFTP_pass =~ s/.*=//gi;}
   if ( ($line =~ /^VARFTP_port/) && ($CLIFTP_port < 1) )
      {$VARFTP_port = $line;   $VARFTP_port =~ s/.*=//gi;}
   if ( ($line =~ /^VARFTP_dir/) && ($CLIFTP_dir < 1) )
      {$VARFTP_dir = $line;   $VARFTP_dir =~ s/.*=//gi;}
   if ( ($line =~ /^VARHTTP_path/) && ($CLIHTTP_path < 1) )
      {$VARHTTP_path = $line;   $VARHTTP_path =~ s/.*=//gi;}
   $i++;
   }

# Customized Variables
$server_ip = $VARserver_ip;      # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}

use Time::HiRes ('gettimeofday','usleep','sleep');  # necessary to have perl sleep command of less than one second
##use DBI;

#$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
# or die "Couldn't connect to database: " . DBI->errstr;

use Net::Ping;
use Net::FTP;

### directory where -all recordings are
if ($WAV > 0) {$dir2 = "/var/spool/asterisk/voicemail/default/888308XXXX/INBOX";}
if ($MP3 > 0) {$dir2 = "$PATHDONEmonitor/MP3";}
if ($GSM > 0) {$dir2 = "$PATHDONEmonitor/GSM";}
if ($OGG > 0) {$dir2 = "$PATHDONEmonitor/OGG";}

opendir(FILE, "$dir2/");
@FILES = readdir(FILE);

### Loop through files first to gather filesizes
$i=0;
foreach(@FILES)
   {
   $FILEsize1[$i] = 0;
   if ( (length($FILES[$i]) > 4) && (!-d "$dir1/$FILES[$i]") )
      {
      $FILEsize1[$i] = (-s "$dir1/$FILES[$i]");
      if ($DBX) {print "$FILES[$i] $FILEsize1[$i]\n";}
      }
   $i++;
   }

sleep(5);

($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time);
$Year += 1900;
$Month++;
$date = "$Year-$Month-$Day";
$start_date =   "$date";
$start_date =~ s/ .*//gi;
#print "$start_date\n";


### Loop through files a second time to gather filesizes again 5 seconds later
$i=0;
foreach(@FILES)
   {
   $FILEsize2[$i] = 0;

   if ( (length($FILES[$i]) > 4) && (!-d "$dir1/$FILES[$i]") )
      {

      $FILEsize2[$i] = (-s "$dir1/$FILES[$i]");
      if ($DBX) {print "$FILES[$i] $FILEsize2[$i]\n\n";}

      if ( ($FILES[$i] !~ /out\.|in\.|lost\+found/i) && ($FILEsize1[$i] eq $FILEsize2[$i]) && (length($FILES[$i]) > 4))
         {
         #$recording_id='';
         $ALLfile = $FILES[$i];
         #$SQLFILE = $FILES[$i];
         #$SQLFILE =~ s/-all\.wav|-all\.gsm|-all\.ogg|-all\.mp3//gi;

         #$stmtA = "select recording_id,start_time from recording_log where filename='$SQLFILE' order by recording_id desc LIMIT 1;";
         #if($DBX){print STDERR "\n|$stmtA|\n";}
         #$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
         #$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
         #$sthArows=$sthA->rows;
         #if ($sthArows > 0)
            #{
            #@aryA = $sthA->fetchrow_array;
            #$recording_id =   "$aryA[0]";
            #$start_date =   "$aryA[1]";
            #$start_date =~ s/ .*//gi;
            #}
      #   $sthA->finish();


   ### BEGIN Remote file transfer
         $p = Net::Ping->new();
         $ping_good = $p->ping("$VARFTP_host");

         if ($ping_good)
            {
            $start_date_PATH='';
            $FTPdb=0;
            if ($DBX>0) {$FTPdb=1;}
            $ftp = Net::FTP->new("$VARFTP_host", Port => $VARFTP_port, Debug => $FTPdb);
            $ftp->login("$VARFTP_user","$VARFTP_pass");
            $ftp->cwd("$VARFTP_dir");
            if ($NODATEDIR < 1)
               {
               $ftp->mkdir("$start_date");
               $ftp->cwd("$start_date");
               $start_date_PATH = "$start_date/";
               }
            $ftp->binary();
            $ftp->put("$dir2/$ALLfile", "$ALLfile");
            usleep(1*200*1000);
            $filesize1 = -s "$dir2/$ALLfile";
            $filesize2 = $ftp->size("$ALLfile");
            if ($filesize1 = $filesize2)
               {
               if ($DB) {print " " . $ALLfile . " was successfully put to ftp" . "\r\n";}
               if (!$T)
                  {
                  if ($DEL=1)
                     {
                     `rm -f "$dir2/$ALLfile"`;
                     }
                  else
                     {
                     `mv -f "$dir2/$ALLfile" "$dir2/DONE/"`;
                     }
                  }
               }
            else
               {
               if ($DB) {print "ERROR !!! " . $ALLfile . " was NOT successfully put to ftp" . "\r\n";}
               }
            $ftp->quit;
            }
   ### END Remote file transfer

         ### sleep for twenty hundredths of a second to not flood the server with disk activity
         usleep(1*200*1000);

         }
      }
   $i++;
   }

if ($DB) {print "DONE... EXITING\n\n";}

#$dbhA->disconnect();


exit;


Posting it just for the idea what you could change, in the name of safety- use when you understand the changes made and at your own risk.
Hope this little helps.

PostPosted: Sun Mar 08, 2009 7:54 pm
by mflorell
Would you mind posting this to the issue tracker?

PostPosted: Mon Mar 09, 2009 3:24 am
by okli
Sure not :) Will clean it up a bit and post it.

PostPosted: Thu Mar 12, 2009 12:02 pm
by okli

PostPosted: Mon Oct 19, 2009 5:16 am
by kimhoogenberg
Matt,

Can voicemail be setup different per in-group, including e-mail option and message that will be played to the customer calling? Do I need to change configuration files manually for this in version 2.0.5?

I can't find anything helpful in the Manager Manual 2.0.5 yet, so any help on this will be very much appreciated.

Regards, Kim

PostPosted: Mon Oct 19, 2009 3:24 pm
by mflorell
In SVN trunk you can set up voicemail boxes as you like in the admin.php interface.

PostPosted: Mon Oct 19, 2009 4:14 pm
by kimhoogenberg
Nice, though we're on vicidialNOW 2.0.5, thus CentOS, and running towards production date, so that would be a bit risky.

Or do you mean "you can look at how it is done in svn"?

PostPosted: Mon Oct 19, 2009 5:34 pm
by mflorell
it's automated in SVN trunk

PostPosted: Mon Oct 19, 2009 5:38 pm
by kimhoogenberg
What is? The updates to SVN trunk are, or do you mean the voicemail settings which I would have to do manually in 2.0.5?

PostPosted: Mon Oct 19, 2009 5:57 pm
by mflorell
Voicemail settings in SVN trunk codebase for ViciDial are automatically configured whereas in 2.0.5 you have to do that manually.

PostPosted: Tue Oct 20, 2009 1:08 am
by gardo
@Kim: Voicemails can be setup per ingroup.

Image

Voicemail still needs to be manually configured as Matt has mentioned. You need to edit /etc/asterisk/voicemail.conf. Here's a good link on how to manually setup your voicemail in Asterisk: http://www.voip-info.org/wiki/view/Aste ... email.conf .

Create a voicemail entry per in-group:

[default]

2203 => 1234,ingroup 1,ingroup1@nowhere.com
2204 => 1234,ingroup 2,ingroup2@nowhere.com

Plug those values in the voicemail settings in the vici admin in-group page.

PostPosted: Tue Oct 20, 2009 3:24 am
by kimhoogenberg
@gardo

What extensions are these and which are 'free' so they don't clash with any other vicidial extensions?

PostPosted: Tue Oct 20, 2009 11:15 am
by gardo
You can create your own custom dialplan to dial your voicemail boxes. The Vicidial default is this:

; Give voicemail at extension 8500
exten => 8500,1,VoicemailMain
exten => 8500,2,Goto(s,6)

So if any users dials 8500, they will hear a prompt for their username and password to access their voicemail box.