Tuesday, September 2, 2014

Asterisk Voicemail

Asterisk Voicemail





Features

  • Password protected
  • Separate away and unavailable greetings
  • Default or custom greetings
  • Multiple mail folders
  • Web interface for checking of voicemail
  • E-mail notification of voicemail with audio file attachment
  • Voicemail forwarding
  • Visual message waiting indicator (MWI)
  • Message waiting stutter dialtone

The number of messages for each voicemailbox is limited to 99 messages. Starting with Asterisk 0.7.1 the system now plays a prompt warning the user that the mailbox is full and cannot record any more messages.

Enhanced voicemail

New features (as of April 28, 2004)
  • Option to have the CID of the caller heard before the voicemail
  • Option to allow an operator to be reached after leaving a voicemail
  • Option to review, rerecord, or save voicemails after leaving them
  • Option to review, rerecord, or save busy, unavailable, and name prompts.
  • Option to allow dialing out from within voicemail
  • Option to allow calling back of the person who left voicemail (with the correctly formatted contexts in extensions.conf)
  • Group voicemail (voicemail broadcast)

VoiceMail contexts.

The context defined in the voicemail.conf corresponds to entries in the channel configuration file, i.e. zapata.conf and sip.conf which require the context to be appended to the mailbox when using VoiceMail2.

Configuration lines for a voicemailbox in 

voicemail.conf:

[general]
cidinternalcontexts = house-admin, house-toll, house-local, house-intercom-only
[default]
1234 => 1234,Some User,email@address.com,pager@address.com,saycid=yes|dialout=fromvm|callback=fromvm|review=yes|operator=yes

Line in zapata.conf or sip.conf:

mailbox=210@YourVoicemailContext

The location of saved messages also changes with the context:
/var/spool/asterisk/voicemail/YourVoicemailContext/210/INBOX

VoiceMail includes a time stamp with the message by default.

When listening to a message you'll hear when it was recorded.

Please note

  • Voicemails are saved on the server in all formats specified in voicemail.conf, but only the first format specified is sent as an attachment to the email.
  • The /contrib/scripts directory of /usr/src/asterisk contains a Perl script that can be applied to regularly expire too old voicemail messages

Sending voicemail emails as MP3's


The easiest way to have Asterisk send voicemails as mp3 files is to use the script found on www.generationd.com This script even extracts the message number, sender name, sender number, etc. and inserts them as tags into the mp3 file. It even allows you to insert a logo (cover art) for your company into the mp3 file. This scripts also ensure that you can playback voicemail files on android phones! (Format compatability)

Alternatively, you can follow this article Asterisk - Setup voicemail to send email with mp3 attachment to get a detailed explaination how to setup Asterisk to send voicemail by email with mp3 audio attachment. This method uses only bash script and usual linux tools.

Here is another method for sending voicemail as an MP3 using a perl script that works just fine.

note: my <pathto> is /var/lib, some peoples will be /usr/share.
1. ensure "attachfmt=wav" and "format=wav|gsm"
2. Put the below script in: /<pathto>/asterisk/agi-bin/mp3vm.pl
3. chmod a+rx mp3vm.pl
4. modify mailcmd=perl /<pathto>/asterisk/agi-bin/mp3vm.pl
5. install lame if you don't already have it
6. check the path to perl, base64, dos2unix and lame and modify the script and mailcmd as needed. (If you are getting 0kb files, your path to lame is likely wrong.)

#!/usr/bin/perl
open(VOICEMAIL,"|/usr/sbin/sendmail -t");
open(LAMEDEC,"|/usr/bin/dos2unix|/usr/bin/base64 -di|/usr/local/bin/lame --quiet --preset voice - /var/spool/asterisk/tmp/vmout.$$.mp3");
open(VM,">/var/spool/asterisk/tmp/vmout.debug.txt"); 
my $inaudio = 0;
loop: while(<>){
  if(/^\.$/){
    last loop;
  }
  if(/^Content-Type: audio\/x-wav/i){
    $inaudio = 1;
  }
  if($inaudio){
    while(s/^(Content-.*)wav(.*)$/$1mp3$2/gi){}
    if(/^\n$/){
      iloop: while(<>){
        print LAMEDEC $_;
        if(/^\n$/){
          last iloop;
        }
      }
      close(LAMEDEC);
      print VOICEMAIL "\n";
      print VM "\n";
      open(B64,"/usr/bin/base64 /var/spool/asterisk/tmp/vmout.$$.mp3|");
      while(<B64>){
        print VOICEMAIL $_; 
        print VM $_;    
      }
      close(B64);
      print VOICEMAIL "\n";
      print VM "\n";
      $inaudio = 0;
    }
  }
  print VOICEMAIL $_;
  print VM $_;
}
print VOICEMAIL "\.";
print VM "\.";
close(VOICEMAIL);
close(VM);

#CLEAN UP THE TEMP FILES CREATED
#This has to be done in a separate cron type job
#because unlinking at the end of this script is too fast,
#the message has not even gotten piped to send mail yet

attribution: minor modifications to script from user "analognipple" from trixbox.org

Dependencies

  • The voicemail system follows the language setting
  • The voicemail storage directory is specified in asterisk.conf
  • The sound files used for prompts is by default english.

Asterisk cmd VoiceMail

Synopsis

Leave a voicemail message in one or more mailboxes.

Description

VoiceMail([flags]boxnumber[@context][&boxnumber2[@context]][&boxnumber3])
or
VoiceMail(boxnumber[@context][&boxnumber2[@context]][&boxnumber3],[flags])

Deprecation in 1.4-trunk
As of 1.4-trunk, flags must be passed after the | (pipe). The ability to pass the flags after a comma or before the box number has been removed.
VoiceMail(boxnumber[@context][&boxnumber2[@context]][&boxnumber3]|[flags])

As of 1.6
As of version 1.6 flags must be passed after the box number seperated by a comma. The usage of the pipe (|) symbol is deprecated. Following format is right for 1.6 and higher (tested on 16th of juli 2009 in version 1.6.1.1).
VoiceMail(boxnumber[@context][&boxnumber2[@context]][&boxnumber3],[flags])

Records the channel, saving an audio file in a given voicemail boxnumber, which must be configured in voicemail.conf. The boxnumber may be preceeded by one or more flags or these may be specified as the second argument:
  • s: The letter s, if present, causes the instructions ("Please leave your message after the tone. When done, hang up, or press the pound key.") to be skipped.
  • u: The letter u, if present, causes the unavailable message to be played. By default, the message says, "The person at extension ... 1234 ... is unavailable," but the mailbox owner may record their own unavailable message with the VoicemailMain command.
  • b: The letter b, if present, causes the busy message to be played. By default, the message says, "The person at extension ... 1234 ... is busy."
  • g(#): (Only when specifying the flags as the second argument) Adjust the gain of the recording. The # is an integer representing the amount of gain in decibels. (This actually sets a channel option to increase the RX gain, this option is unfortunately only supported on Zap, see the volgain voicemail.conf option to have asterisk call sox to adjust the gain on voicemails sent as email attachements)
You may not specify both u and b flags together. You may, however, combine them with s, giving six possibiities:
  1. s: Play nothing.
  2. (no flags): Play instructions.
  3. su: Play unavailable message.
  4. u: Play unavailable message, then instructions.
  5. sb: Play busy message.
  6. b: Play busy message, then instructions.
In all cases, the beep.gsm file will also be played, prior to starting to record.

This application will set the following channel variable upon completion:
VMSTATUS - This indicates the status of the execution of the VoiceMail application.
The possible values are:
  • SUCCESS: Caller left message successfully
  • USEREXIT: Caller exited VM by keypress
  • FAILED: Caller did not leave message or any issue to cause a message to not be left
The voicemail messages will be saved into the inbox directory for that voicemail boxnumber:
  • /var/spool/asterisk/voicemail/context/boxnumber/INBOX/
If the caller presses 0 (zero) during the announcement, and the option 'operator=yes' is set in voicemail.conf either in the general section or for this mailbox then he will be moved to extension 'o' (as in "Out") in the current voicemail context. This could be used as an escape for a receptionist. If you don't want it, just configure extension o to go back to voicemail, or configure operator=no, otherwise the call will be hangup due to the fact that extension 'o' doesn't exist.

Also. during the prompt if the caller presses:
'*' - the call jumps to extension 'a' in the current voicemail context.
Example:
Exten => a, 1, VoicemailMain(@default)
Exten => a, 2, Hangup
'#' - the greeting and/or instructions are stopped and recording starts immediately.

NOTE: The below information is not correct in version 1.2.x. The a and o extensions must exist within the current context.

When using the zero '0' and star '*' it's important to note that the context you placed the application voicemail in is irrelvant, it's the context for the voicemail box that we're looking for in the dialplan for the jump to the 'a' or 'o' extention.
I tested this using a macro to call voicemail and pressing '0' and/or '*' first jumped back to the macro that called voicemail, to look for 'o' and/or 'a' in that macro, if it failed it jumpted to the context defined in voicemail.conf. I'm running CVS version 1.07

If the requested mailbox does not exist, and there exists a priority n+101, then that priority will be taken next.

If, during the recording the caller presses:
'#' - or the defined silence limit is exceeded, recording is stopped and the call continues at priority n+1.

Be sure you do something with the caller after they come back from Voicemail(), at the very least:
...
exten => somewhere,5,Playback(Goodbye)
exten => somewhere,6,Hangup

Examples


Voicemail(1)
Voicemail(b1234@default)
Voicemail(b1234&1704@home)
Voicemail(su${EXTEN})

Asterisk cmd VoiceMailMain

Synopsis:

Enter voicemail system

Description:

VoiceMailMain([[[s]mailbox][@context])

Enters the main voicemail system for the checking of voicemail. The mailbox can be passed as the option, which will stop the voicemail system from prompting the user for the mailbox.

If the mailbox is preceeded by 's' then the password check will be skipped. If a context is specified, logins are considered in that context only.

Menu

  • 1 Read voicemail messages
    • 3 Advanced options (with option to reply; introduced in Asterisk CVS Head April 28, 2004 with 'enhanced voicemail')
      • 1 Reply
      • 2 Call back(1)
      • 3 Envelope
      • 4 Outgoing call(1)
      • 5 Send Message (only available if sendvoicemail=yes in voicemail.conf)
    • 4 Play previous message
    • 5 Repeat current message
    • 6 Play next message
    • 7 Delete current message
    • 8 Forward message to another mailbox
      • 1 Use Voicemailnumber (only available if usedirectory=yes in voicemail.conf)
      • 2 Use Voicemail Directory (only available if usedirectory=yes in voicemail.conf)
    • 9 Save message in a folder
      • 0 Save in new Messages
      • 1 Save in old Messages
      • 2 Save in Work Messages
      • 3 Save in Family Messages
      • 4 Save in Friends Messages
    • * Help; during msg playback: Rewind
    • # Exit; during msg playback: Skip forward
  • 2 Change folders
    • 0 Switch to new Messages
    • 1 Switch to old Messages
    • 2 Switch to Work Messages
    • 3 Switch to Family Messages
    • 4 Switch to Friends Messages
  • 3 Advanced Options
    • 5 Send Message (only available if sendvoicemail=yes in voicemail.conf)
      • 1 Use Voicemailnumber (only available if usedirectory=yes in voicemail.conf)
      • 2 Use Voicemail Directory (only available if usedirectory=yes in voicemail.conf)
  • 0 Mailbox options
    • 1 Record your unavailable message
    • 2 Record your busy message
    • 3 Record your name
    • 4 Record your temporary message (new in Asterisk v1.2)
      • 1 Record your temporary message
      • 2 Erase your temporary message (going back to the standard message)
    • 5 Change your password
    • * Return to the main menu
  • * Help
  • # Exit
  • After recording a message (incoming message, busy/unavail greeting, or name)
    • 1 - Accept
    • 2 - Review
    • 3 - Re-record
    • 0 - Reach operator(1) (not available when recording greetings/name)

(1) Prompts for these are only played if these options are enabled in voicemail.conf

If you are using text based configuration (not database) of the voicemail system, the voicemail.conf configuration file needs to be writable by the asterisk server.

While listening to a recorded voicemail message: Press # to fastforward, or * to rewind by skipms increments. Skipms defaults to 3000 ms and is configurable in voicemail.conf. Note that the # and * keys only work when the message is in the process of being played back

Notes

  • Logging In: When calling VoiceMailMain without specifying a context, whether specifying a box number or alllowing the built-in prompt, if there are two boxes with the same number in different contexts, the last one specified in the voicemail.conf file will be used. You will not be able to log into the other boxes unless you specify the context when calling VoiceMailMain.

New in Asterisk 1.2

Description:

VoiceMailMain([mailbox][@context][|options])

Options:

p - Consider the mailbox parameter as a prefix to the mailbox that is entered by the caller.
g(#) - Use the specified amount of gain when recording a voicemail message. The units are whole-number decibels (dB).
s - Skip checking the passcode for the mailbox.
a(#) - Auto play new messages in the given folder

Folders for the autoplay option:

0 - INBOX
1 - Old
2 - Work
3 - Family
4 - Friends
5 - Cust1
6 - Cust2
7 - Cust3
8 - Cust4
9 - Cust5

Announce Name Before Voicemail Playback: Asterisk 1.2 supports 'categories' that can be assigned to voicemail messages before they are left, and playback of a pre-recorded prompt before the message is played back based on the category name. If there is e.g. a (relatively small) number of companies sharing this mailbox, this would be the easiest way to go. Use the ${VM_CATEGORY} channel variable for this.

Modifications

Q: How can I disable dtmf-input 2,3,4 if I only want the menu behind option 1 available ?

A: (June 2010) In the C code, find:

case '2': /* Change folders */
if (useadsi)
adsi_folders(chan, 0, "Change to folder...");
cmd = get_folder2(chan, "vm-changeto", 0);

then add the lines:

+ cmd = 0; /* Go back to root menu */+ break; /* don't continue */
so it look like this:

case '2': /* Change folders */
cmd = 0; /* Go back to root menu */
break; /* don't continue */
if (useadsi)
adsi_folders(chan, 0, "Change to folder...");
cmd = get_folder2(chan, "vm-changeto", 0);

add the same lines to case 3 and 4..

Asterisk cmd HasNewVoicemail

Synopsis:

Conditionally branches to priority + 101

Description

HasNewVoicemail(vmbox[@context][:folder][|varname])
HasVoicemail(vmbox[@context][:folder][|varname])

New!!
HasNewVoicemail(vmbox[/folder][@context][|varname[|options]])
HasVoicemail(vmbox[/folder][@context][|varname[|options]])

Branches to priority + 101, if there is new voicemail in the folder indicated. Optionally sets <varname> to the number of new messages. Assumes folder of INBOX if not specified.

Options

  • j Is need to jump.
  • These commands are now deprecated in favour of the VMCOUNT function
  • Written originally to (and therefore useful for) determining how many times an incoming call will ring. If there is no new voicemail, the phone might be allowed to ring several more times, possibly saving a toll call when there are no new messages to retreive.
  • Since 05/01/04, HasNewVoicemail has been implemented as a synonym for HasVoicemail. Until 10/03/04, these commands did not actually select any default folder, contrary to documentation, so a folder needs to be specified (:folder) in versions between those dates (including 1.0.0, 1.0.1 and CVS-HEAD-08/13/04-12:00:00-BRI-stuffed-0.1.0-RC4a).

Asterisk cmd MailboxExists

Synopsis:

Check if vmbox exists

Description:

MailboxExists(mailbox[@context])

Conditionally branches to priority n+101 if the specified voice mailbox exists.

(:exclaim:) This command was added to the development (CVS) edition of Asterisk on 2004-03-19. It does not exist in Asterisk 1.0 or 0.9.
Asterisk 11DeprecatedUse VM_INFO(mailbox,exists)

For Asterisk 1.2.x the following is valid:

Synopsis:

Check to see if Voicemail mailbox exists

Description:

MailboxExists(mailbox[@context][|options])

Check to see if the specified mailbox exists. If no voicemail context is specified, the 'default' context will be used.

This application will set the following channel variable upon completion:

VMBOXEXISTSSTATUS - This will contain the status of the execution of the
MailboxExists application. Possible values include:
SUCCESS | FAILED

Options:

j - Jump to priority n+101 if the mailbox is found.

For Asterisk 1.6.x the following is valid:

Synopsis:

Check to see if Voicemail mailbox exists. Has been changed to a function which means that you can use it in GotoIf.

Description:

MailboxExists(mailbox[@context][,options])

Check to see if the specified mailbox exists. If no voicemail context is specified, the 'default' context will be used.

This application will set the following channel variable upon completion:

VMBOXEXISTSSTATUS - This will contain the status of the execution of the
MailboxExists application. Possible values include:
SUCCESS | FAILED

Options:

None. This is a change from 1.4. j does not jump to n+101 to do that, use
GotoIf(${MAILBOX_EXISTS(${ARG1}@residential)} = "1"?labeltojumpto)

Asterisk MWI

Message Waiting Indication (MWI)

MWI across multiple Asterisk servers

Depending on how you want to set it up, just use externnotify= and a script that touches the msg<num>.txt file in the user's vm directory on the other boxes. We're using ssh, you may choose to use a different method. It's an immediate MWI notification, and seems to work well.

Legacy integration
  • Avaya or Lucent Magix Voicemail Integration
  • Asterisk at large: MWI integration with SER
  • Asterisk ast_data: Asterisk 1.0.x with SER and MWI integration

MWI when modifying mailboxes from outside of asterisk 1.8

after copying/inserting a message (msg0000.gsm msg0000.txt msg0000.WAV msg0000.wav) in the INBOX of a voicemail,
do :

touch /etc/asterisk/voicemail.conf
asterisk -r -x 'reload app_voicemail.so'

it will scans the mailboxes and refresh MWI across all phones.

Asterisk sound files

June 10th 2011: High Quality Dutch Prompts (Nederlands)

Default Asterisk PBX voice prompts in Dutch offered by DialXS.

January 5th 2009: German Text-To-Speech engine

Free web-based Text-to-Speech engine to generate custom voice prompts 

October 31st 2008 : New German Male Voice available for free use!

professional digital recording, already converted to GSM ready.

April 21th 2008 : Spanish voices available free under Creative Commons License.

A free Spanish Voice Pack under the Creative Commons License.

December 20th 2006 : New french voices services

123Messagepro.com offers a new Web service to create your own greeting message. With a new technology (TTS and music mixed together), you can have french and english messages. For the moment, there are only 2 languages (FR, UK/US) and 6 voices, but they'll add more voices for 2007. 

December 2006: American English third-party sound files released

free full voice-pack containing over 1,500 sound files intended to replace the default sound files distributed with Asterisk. The studio recordings are high-quality and feature a very pleasant and professional female voice speaking American English. These voice-packs are offered in Asterisk Native (sln) format, u-law, a-law, and GSM. Voice Vector Media also offers inexpensive custom recording services to extend and customize this voice-pack. The company's web site lists additional voice-packs in production for a male voice speaking American English and a female voice speaking British English. 

June 2006: New Zealand voice prompts available

A  free series of New Zealand english asterisk voice prompts.

May 2006: British English voice prompts available

EniCommunications corp is kindly offering the Asterisk community a free series of British English recordings in various formats including SLIN, WAV, alaw, ulaw, gsm, g723 and g729. The files are of a high quality. You should make a copy of the original sound files beforehand as you may wish to copy back various ones (like the 'beeps') that aren't included with this new set - eg:

cd /var/lib/asterisk
mv sounds sounds.orig
mkdir sounds
mkdir sounds/custom (make this or freepbx complains)
cd sounds
tar xvfz /path/to/downloaded/sounds/file
(repeat tar for all downloaded files)
chown -R asterisk:asterisk ../sounds
(copy from sounds.orig all *beep* files and anything else you find missing)
amportal restart

To avoid having to go hunting for missing files, or to enable you to switch languages in channels you can do this:

Download and decompress all versions apart from the 44k wavs (I found tar did not recognise the file format and I had to use WinRAR)
mkdir /var/lib/asterisk/sounds/en_GB
move all files into en_GB, merging the files in each directory
chown -R asterisk:asterisk /var/lib/asterisk/sounds/en_GB
In sip_custom.conf add the line: language=en_GB
Restart

Notes (based on Asterisk@home 2.8)

At the time of writing (30th May 2006):
  • The g729 download on the site seems to contain g723 files.
  • Some essential recordings are missing - for example, a couple for conferences, which can be fixed by issuing the following commands from the sounds directory:
cp conf-getpin.sln enter-conf-pin-number.sln
cp conf-getconfno.sln enter-conf-call-number.sln
  • "goodbye" is also missing but can be extracted from demo-thanks.wav using Audacity and then processed into an sln file with sox using the command: sox goodbye.wav -t raw -r 8000 -s -w -c  1 goodbye.sln
  • The speaking clock announcement is also missing but can be created by editing a copy of queue-holdtime.wav to make it say "The time is currently" and editing extensions_custom.conf to point to your new sln file created with sox.
  • One or more sound files for the voicemail service are missing and so voicemail hangs up when you try to listen to your messages.

The site owners have been informed of these issues and sent the missing sound files so things may be fixed by the time you download the tar files.

Jan 2006: Standard prompts now in native format (instead of GSM)

Asterisk Native Sounds are a collection of audio prompts for Asterisk. They will improve quality, reduce CPU usage, reduce latency, and (in some cases) eliminate the need for G729 licenses!

cd /var/lib/asterisk/
mv sounds sounds.orig
tar -xvjf /path/to/sounds.tar.bz2

(repeat last step for other formats)
The audio prompts are available from the "Extras" category 

Recording hints

If you want to record sound files with Asterisk, you may use the record application.
If you record in a studio, use 8kHz 16 bits, not 8 bits. The phone line is 12 to 13 bits compressed down to 8 in a pseudo-logarithmic way. If you start with 8 bit linear data it will sound considerably worse than 8 bit data, unless the volume is very uniform.

A very useful application is Audacity. This is open source (like Asterisk) and is used by professional musicians for recording. You can normalise the volume (make it a standard volume) and it is very good at removing background noise.

An alternative for Windows is WavePad Sound Editor for Windows. It is also free.

If you are lucky enough to have CoolEdit (now called Adobe Audition), you should record your source material using a high (at least 44Khz) sample rate, apply any filters or normalization that you want, then downsample your audio to 8000hz and save in Windows PCM wav (16 bit) format.

When recording find a really quiet place. Background noise is usually the biggest hassle when recording prompts. Other than that, use a reasonable mic; fix it down someplace (don't hand hold it); and get your "voice model" to sit comfortably, so they sound nice and relaxed. Choose a friend or colleague - someone easily accessible for more recordings when you realise you have forgotten some.

Developing IVR Menus: This page contains some hints for developing IVR menus which may be useful.

Tip: Transcoding consumes CPU power, so ideally you have your prompts in a file format that already matches the current channel's codec. Type show file formats at the Asterisk CLI to get an overview of the available formats.

Note: With Asterisk 1.2.x the transcoding behaviour changed: SLINEAR (signed linear) is now the "root" format and thus it is probably an excellent idea to encode your sound files as SLINEAR as well.

Adjusting the volume

After cutting the prompts and saving them (audacity works nice for that), this little script makes sure that all the voice prompts have more-or-less the same (maximum) volume:
  1. !/bin/sh
tmpfile=/tmp/rescale$$.wav
for i in *.wav; do
scale=$(sox "$i" /tmp/foo.wav stat -v 2>&1)
if [ $scale != "1.000" ]; then
echo -n "Rescale $i..."
cp "$i" $tmpfile
sox $tmpfile -v $scale "$i"

echo
fi
done

Creating GSM files with sox

This is how you convert wav files to gsm files used by Asterisk

$ sox inputfile.wav -r 8000 -c 1 outputfile.gsm resample -ql

Converting all files in a directory:
for i in *.wav; do sox $i -r 8000 -c 1 $(basename $i .wav).gsm resample -ql; done

sox has many features, I have found that when converting from
44 Khz wav files adding the option resample -ql gives the best results.

Mixing .wav files into a single .gsm:

exten => s,1,SetVar(MONITORDIR=/var/spool/asterisk/monitor)
exten => s,2,GotoIf($[${CALLFILENAME} = ${FOO}]?6:3)
exten => s,3,System(soxmix ${MONITORDIR}/${CALLFILENAME}-in.wav ${MONITORDIR}/${CALLFILENAME}-out.wav ${MONITORDIR}/${CALLFILENAME}.gsm)
exten => s,4,System(/bin/rm ${MONITORDIR}/${CALLFILENAME}-in.wav ${MONITORDIR}/${CALLFILENAME}-out.wav)
exten => s,5,NoOp

If you'd like to use sox to simply examine a sound file use this little snippet (of course .raw files won't return much info because the don't have any describing headers embedded in the file):

sox -V file.wav -e stat (with latest version of sox : "sox -V file.wav -n")

Creating GSM files with gstreamer

gst-launch filesrc location="input.mp3" ! spider ! volume volume=0.6 ! audioconvert ! audioscale ! audio/x-raw-int,channels=1,rate=8000 ! gsmenc ! filesink location="output.gsm"

Joining files

cat 1.gsm 2.gsm 3.gsm > new.gsm

Editing files

On Win32, a utility which can edit .gsm files direct is WavePad
Alternatively view http://www.objectivevoice.com/addcodec95.html on how to install gsm codec on Win95/98 and then play it with sndrec32 or some such...plays natively on my windows boxes...

Tools for converting GSM files

  • Switch Sound Format Converter
  • GX::Transcoder: Freeware tool for sound conversion, including g729 and g723 formats
  • On-line audio conversion by asteriskguru.com, including G729 and g723 formats
  • SoundConverter

Playing GSM files on Windows

First of all take a look at WavePad.
Playing GSM files can also be done using freely available Quicktime player.
Moreover you can use this free Winamp plugin http://www.mlkj.net/gsm/winamp_plugin_gsm_codec.php
Another useful tool is j2 messenger.
Java applet for playing gsm files in a web browser http://www.westhawk.co.uk/software/playGSM/PlayGSM.html
Flash-based player, able to playback all asterisk-recorded formats including gsm can be found

Location of the sound files

Asterisk normally looks for a sound file with an extension used for the codec used. If a language is set for the channel with the SetLanguage() application, Asterisk first looks for countrycode/filename where countrycode is the language code (example:. 'fr' for french). Languages and special tones for that country or region are defined in indications.conf.

Performance improvements

  • Store the voice prompts in RAM instead of harddisk: Take a look at ramfs .All you need then is to create a link (ln -s) in /var/lib/asterisk/sound to then ramdrive you created using ramfs.
  • A modern operating system (e.g. Linux) caches often used files in RAM, mitigating this optimization. You might need it if you are accessing lots of different files and the disk cache expires. Perform some tests to see if this is a bottleneck before making your setup more complicated.

AGI enhancements

asterisk-agi-audiotx

This is an extension module for the Asterisk Gateway Interface (AGI) that adds commands to allow the transfer of audio files to and from Asterisk via the AGI session. This is useful when using FastAGI from a remote host; sounds recorded by Asterisk may be retrieved by remote FastAGI-providing service, for example, or sound files required by the remote service may be dynamically added to the Asterisk server.
This module adds the following AGI commands:
  • PUT SOUNDFILE <soundfile> <size>
  • GET SOUNDFILE <soundfile>
  • ISEXISTING SOUNDFILE <soundfile>

Sound file listing

The following files are included in the Asterisk distribution in the directory /var/lib/asterisk/sounds
The text of the sound files can be found in sounds.txt or core-sounds-en.txt (or /usr/share/doc/asterisk-sounds-main/sounds.txt.gz).

Here's yet another transcription of sound files to be found:
  • Master List of sounds, durations, locations, and transcriptions in Asterisk 1.0.7. Also includes an MP3 of each GSM file for easy listening.
  • Standard sounds in Asterisk 1.0.7
  • Additional sounds in Asterisk 1.0.7

General sound files

  • agent-alreadyon: That agent is already logged on. Please enter your agent number followed by the pound key.
  • agent-incorrect: Login incorrect. Please enter your agent number followed by the pound key.
  • agent-loggedoff: Agent Logged off.
  • agent-loginok: Agent logged in.
  • agent-newlocation: Please enter a new extension, followed by pound.
  • agent-pass: Please enter your password followed by the pound key.
  • agent-user: Agent login. Please enter your agent number followed by the pound key.
  • auth-incorrect: Password incorrect. Please enter your password followed by the pound key.
  • auth-thankyou: Thank you.
  • beep: this is a simple beep tone
  • beeperr: this is an error beep tone
  • conf-adminmenu: Please press 1 to mute or unmute yourself, 2 to lock or unlock the conference, 3 to eject the last user, 4 or 6 to decrease or increase the conference volume, 7 or 9 to decrease or increase your volume, or 8 to exit.
  • demo-abouttotry: I am about to attempt an Inter-Asterisk Exchange connection to a demonstration server located at Digium. In order for this to work you must already be connected to the Internet. Please wait a moment while I attempt to make the connection.
  • demo-congrats: Congratulations. You have successfully installed and executed the Asterisk open source PBX. You have also installed a set of sample sounds and configuration files that should help you to get started. Like a normal PBX you will navigate this demonstration by dialing digits. If you are using a console channel driver instead of a real phone you can use the dial, answer, and hang up commands to simulate the actions of a standard telephone.
  • demo-echodone: The echo test has been completed.
  • demo-echotest: You are about to enter an echo test. In this mode everything you say will be repeated back to you just as soon as it is received. The purpose of this test is to give you an audible sense of the latency between you and the machine that is running the echo test application. You may end the test by hanging up or by pressing the pound key.
  • demo-enterkeywords: Please enter one or more keywords separated by * and then press the pound key.
  • demo-instruct: If you would like to learn more technical information about Asterisk dial 2 now. If you'd like to test out the voice over IP capabilities of Asterisk you can dial 500 to attempt an Inter-Asterisk Exchange or IAX connection to a demonstration server at Digium. In order for this test to work you will need to be connected to the Internet and have at least a 28.8 kilobit modem. To execute an echo test dial 600. This test is most useful when you have connected to this Asterisk server from a remote location. The sample configuration also has a single user with extension 1234 and password 4242. That user is configured to ring the console when their extension is dialed. If you dial 1234 you can try to ring the console. If the console is busy or unavailable you will be given the option to leave voicemail. To check voice mail for the user dial extension 8500 to enter the voicemail system. Finally, you can press the pound key to disconnect from the PBX.
  • demo-moreinfo: Asterisk is an Open Source full-featured PBX and IVR platform that runs on the linux operating system. For more information, visit www.asterisk.org.
  • demo-nogo: I am afraid I was unable to create a connection to the Digium demonstration Asterisk server. You may find some helpful debugging information on the Asterisk console.
  • demo-nomatch: I'm sorry there are no matches for those keywords
  • demo-thanks: Goodbye. Thank you for trying out the Asterisk Open Source PBX.
  • dictate/both_help: press * to toggle pause, press # to enter a new dictation filename
  • dictate/enter_filename: Enter a numeric dictation filename followed by # or just # to exit
  • dictate/forhelp: press 0 for help
  • dictate/pause: pause
  • dictate/paused: paused
  • dictate/play_help: press 1 to switch to record mode, press 2 to toggle fast playback, press 7 to jump backwards, press 8 to jump forwards
  • dictate/playback: playback
  • dictate/playback_mode: playback mode
  • dictate/record: record
  • dictate/record_help: press 1 to switch to playback mode, press 8 to truncate the file and start over
  • dictate/record_mode: record mode
  • dictate/truncating_audio: truncating audio
  • dollars: dollars
  • followme/call-from.wav: incoming call from
  • followme/no-recording.wav: you have an incoming call
  • followme/options.wav: press 1 to accept this call, or 2 to reject it
  • followme/pls-hold-while-try.wav: please hold while I try to locate the person you are calling
  • followme/sorry.wav: I'm sorry, but I was unable to locate the person you are calling
  • followme/status.wav: the person you are calling is not at their desk; I will try to locate them for you
  • hello-world: Hello world.
  • hours: hours
  • invalid: I am sorry, that's not a valid extension. Please try again.
  • minutes: minutes
  • pbx-invalid: I am sorry, that's not a valid extension. Please try again.
  • pbx-invalidpark: I am sorry, there is no call parked on that extension. Please try again.
  • pbx-transfer: Transfer.
  • phonetic/9_p: niner
  • phonetic/a_p: alpha
  • phonetic/b_p: bravo
  • phonetic/c_p: charlie
  • phonetic/d_p: delta
  • phonetic/e_p: echo
  • phonetic/f_p: foxtrot
  • phonetic/g_p: golf
  • phonetic/h_p: hotel
  • phonetic/i_p: india
  • phonetic/j_p: juliet
  • phonetic/k_p: kilo
  • phonetic/l_p: lima
  • phonetic/m_p: mike
  • phonetic/n_p: november
  • phonetic/niner: niner
  • phonetic/o_p: oscar
  • phonetic/p_p: papa
  • phonetic/q_p: quebec
  • phonetic/r_p: romeo
  • phonetic/s_p: sierra
  • phonetic/t_p: tango
  • phonetic/u_p: uniform
  • phonetic/v_p: victor
  • phonetic/w_p: whiskey
  • phonetic/x_p: xray
  • phonetic/y_p: yankee
  • phonetic/z_p: zulu
  • priv-callee-options: Dial 1 if you wish this caller to reach you directly now, and in the future. Dial 2 if you wish to send this caller to voicemail now and forevermore. Dial 3 to send this caller to the torture menus, now and forevermore. Dial 4 to send this caller to a polite "don't call" menu, now and forevermore. Dial 5 to allow this caller to come straight thru to you in the future, but just this once, send them to voicemail.
  • priv-callpending: I have a caller waiting, who introduces themselves as:
  • priv-introsaved: Thank you. Please hold, while I attempt to connect you with your party!
  • priv-recordintro: At the tone, please say your name.
  • privacy-incorrect: I'm sorry, that number is not valid.
  • privacy-prompt: Please enter your phone number, starting with the area code.
  • privacy-thankyou: Thank you.
  • privacy-unident: The party you are trying to reach does not accept unidentified calls.
  • queue-callswaiting: Waiting to speak with a representative
  • queue-holdtime: The estimated hold time is currently
  • queue-less-than: less than
  • queue-minutes: Minutes
  • queue-periodic-announce: All of our represenatives are currently busy. Please stay on the line and your call will be answered by the next available representative.
  • queue-reporthold: Hold time
  • queue-seconds: Seconds
  • queue-thankyou: Thank you for your patience
  • queue-thereare: You are currently caller number
  • queue-youarenext: Your call is now first in line and will be answered by the next available representative.
  • screen-callee-options: You have these options: Dial 1 if you wish to immediately connect to the incoming call. Dial 2 if you wish to send this caller to voicemail. Dial 3 to send this caller to the torture menus. Dial 4 to send this caller to a polite "don't call" menu.
  • seconds: seconds
  • spy-agent: Agent
  • spy-dahdi: DAHDI
  • spy-h323: H.323
  • spy-iax2: IAX (note: does not say "2")
  • spy-iax: IAX
  • spy-mgcp: MGCP
  • spy-sip: SIP
  • spy-skinny: Skinny
  • spy-zap: Zap
  • ss-noservice: The number you have dialed is not in service. Please check the number and try again.
  • transfer: Please hold while I try that extension.
  • tt-allbusy: All representatives of the household are currently assisting other telemarketers. Please hold and your call will be answered in the order it was received.
  • tt-monkeys: sound of monkeys screaming
  • tt-monkeysintro: They have been carried away by monkeys
  • tt-somethingwrong: Something is terribly wrong
  • tt-weasels: Weasels have eaten our phone system
  • dir-firstlast: ... letters of your party's first or last name.
  • dir-last: ... letters of your party's last name.
  • dir-multi1: Press ...
  • dir-multi2: ... for ...
  • dir-multi3: ... extension ...
  • dir-multi9: Press 9 for more entries.
  • dir-pls-enter: Please enter the first ...
  • dir-usingkeypad: ... using your touchtone keypad. Use the 7 key for Q, and the 9 key for Z.
  • dir-welcome: Welcome to the directory
  • queue-quantity1: Currently, there are more than ...
  • queue-quantity2: ... callers waiting to speak with a representative.
  • spy-console: Console
  • spy-jingle: Jingle
  • spy-local: Local
  • spy-misdn: M I S D N
  • spy-mobile: Bluetooth Mobile
  • spy-nbs: N B S
  • spy-unistim: Unistim
  • spy-usbradio: USB Radio
  • vm-duration: This message lasts ...
  • vm-invalid-password: That password does not meet the minimum requirements for this mailbox. Please try again.
  • vm-invalidpassword: That is not a valid password. Please try again.
  • vm-marked-nonurgent: Urgent status removed.
  • vm-marked-urgent: Message marked urgent.
  • vm-onefor-full: Press one to listen to ...
  • vm-opts-full: press 2 to access messages saved in other folders. Press 3 to record a message for another mailbox. Press 0 for greetings and password management.
  • vm-review-nonurgent: Press 4 to remove the urgent status of this message.
  • vm-review-urgent: Press 4 to mark this message as urgent.
  • vm-tmpexists: There is a temporary greeting, which overrides your standard greetings.
  • vm-Urgent: urgent

Conferences

  • conf-adminmenu: Please press 1 to mute or unmute yourself. 2 to lock or unlock the conference, 3 to eject the last user, 4 or 6 to decrease or increase the conference volume, 5 to extend the conference, 7 or 9 to decrease or increase your volume, or 8 to exit
  • conf-adminmenu-162: Please press 1 to mute or unmute yourself. 2 to lock or unlock the conference, 3 to eject the last user, 4 or 6 to decrease or increase the conference volume, 5 to extend the conference, 7 or 9 to decrease or increase your volume, or 8 to exit
  • conf-banned: You have been banned from this conference
  • conf-enteringno: You are entering conference number
  • conference: conference
  • conference-call: conference call
  • conference-reservations: conference reservations
  • conf-errormenu: Invalid choice
  • conf-extended: The conference has been extended
  • conf-full: That conference is full
  • conf-getchannel: Please enter the channel number followed by the pound key
  • conf-getconfno: Please enter your conference number followed by the pound key
  • conf-getpin: Please enter the conference PIN number
  • conf-hasentered: has entered the conference
  • conf-hasjoin: is now in the conference.
  • conf-hasleft: has left the conference.
  • conf-invalid: That is not a valid conference number. Please try again.
  • conf-invalidpin: That PIN is invalid for this conference
  • confirm-number-is: Your confirmation number is
  • conf-kicked: You have been kicked from this conference
  • conf-leaderhasleft: The leader has left the conference.
  • conf-locked: This conference is locked
  • conf-lockednow: The conference is now locked
  • conf-muted: You are now muted
  • conf-noempty: No empty conferences currently exist
  • conf-nonextended: The conference cannot be extended
  • conf-onlyone: There is currently one other participant in the conference
  • conf-onlyperson: You are currently the only person in this conference
  • conf-onlypersonleft: You are now the only person left in this conference
  • conf-otherinparty: other participants in the conference
  • conf-peopleinconf: people in this conference
  • conf-placeintoconf: You will now be placed into the conference
  • conf-sysop: The Sysop
  • conf-sysopreq: System operator requested
  • conf-sysopreqcancelled: System operator request cancelled
  • conf-thereare: There are
  • conf-unlockednow: The conference is now unlocked
  • conf-unmuted: You are now unmuted
  • conf-usermenu: Please press 1 to mute or unmute yourself. 4 or 6 to decrease or increase the conference volume, 7 or 9 to decrease or increase your volume or 8 to exit.
  • conf-usermenu-162: Please press 1 to mute or unmute yourself. 4 or 6 to decrease or increase the conference volume, 5 to extend the conference, 7 or 9 to decrease or increase your volume or 8 to exit.
  • conf-userswilljoin: users will join the conference
  • conf-userwilljoin: user will join the conference
  • conf-waitforleader: The conference will begin when the leader arrives
  • conf-youareinconfnum: You are in conference number
  • enter-conf-call-number: Please enter the conference call number for the conference you wish to join
  • enter-conf-pin-number: Please enter the conference PIN number
  • entering-conf-number: You are entering conference number
  • no-empty-conferences: No empty conferences currently exist
  • pls-enter-conf-password: Please enter the conference password

Agent sound files

  • agent-alreadyon: That agent is already logged on. Please enter your agent number followed by the pound key.
  • agent-incorrect: Login incorrect. Please enter your agent number followed by the pound key.
  • agent-loggedoff: Agent logged off.
  • agent-loginok: Agent logged in.
  • agent-newlocation: Please enter new extension, followed by pound.
  • agent-pass: Please enter your password followed by the pound key.
  • agent-user: Agent login. Please enter your agent number followed by the pound key.

Demo sound files

These are used in the [demo] context of extensions.conf in the sample files installed with Asterisk.
  • demo-abouttotry: I am about to attempt an Inter-Asterisk Exchange connection to a demonstration server located at Digium. In order for this to work you must already be connected to the Internet. Please wait a moment while I attempt to make the connection.
  • demo-congrats: Congratulations. You have successfully installed and executed the Asterisk open source PBX. You have also installed a set of sample sounds and configuration files that should help you to get started. Like a normal PBX, you will navigate this demonstration by dialing digits. If you are using a console channel driver instead of a real phone you can use the dial, answer, and hang up commands to simulate the actions of a standard telephone.
  • demo-echodone: The echo test has been completed.
  • demo-echotest: You are about to enter an echo test. In this mode everything you say will be repeated back to you just as soon as it is received. The purpose of this test is to give you an audible sense of the latency between you and the machine that is running the echo test application. You may end the test by hanging up or pressing the pound key.
  • demo-enterkeywords: Please enter one or more keywords separated by star and then press the pound key.
  • demo-instruct: If you would like to learn more technical information about Asterisk, dial 2 now. If you'd like to test out the voice-over-IP capabilities of Asterisk, you can dial five-hundred to attempt an Inter-Asterisk Exchange, or IAX connection to a demonstration server at Digium. In order for this test to work, you will need to be connected to the Internet and have at least a twenty-eight-point-eight kilobit modem. To execute an echo test, dial six-hundred. This test is most useful when you have connected to this Asterisk server from a remote location. The sample configuration also has a single user with extension one two three four, and password four two four two. That user is configured to ring the console, when their extension is dialed. If you dial one two three four, you can try to ring the console. If the console is busy, or unavailable, you will be given the option to leave voicemail. To check voice mail for the user dial extension eight five zero zero to enter the voicemail system. Finally, you can press the pound key to disconnect from the PBX.
  • demo-moreinfo: Asterisk is an open source, full-featured PBX and IVR platform that runs on the Linux operating system. For more information visit w w w dot asterisk dot org.
  • demo-nogo: I am afraid I was unable to create a connection to the Digium demonstration Asterisk server. You may find some helpful debugging information on the Asterisk console.
  • demo-nomatch: I'm sorry there are no matches for those keywords.
  • demo-thanks: Goodbye. Thank you for trying out the Asterisk Open Source PBX.

Directory

  • dir-welcome: Welcome to the directory
  • dir-firstlast: letters of your parties first or last name
  • dir-multi1: Press
  • dir-nomore: There are no more compatible entries in the directory
  • dir-multi3: extension
  • dir-usingkeypad: using your touchtone keypad. Use the 7 key for Q and the 9 key for Z
  • dir-multi2: for
  • dir-nomatch: No directory entries match your search
  • dir-intro-fn: Welcome to the directory. Please enter the first three digits of your parties first name using your touchtone keypad. Use the 7 key for Q and the 9 key for Z
  • dir-last: letters of your parties last name
  • dir-multi9: Press 9 for more entries
  • dir-instr: If this is the person you are looking for, press 1 now. Otherwise please press * now.
  • dir-intro: Welcome to the directory. Please enter the first three letters of your parties last name using your touchtone keypad. Use the 7 key for Q and the 9 key for Z
  • dir-pls-enter: Please enter the first
  • dir-first: letters of your parties first name

Voicemail sound files

  • vm-advopts: Press 3 for advanced options.
  • vm-and: and
  • vm-calldiffnum: Press 2 to enter a different number
  • vm-changeto: Change to which folder?
  • vm-Cust1: Folder. Five.
  • vm-Cust2: Folder. Six.
  • vm-Cust3: Folder. Seven.
  • vm-Cust4: Folder. Eight.
  • vm-Cust5: Folder. Nine.
  • vm-delete: Press 7 to delete this message.
  • vm-deleted: Message deleted.
  • vm-dialout: Please wait while I connect your call.
  • vm-duration: This message lasts
  • vm-enter-num-to-call: Please enter the number you wish to call.
  • vm-extension: extension
  • vm-Family: family
  • vm-first: first
  • vm-for: for
  • vm-forward: Press 1 to enter an extension. Press 2 to use the directory.
  • vm-forward-multiple: Press 1 to send this message or 2 to add another recipient
  • vm-forwardoptions: Press 1 to prepend the message, or 2 to forward a message without prepending.
  • vm-Friends: friends
  • vm-from: from
  • vm-from-extension: message from extension
  • vm-from-phonenumber: message from phone number
  • vm-goodbye: goodbye
  • vm-helpexit: Press star for help or pound to exit.
  • vm-INBOX: new
  • vm-incorrect: Login incorrect.
  • vm-incorrect-mailbox: Login incorrect. Mailbox:
  • vm-instructions: To look into your messages press 1 now. You may quit voicemail at any time by pressing the pound key.
  • vm-intro: Please leave your message after the tone. When done hang up or press the pound key.
  • vm-invalid-password: That password does not meet the minimum requirements for this mailbox
  • vm-invalidpassword: That is not a valid password. Please try again.
  • vm-isonphone: — is on the phone.
  • vm-isunavail: — is unavailable.
  • vm-last: last
  • vm-leavemsg: Press 5 to leave a message
  • vm-login: Commedian Mail. Mailbox:
  • vm-mailboxfull: sorry but the user's mail box can't accept more messages
  • vm-marked-nonurgent: Urgent status removed
  • vm-marked-urgent: Message marked urgent
  • vm-message: message
  • vm-messages: messages
  • vm-minutes: minutes
  • vm-mismatch: The passwords you entered and re-entered did not match.
  • vm-msginstruct: To hear the next message press 6. To repeat this message press 5. To hear the previous message press 4. To delete or undelete this message press zero. To quit voicemail press pound.
  • vm-msgsaved: Your message has been saved.
  • vm-newpassword: Please enter your new password followed by the pound key.
  • vm-newuser: Welcome to commedian mail. First I will guide you through a short setup process
  • vm-next: Press 6 to play the next message
  • vm-no: no
  • vm-nobodyavail: Nobody is available to take your call at the moment.
  • vm-nobox: You cannot reply to this message because the sender does not have a mailbox.
  • vm-nomore: No more messages.
  • vm-nonumber: I'm afraid I don't know who sent this message
  • vm-num-i-have: The number I have is
  • vm-Old: old
  • vm-onefor: Press 1 for
  • vm-onefor-full: Press 1 to listen to
  • vm-options: Press 1 to record your unavilable message. Press 2 to record your busy message. Press 3 to record your name. Press 4 to manage your temporary greeting. Press 5 to change your password. Press * to return to the main menu.
  • vm-opts: Press 2 to change folders. Press 3 for advanced options. Press zero for mailbox options.
  • vm-opts-full: Press 2 to access messages saved in other folders. Press 3 to record a message for another mailbox. Press zero for greetings and password management.
  • vm-passchanged: Your passwords have been changed.
  • vm-password: password
  • vm-press: press
  • vm-prev: Press 4 for the previous message.
  • vm-reachoper: Press 0 to reach an operator.
  • vm-rec-busy: After the tone say your busy message and then press the pound key.
  • vm-received: received
  • vm-rec-name: After the tone say your name and then press the pound key.
  • vm-record-prepend: At the tone please record an introduction to the forwarded message. When done press the pound sign.
  • vm-rec-temp: After the tone say your temporary message and then press the pound key.
  • vm-rec-unv: After the tone say your unavailable message and then press the pound key.
  • vm-reenterpassword: Please reenter your password followed by the pound key.
  • vm-repeat: Press 5 to repeat the current message.
  • vm-review: Press 1 to accept this recording. Press 2 to listen to it. Press 3 to re-record your message.
  • vm-review-nonurgent: Press 4 to remove the urgent status of this message
  • vm-review-urgent: Press 4 to mark this message as urgent
  • vm-saved: saved
  • vm-savedto: saved to
  • vm-savefolder: Which folder should I save the message to?
  • vm-savemessage: or 9 to save this message.
  • vm-saveoper: Press 1 to accept this recording otherwise continue to hold.
  • vm-sorry: I'm sorry I did not understand your response.
  • vm-star-cancel: Press * to cancel
  • vm-starmain: Press * to return to the main menu
  • vm-tempgreetactive: Your temporary greeting is currently active
  • vm-tempgreeting2: Press 1 to record your temporary greeting or press 2 to erase your temporary greeting.
  • vm-tempgreeting: Press 1 to record your temporary greeting
  • vm-tempremoved: Your temporary greeting has been removed
  • vm-then-pound: then press pound
  • vm-theperson: The person at extension
  • vm-tmpexists: There is a temporary greeting which overrides your standard greetings
  • vm-tocallback: Press 2 to call the person who sent this message
  • vm-tocallnum: Press 1 to call this number
  • vm-tocancel: or pound to cancel.
  • vm-tocancelmsg: Press * to cancel this message
  • vm-toenternumber: Press 1 to enter a number
  • vm-toforward: Press 8 to forward the message to another user.
  • vm-tohearenv: Press 3 to hear the message envelope
  • vm-tomakecall: Press 4 to place an outgoing call
  • vm-tooshort: Your message is too short
  • vm-toreply: Press 1 to send a reply
  • vm-torerecord: Press 3 to re-record your message
  • vm-undelete: Press 7 to undelete this message.
  • vm-undeleted: Message undeleted.
  • vm-unknown-caller: from an unknown caller
  • vm-Urgent: urgent
  • vm-whichbox: To leave a message, please enter a mailbox number.
  • vm-Work: work
  • vm-youhave: you have

Letters

  • a: a
  • ascii123: left brace
  • ascii124: pipe
  • ascii125: right brace
  • ascii126: tilde
  • ascii34: quote
  • ascii36: dollar sign
  • ascii37: percent
  • ascii38: ampersand
  • ascii39: tick
  • ascii40: open parenthesis
  • ascii41: close parenthesis
  • ascii42: star
  • ascii44: comma
  • ascii58: colon
  • ascii59: semi-colon
  • ascii60: less than
  • ascii62: greater than
  • ascii63: question mark
  • ascii91: left bracket
  • ascii92: backslash
  • ascii93: right bracket
  • ascii94: caret
  • ascii95: underscore
  • ascii96: backtick
  • asterisk: asterisk
  • at: at
  • b: b
  • c: c
  • d: d
  • dash: dash
  • dollar: dollar
  • dot: dot
  • e: e
  • equals: equals
  • exclaimation-point: exclaimation-point
  • f: f
  • g: g
  • h: h
  • i: i
  • j: j
  • k: k
  • l: l
  • m: m
  • n: n
  • o: o
  • p: p
  • plus: plus
  • q: q
  • r: r
  • s: s
  • slash: slash
  • space: space
  • t: t
  • u: u
  • v: v
  • w: w
  • x: x
  • y: y
  • z: z
  • zed: zed

Digits

These sound files are used by the SayDigits, DateTime and SayNumber commands.
Note: All these recordings have falling intonations, as if the words were said at the end of a sentence. They may sound a little bit odd if used in the middle of a sentence.
In the digits subdirectory:
  • 0: zero
  • oh: oh (spoken in a way meaning "zero")
  • 1: one
  • 2: two
  • 3: three
  • 4: four
  • 5: five
  • 6: six
  • 7: seven
  • 8: eight
  • 9: nine
  • 10: ten
  • 11: eleven
  • 12: twelve
  • 13: thirteen
  • 14: fourteen
  • 15: fifteen
  • 16: sixteen
  • 17: seventeen
  • 18: eighteen
  • 19: nineteen
  • 20: twenty
  • 30: thirty
  • 40: forty
  • 50: fifty
  • 60: sixty
  • 70: seventy
  • 80: eighty
  • 90: ninety
  • h-1: first
  • h-2: second
  • h-3: third
  • h-4: fourth
  • h-5: fifth
  • h-6: sixth
  • h-7: seventh
  • h-8: eighth
  • h-9: ninth
  • h-10: tenth
  • h-11: eleventh
  • h-12: twelfth
  • h-13: thirteenth
  • h-14: fourteenth
  • h-15: fifteenth
  • h-16: sixteenth
  • h-17: seventeenth
  • h-18: eighteenth
  • h-19: nineteenth
  • h-20: twentieth
  • h-30: thirtieth
  • at: at
  • a-m: AM
  • p-m: PM
  • hundred: hundred
  • thousand: thousand
  • million: million
  • day-0: sunday
  • day-1: monday
  • day-2: tuesday
  • day-3: wednesday
  • day-4: thursday
  • day-5: friday
  • day-6: saturday
  • dollars: dollars
  • mon-0: January
  • mon-1: February
  • mon-2: March
  • mon-3: April
  • mon-4: May
  • mon-5: June
  • mon-6: July
  • mon-7: August
  • mon-8: September
  • mon-9: October
  • mon-10: November
  • mon-11: December
  • oclock: o'clock
  • today: today
  • tomorrow: tomorrow
  • yesterday: yesterday

Script to Age and Delete old Voicemails - vmspool_manager

Now Open Source

vmspool_manager is an Open Source program for managing your voicemail spool. Written in easy to read Perl. Tested with several versions of Asterisk. Automatically renumbers voicemail files after deleting old voicemails. Almost every option is controllable from the command line so it's easy to use as part of some automated nightly maintenance.

VMSPOOL Manager

New features (as of July 18, 2007)
  • Report mode is defualt - only says what _would_ have been done if active
  • Set the number of days from the command line
  • Option to operate on one mailbox instead of the whole queue

Get it, Install it, Run It

  • Just go to http://www.f2it.com/vmspool_manager and Download the script
  • Run it in report mode until you get the idea of what it will do
  • Finally run it for real by adding the --activate flag

Brought to you by F2 Incorporated

Please contact Judith Lebzelter at http://www.f2it.com for your comments and questions

Here is the source code: the link seems to be broken:
#!/usr/bin/perl
use strict;
# Copyright 2007 Jay Allen
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author: Jay D. Allen jay@f2it.com
# Version: 1.4 - July 2007
# 1. Delete any stale .lock* files. Stale is defined as ctime/atime more 
# a few minutes old (maybe 30 minutes to be safe)? Look into the cause of 
# these stake lock files? What versions of Asterisk are effected?
# Nasty bug! .locked mailboxes _silently_ drop voicemail recordings.
# 2. Remove voicemail files older than a policy date
# 3. Possibly a report mode that just shows the age of the mail/boxes but 
# does nothing
# Report on number of messages per box, vs quota max
# Send whiny emails to users about voicemail quota.
# 4. Renumber boxes that are missing msg0001.X - since that will prevent
# playback.
=head1 vmspool_manager.pl

This is a utility which does some checks on existing asterisk voicemail files and deletes old lock files and mail messages. This is best run on a system that is not being used due the file renumbering and deleting of files which Asterisk could be accessing at the same time.

=head1 Options
--active: Run in active mode, deleting files. Default is to 'report'
--age=<#>: Time after which a message is considered old in days. Default is 14 days.
--bad: Remove message files that do not have the expected number of files.
--context=<name>: The context for Asterisk, set to 'default' by default.
--debug: Debug mode.
--group=<name>: Name of group, default is "asterisk"
--help: Help message.
--mailbox=<#>: Run for a particular mailbox.
--spool=<path>: Set to path to mail spool. Default is "/var/spool/asterisk/voicemail"
--user=<name>: Name of user, default is "asterisk"

=head1 USAGE: To delete files over 30 days old. Also remove bad lock files.
fixup-voicemail.perl --age=30 --active

=head1 FUNCTIONS
=cut

use Getopt::Long;
use Pod::Usage;

our $DEBUG=0;
our $REPORT=1;
# Voicemail User
our $VM_USER="asterisk";
# Voicemail Groupour $VM_GROUP="asterisk";
#  Sane defaults for Trixbox
our $VM_CONTEXT="default";
our $VM_SPOOL="/var/spool/asterisk/voicemail";
# Developer's box
#our $VM_SPOOL="/home/judith/ast-runtime-1.2.14/var/spool/asterisk/voicemail";
our $MAX_AGE=14;                 # days
our $MAX_LOCK_AGE=30;            # minutes

our $VMDIR;     # This is the directory handle

our @SUFFIXES=("WAV", "gsm", "txt", "wav");
our @MAILBOX_TYPES=("Old", "INBOX");

our $ACTIVE = undef;
our $BAD = undef;
our $HELP = undef;
our $ONE_MAILBOX = undef;

my $result = GetOptions ("active"      => \$ACTIVE,
                         "age=i"       => \$MAX_AGE,      # numeric
                         "bad"         => \$BAD,          # string
                         "context=s"   => \$VM_CONTEXT,   # string
                         "debug"       => \$DEBUG,        # flag
                         "group=s"     => \$VM_GROUP,     # string
                         "help"        => \$HELP,         # flag
                         "mailbox=i"   => \$ONE_MAILBOX,  # flag
                         "spool=s"     => \$VM_SPOOL,
                         "user=s"      => \$VM_USER) or pod2usage(2); 
## Parse options and print usage if there is a syntax error,
## or if usage was explicitly requested.
pod2usage(1) if $HELP;


our $VM_SPOOL_PATH="$VM_SPOOL/$VM_CONTEXT";

if ($ACTIVE){
    $REPORT = undef;
}
#
# Here is the main script.
# Get a list of all the voicemail directorys in this context
opendir(VMDIR,$VM_SPOOL_PATH) || die "Can't open $VM_SPOOL_PATH\n";
my @mailboxes = grep { /^\d./ && -d "$VM_SPOOL_PATH/$_" } readdir(VMDIR);
if ($ONE_MAILBOX){
    if ( -d "$VM_SPOOL_PATH/$ONE_MAILBOX" ){
        @mailboxes = ( $ONE_MAILBOX );
    } else {
        die "Mailbox $VM_SPOOL_PATH/$ONE_MAILBOX does not exist\n";
    }
}

foreach my $vmbox (@mailboxes){
    foreach my $mailbox_type (@MAILBOX_TYPES){
        print "MAILBOX $vmbox/$mailbox_type\n";
        my $MAILBOX;
        my $path = "$VM_SPOOL_PATH/$vmbox/$mailbox_type";
        if(opendir($MAILBOX, $path)){
            delete_old_messages($MAILBOX, $path);
            renumber($MAILBOX, $path);
        } #  end of if has a vmbox/old
    }
}

closedir VMDIR;

=head2 delete_old_messages

Delete the Contents of the passed directory.

=cut

sub delete_old_messages{
    my $MAILBOX=shift;
    my $path=shift;
    
    if (! delete_lock_file( $MAILBOX, $path)){
        foreach my $filename (sort grep ( /^msg.*/, readdir($MAILBOX))){
            my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$path/$filename");
            if ($DEBUG and !$REPORT){ print "\tFile $size: ".localtime($mtime).": $filename\n"; }
            if( $mtime < (time()-(60*60*24*$MAX_AGE))){
                print "\tDELETE:  $size: ".localtime($mtime).": $filename\n";
                if ($ACTIVE){ unlink "$path/$filename"; }
                if ($DEBUG and !$REPORT){ "DELETE $filename\n"; }
            } else { if ($REPORT){print "\tKEEP:  $size: ".localtime($mtime).": $filename\n"} };
        }
        rewinddir($MAILBOX); 
    } else {
        if ($REPORT){print "Mailbox $MAILBOX is LOCKED\n"};
    }
}

=head2 delete_lock_file

Delete a lockfile older than 30 minutes in the passed mailbox.

=cut

sub delete_lock_file {
    my $MAILBOX=shift;
    my $path=shift;
    my $retval=0;
    foreach my $filename (sort grep ( /^\.lock*/, readdir($MAILBOX))){
        my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$path/$filename");
        $retval=1;
        if( $mtime < (time()-(60*$MAX_LOCK_AGE))){
            $retval=0;
            if ($REPORT){ print "\tDELETE LOCK:  $size:".localtime($mtime).": $filename\n";}
            else { unlink "$path/$filename";}
        }
    }
    rewinddir($MAILBOX); # Make sure we rewind!
    return $retval;
}

=head2 check_message_files

Check that there are the right number of messages using the array SUFFIXES.  Delete 'bad' messages if in active mode.

=cut

sub check_message_files{
    my $file_names=shift;    # This is an array of the filenames.
    my $path=shift;
    my %mboxindx=();
    foreach my $fixfile (@{$file_names}){
        if($fixfile =~ /^msg/){
            my ($prefix,$suffix)=split(/\./,$fixfile);
            if ($DEBUG){print "\tCheck presence:  $prefix\.$suffix\n";}
            $mboxindx{$prefix}++;
        }
    } # End of foreach $fixfile 

    foreach my $index (keys %mboxindx){
        if ($mboxindx{$index} != $#SUFFIXES + 1) { 
            print "Broken Mailbox:  $index:  $mboxindx{$index}\n" ;
#            if ((! $REPORT) and $BAD){
#                # Remove files where incomplete.
#                print "Remove files $path/$index*\n";
#                unlink <$path/$index.*>;
#            }
        }
    }
}

=head2 renumber

Asterisk needs a message with 'msg0000.XXX' in each mailbox to function.  This function will renumber the lowest number message to msg0000.XXX if one does not exist.

=cut

sub renumber {
    my $MAILBOX=shift;
    my $path = shift;
    my @OLDMAILBOX=();
    # Fixup/checkup of Old voicemail box
    @OLDMAILBOX = sort grep (/^msg.*/ , readdir($MAILBOX));
    if($#OLDMAILBOX > -1 ) {
        if ($DEBUG){ print "\tHas mail messages: " . ($#OLDMAILBOX + 1)/($#SUFFIXES + 1) . "\n";}
        if ($DEBUG){ print "\tFIRST FILE:  $OLDMAILBOX[0]\n";}
        if($OLDMAILBOX[0] !~ /msg0000.*/) {
            print "Has renumber broken msglist\n";
            rename_first_message($path, $OLDMAILBOX[0]);
        }
    }
    check_message_files(\@OLDMAILBOX, $path);
    rewinddir($MAILBOX); # Make sure we rewind!
}

=head2 rename_first_message

This function will renumber the passed message to msg0000.XXX.

=cut

sub rename_first_message {
    my $path = shift;
    my $filename = shift;
    if ($filename =~ /^msg.*/){
        my ($prefix,$suffix)=split(/\./,$filename);
        foreach my $suff (@SUFFIXES){
            print "\tRenaming files: $path/$prefix.$suff to $path/msg0000\.$suff\n";
            if ($ACTIVE){ 
                rename "$path/$prefix.$suff", "$path/msg0000\.$suff";
            } else { 
                print "\tWould rename files: $path/$prefix.$suff to $path/msg0000\.$suff\n"; 
            }
        }
    }
}

Asterisk tips callback

How to create callback voicemail

How it works:

    • Instead of calling Voicemail() directly, I set up a macro 'macro-leave_voicemail' that makes the Voicemail() call, then checks to see if you want to send a call to the user.
    • If callback is set, the macro calls a bash script that creates the call file. This script:
      • Checks the voicemail.conf file for a specially formatted comment line after the mailbox definition with the telephone numbers to call for this user.
      • Creates a call file for each of these phone numbers. Note that the call file:
        • Puts the callee into a context in extensions.conf that tells them that they have a call waiting, and allows them to press 1 to go directly to voicemail.
        • Sets a variable '${mailbox}', which is used to enter the correct voicemailbox if the user chooses to listen to the voicemail.

/var/lib/asterisk/scripts:

Usage:
voicemail_callback.sh <voicemailbox>

Requires that you add a line after each entry in voicemail.conf where you want the mailbox to get a callback, in the format
315 => 4513,Jim Doh,doh@megacorp.com,5555555555@messaging.nextel.com
callme = 5555555555,6666666666

TODO:
  1. Allow for different contexts, as the config file does.
  2. Right now, anyone with the same mailbox # will get called :-)
get_phone_numbers()
{
if [ "x$1" != "x" ];then voicemailbox="$1"; else return 1; fi
cfg_line=$(grep -A 1 "^$voicemailbox" "$VOICEMAIL_CFG")
if ( echo "$cfg_line"|grep -E 'callme\W*=\W*[[:digit:]]+'>/dev/null);then
phnum_list=$(echo "$cfg_line"|grep -E 'callme = '|cut -d'=' -f 2|sed -e 's/,/ /g')
echo "$phnum_list"
else
return 1
fi
}

make_callfile()
{
if [ "x$1" != "x" ];then mailbox="$1"; else return 1; fi
if [ "x$2" != "x" ];then phone_number="$2"; else return 1; fi
  1. note use of '-' in '-EOF1' - Escapes tab at beginning of lines
CALLFILE=$(cat <<-EOF1
Channel: Zap/g1/$phone_number
MaxRetries: 2
  1. Retry in 5 min
RetryTime: 300
WaitTime: 45

Context: feature-voicemail_callback
Extension: s
Priority: 1
SetVar: mailbox=$mailboxEOF1)echo "$CALLFILE" >> "$CALL_SPOOL_DIR"/$(date +%Y%m%d-%I%M%S)-$phone_number
}
CONSTANTS
ASTERISK_CFG="/etc/asterisk"
VOICEMAIL_CFG="$ASTERISK_CFG/voicemail.conf"
CALL_SPOOL_DIR="/var/spool/asterisk/outgoing"

  1. CALL_SPOOL_DIR=tst/
  2. VOICEMAIL_CFG="./asterisk/voicemail.conf
  3. *********MAIN*******************************************************

if [ "x$1" != "x" ];then voicemailbox="$1"; else exit 1; fi

if ph_numbers=$(get_phone_numbers $voicemailbox) ;then
for ph_num in $ph_numbers; do
make_callfile "$voicemailbox" "$ph_num"
done
fi


extensions.conf:

  • A macro that is used to call app_voicemail, and which calls the bash script to initiate the call out.

[macro-leave_voicemail]
  ; Leave a voicemail message, then do post-processing.
  ;   o Call configured phones, with an announcement that a message
  ;      is waiting, and the option to listen to the voicemail(s)
  ;        ${ARG1} = u or b for 'unavailable' or 'busy' message
  ;        ${ARG2} = mailbox
  ;      ${ARG3} = Call user flag
  ; USAGE:
  ;     exten => s,15,Macro(leave_voicemail,u,310,1)

  exten => s,1,ResponseTimeout(30)
  exten => s,2,Voicemail2(${ARG1}${ARG2})
  exten => s,3,GoToIf($[${ARG3} = 0]?s|5)
  exten => s,4,system(${SCRIPTS_DIR}/voicemail_callback.sh ${ARG2})
  exten => s,5,NoOp

  exten => h,1,GoToIf($[${ARG3} = 0]?h|3)
  exten => h,2,system(${SCRIPTS_DIR}/voicemail_callback.sh ${ARG2})
  exten => h,3,NoOp
  exten => t,1,GoToIf($[${ARG3} = 0]?t|3)
  exten => t,2,system(${SCRIPTS_DIR}/voicemail_callback.sh ${ARG2})
exten => t,3,NoOp

  • Note that the h and t extensions may not be necessary... I used them for troubleshooting problems with call progress detection on FXO cards (More on that later... Down in 'Please Note!')
and...
  • The context that is connected to by the call file:

[feature-voicemail_callback]
exten => s,1,ResponseTimeout(2)
exten => s,2,Background(vm_callback-announcement)
exten => s,3,Background(vm_callback-options)
exten => t,1,Goto(s|2)
exten => 1,1,VoicemailMain2(s${mailbox})

  • Finally, the sound file contents:

vm_callback-announcement: "You have new voicemail"
vm_callback-options: "To listen to this voicemail, press 1"

Asterisk voicemail database

Database support in voicemail

NOTE: This is the old way of configuring voicemail users via a database, and will soon be obsoleted by the new asterisk realtime architecture (ARA) - see Asterisk RealTime. As of cvs stable release 1.0.7, realtime configuration is not available, it is currently only found in CVS-Head. This does not store the voicemail files, only the voicemail configuration. See also Asterisk Voicemail ODBC storage

The Asterisk voicemail system, comedian mail, supports configuration of mailboxes in a database. Voicemail supports both Postgres and MySQL databases. Work is going on to make it support UnixODBC.

This means:
  • All voicemail user configurations will be read dynamically from database
  • Users can change their voicemail passwords from inside voicemail or using a simple web-based UI

1. Download

Note that the MySQL support has been moved to asterisk-addons due to MySQL changing the licensing of their libraries to full GPL.

cd /usr/src
export CVSROOT=:pserver:anoncvs@cvs.digium.com:/usr/cvsroot
cvs login - the password is anoncvs.
cvs checkout asterisk-addons

2. Compile

cp asterisk-addons/mysql-vm-routines.h asterisk-0.7.2/apps
cd asterisk-0.7.2
vi apps/Makefile +14
USE_MYSQL_VM_INTERFACE=1
make clean
make
make install

3. Configure in voicemail.conf

for mysql use:
In the [general] section in voicemail.conf specify

dbuser=username
dbpass=password
dbhost=localhost
dbname=asterisk_vm

for postgresql use:
in [general]:

dboption=dbname=asterisk user=USERNAME password=PASSWORD

4. Configure database

Create a database (e.g. 'asterisk_vm') & a user which can access it (needs to have write access for password changes from inside VM).

For mysql table has to be called 'users' (hardcoded in .h file)

CREATE TABLE users (
context char(79) DEFAULT '' NOT NULL,
mailbox char(79) DEFAULT '' NOT NULL,
password char(79) DEFAULT '' NOT NULL,
fullname char(79) DEFAULT '' NOT NULL,
email char(79) DEFAULT '' NOT NULL,
pager char(79) DEFAULT '' NOT NULL,
options char(159) DEFAULT '' NOT NULL,
stamp timestamp,
PRIMARY KEY (context,mailbox)
);

For postgres table has to be called 'voicemail'

CREATE TABLE voicemail (
context varchar(79) DEFAULT '' NOT NULL,
mailbox varchar(79) DEFAULT '' NOT NULL,
password varchar(79) DEFAULT '' NOT NULL,
fullname varchar(79) DEFAULT '' NOT NULL,
email varchar(79) DEFAULT '' NOT NULL,
pager varchar(79) DEFAULT '' NOT NULL,
options varchar(159) DEFAULT '' NOT NULL,
stamp timestamp,
PRIMARY KEY (context,mailbox)
);

Note that context refers to the Mailbox context, not extension context)
Note that the password is stored in plain text

Asterisk Voicemail ODBC Storage

ver: CVS HEAD >= 08-24-05 | Asterisk 1.2

Requirements

unixODBC (app and dev required) - Check your local RPM provider or http://www.unixodbc.org/

Setup

Asterisk 1.4
1) Run "make menuselect"
2) Go down to "Voicemail Build Options"
3) Select ODBC_STORAGE. Note that if there is an "XXX" next to this option, then the necessary dependencies are not installed. Be sure that you have unixodbc-dev as well as libtool installed.
4) Hit 'x' to save an exit.

Asterisk 1.2
You have to edit the Makefile in /apps adding:
CFLAGS+=-DEXTENDED_ODBC_STORAGE
CFLAGS+=-DUSE_ODBC_STORAGE


Or you can unrem (remove the #) the existing lines that already say those two lines. (Yes, you need both lines.)

If you've already compiled asterisk, you must recompile (make clean;make;make install).

Voicemail.conf

Uncomment or add these lines to voicemail.conf.
  • odbcstorage should match the section name in res_odbc.conf
  • odbctable should be the name of the table you're storing messages in.
odbcstorage=asterisk
odbctable=voicemessages

Database format

MySQL

CREATE TABLE `bit_voicemessages` (
`id` int(11) NOT NULL auto_increment,
`msgnum` int(11) NOT NULL default '0',
`dir` varchar(80) default '',
`context` varchar(80) default '',
`macrocontext` varchar(80) default '',
`callerid` varchar(40) default '',
`origtime` varchar(40) default '',
`duration` varchar(20) default '',
`mailboxuser` varchar(80) default '',
`mailboxcontext` varchar(80) default '',
`recording` longblob,
`flag` varchar(128) default '',
PRIMARY KEY (`id`),
KEY `dir` (`dir`)
) ENGINE=InnoDB;

Asterisk 1.6.1

requires a new column "flag" added above.

DB2

CREATE TABLE voicemessages (
id bigint generated always as identity NOT NULL,
dbdate timestamp not null default current timestamp,
dir varchar(80) default '',
msgnum bigint NOT NULL default 0,
context varchar(80) default '',
macrocontext varchar(80) default '',
callerid varchar(40) default '',
origtime varchar(40) default '',
duration varchar(20) default '',
mailboxuser varchar(80) default '',
mailboxcontext varchar(80) default '',
recording blob,
PRIMARY KEY (id)
);

create index idx_voicemsgs on voicemessages(dir,msgnum);

README.odbcstorage


ODBC Voicemail Storage
======================

ODBC Storage allows you to store voicemail messages within a database
instead of using a file. This is *not* a full realtime engine and
  • only* supports ODBC. The table description for the "voicemessages"
table is as follows:

+-------------------------------------------+-------+| Field | Type | Null | Key | Default | Extra |
+-------------------------------------------+-------+| msgnum | int(11) | YES | | NULL | |
| dir | varchar(80) | YES | MUL | NULL | |
| context | varchar(80) | YES | | NULL | |
| macrocontext | varchar(80) | YES | | NULL | |
| callerid | varchar(40) | YES | | NULL | |
| origtime | varchar(40) | YES | | NULL | |
| duration | varchar(20) | YES | | NULL | |
| recording | longblob | YES | | NULL | |
+-------------------------------------------+-------+
The database name (from /etc/asterisk/res_odbc.conf) is in the
"odbcstorage" variable in the general section.

Other considerations

When using ODBC for storage, app_voicemail reads the busy and unavail messages from the database and deletes any it finds on the local voicemail spool path. If there is no message held in the database and there is one locally, app_voicemail will play the local version and then delete it. Further calls will just play the standard Alison "I'm sorry, but the extension........" message.

If you've already started using ODBC and don't want to run the conversion script, below, then assuming you're using MySQL, you can manually insert the WAV files into the database with the following SQL:
INSERT INTO voicemail (msgnum,dir,mailboxuser,mailboxcontext,recording) VALUES (-1,'/var/spool/asterisk/voicemail/CONTEXT/USER/busy','CONTEXT','USER',LOAD_FILE('/var/spool/asterisk/voicemail/CONTEXT/USER/busy.WAV'));
INSERT INTO voicemail (msgnum,dir,mailboxuser,mailboxcontext,recording) VALUES (-1,'/var/spool/asterisk/voicemail/CONTEXT/USER/unavail','CONTEXT','USER',LOAD_FILE('/var/spool/asterisk/voicemail/CONTEXT/USER/unavail.WAV'));

Where 'CONTEXT' and 'USER' are the context and username to be used and the paths shown are to be amended as appropriate. Make sure you load the .WAV file and not the .wav or .gsm or it won't work! <-- is that true? I couldnt get .WAV to work. But when I used a 16bit 8000Hz file with a .wav extension, it worked fine.


When connecting to MS SQL Server you may need to adjust the option "textsize" to a larger value than provided in the default freetds.conf file. With the default provided value my voicemail playback was being cut short, with the adjusted value of:
/etc/freetds.conf
textsize = 20971520

that fixed the issue.

Notes:

  • I had a problem initially with connecting, it was an unixODBC problem so make sure you've got that configured correctly. - Flobi
  • I tried adding ODBC message storage to a 1.2.5 system already using MySQL for RealTime... Not a good idea, but using ODBC for both Realtime and msg storage seems good so far. -X1Z
  • PHP script to convert to ODBC voicemail storage

VoiceMail eXtreme


Welcome to VMX.
VMX is an VoiceMail application written specifically for Asterisk Realtime.
At this moment only basic functionality is written, I welcome any help you can offer.
You can reach me by email on boerg@gertjandeboer.nl
For more information about me surf to www.gertjandeboer.nl (in Dutch)

Project Information:

VoiceMail eXtreme is a voicemail application intended for use with Asterisk PBX. VoiceMail eXtreme uses the Asterisk Realtime extension. This means that all Asterisk data is stored in a MySQL database. This database is then used by VoiceMail eXtreme to read and authenticate user data. VoiceMail is stored by Asterisk in the /var/spool/asterisk/voicemail directory. All data about a VoiceMail is stored in a .txt file in ini format by Asterisk. VoiceMail eXtreme is completely modular and scalable. All operations are done by php functions and every setting is declared in conf.inc.php.
At this moment version 0.1 is released.

Asterisk tips voicemail live

Voicemail Live

Answering machine mimic: Listen while caller is leaving voicemail for you; with pick-up option
Posted by Philipp von Klitzing in Dec. 2005, updated in Apr. 2010

Idea

You'd like to have the PBX voicemail act just like your answering machine at home? It can be done!
First of all you'd probably want to listen in on the new call while the caller dictates her message to the system. Then, if you wish, press # to stop the recording and connect to the caller. All this is most useful if your phone comes with auto-answer/intercom support and a decent speaker.

Concept

  • ideally you have a multi-line speaker phone that allows to configure one of the lines for auto-answer/intercom (SNOM or the like); the speaker phone (listener) is muted in that conference
  • place caller, voicemail and speaker phone into a first dynamic MeetMe conference with the help of AGI-generated .call files
  • dissolve that first MeetMe upon a # key press by the callee on the speaker phone
  • now engage in a second dynamic MeetMe to begin a two-way conversation; we allow for a maximum of two simultaneous instances of this second MeetMe

Potential enhancements

Note: For testing purposes the freely available (for private use) SNOM softphone proved to be a useful tool
  1. Use app_bridge (or ChannelRedirect ?) instead of 2nd MeetMe for duplex talking
  2. Consider ChanSpy instead of the 1st MeetMe (for listening in)
  3. Instead of jumping into a new MeetMe room we could stay inside and instead unmute ourselves (get out, unmute, get in again); possibly the voicemail recording leg can be hung up using "soft hangup", but we will first have to obtain the channel name, or we kick only that specific user from the conference (but: how to correctly determine that user?) - Workaround: Use option 'N' of MeetMeAdmin to at least silence the Voicemail application.
  4. Insert an astdb (DBGet/Put) switch for "Voicemail Live" on/off
  5. Use 'dE' instead of just 'd' to create a free dynamic conference and then do away with MeetMeCount
  6. Find out why we sometimes get the VM prompts rather late?! Possible cause is CPU load, should be low (check with 'top')
  7. Dedicate a SNOM button of type "DTMF" to issue the # and label it "voicemail pick-up"
  8. Use the SNOM "URL Action" for Off-Hook to talk to the vm caller by simply lifting the handset (no need to press #)
  9. Rewrite the dialplan part without priority jumping
  10. Play the VM intro to the caller _before_ entering the MeetMe room so that the listener (=VM box owner) does not always have to listen to it
  11. Fix me: If the caller hangs up before having entered MeetMe, then the listener and voicemail will remain in MeetMe until time out . Cause: the x option of MeetMe first of all needs the marked user to enter before it gets a chance to close the conference. Solutions:
    1. use ChanSpy instead of MeetMe (but then owner can't exit by pressing #), or
    2. let a 4th fake & marked user (option A) quickly enter and leave the MeetMe room after caller hangup (this caller's presence must then overlap with the entry of the caller into MeetMe; we would need to stay below vm config for minimum message duration), or
    3. FIXED: Set a channel variable as flag, and then use the h extension to call MeetMeAdmin on hangup and kick those that remain in MeetMe (downsides: a channel variable is probably already destroyed when we reach the h extension, but maybe we can address this with a global variable? Also employing the h extension might mess up our CDRs a little, and this h extension will be called by any closing call, not just our VM calls). This is the best way to go, probably with passing arguments to the AGI scripts on the command line (see 'ORIGVAL' below)
  12. consider to introduce the 'w' flag for the listener and set up special music-on-hold that plays pick-up instructions for the owner/listener
  13. check if $agi["callerid"] gives us trouble when a Caller ID Name is present and we thus have a space in the filename - we should better use the unique ID of the call to determine the file name for the .call files!

extensions.conf

Note: You'll most probably need priorityjumping=yes in the [general] section if you are using Asterik v1.2.x. If you don't like that then you'll need to rework the parts where jumpts to n+101 are performed, e.g. look for Dial() and ChanIsAvail()

AGI scripts (PHP)

Place these AGI scripts into /var/lib/asterisk/agi-bin/ and make them executable ('chmod u+x macro-vm-*.agi').
Note: On Debian you will need to have 'php-cli' installed for this. Of course next to any other language can do the job as well, you are not bound to PHP.

macro-vm-listen.agi


#!/usr/bin/php -q
  <?php

  ob_implicit_flush(true);
  set_time_limit(5);
  $in = fopen("php://stdin","r");

  // toggle debugging output (more verbose)
  $debug = false;
  //$debug = true;
 
 function __read__() {
   global $in, $debug;
   $input = str_replace("\n", "", fgets($in, 4096));
   if ($debug) echo "VERBOSE \"read: $input\"\n";
   return $input;
 }

 function __write__($line) {
    global $debug;
    if ($debug) echo "VERBOSE \"write: $line\"\n";
    print $line."\n";
 }

 //read the standard agi variables
 while (!feof($in)) {
        $temp = str_replace("\n","",fgets($in,4096));
        $s = split(":",$temp);
        $agi[str_replace("agi_","",$s[0])] = trim($s[1]);
        if (($temp == "") || ($temp == "\n")) {
                break;
        }
 }

  //get the variable 'ORIGVAL' that was passed as command line argument to this script
  $origval = $argv[1];

  //get the variables and strip off all the extra stuff around
  __write__~/np~("GET VARIABLE TARGET");
  $res = substr(strrchr(~np~__read__(),"("),1,-1);
  __write__~/np~("GET VARIABLE ARG2");
  $arg2 = substr(strrchr(~np~__read__(),"("),1,-1);

  $cf = fopen("/tmp/cb".$agi["callerid"],"w+");
  fputs($cf,"Channel: Local/listen@vm-meet-listener/n\n");
  fputs($cf,"Set: _ORIGCIDNAME=".$agi["calleridname"]."\n");
  fputs($cf,"Set: _ORIGCIDNUM=".$agi["callerid"]."\n");
  fputs($cf,"Set: CALLERID(name)=".$agi["calleridname"]."\n");
  fputs($cf,"Set: CALLERID(number)=".$agi["callerid"]."\n");
  fputs($cf,"Set: _TARGET=".$res."\n");
  fputs($cf,"Set: _ROOMNO=".$arg2."\n");
  fputs($cf,"Set: _ORIGVAL=".$origval."\n");
  fputs($cf,"MaxRetries: 0\n");
  fputs($cf,"RetryTime: 10\n");
  // --- We are the first so we create the dynamic conference ---
  fputs($cf,"Context: vm-meet-join\n");
  fputs($cf,"Extension: join\n");
  fputs($cf,"Priority: 1\n");

  //Now move (!) the file to the outgoing dir AFTER we closed it
  fclose($cf);
  exec("mv /tmp/cb".$agi["callerid"]." /var/spool/asterisk/outgoing");

  fclose($in);
  ?>

macro-vm-record.agi

  1. !/usr/bin/php -q
<?php

ob_implicit_flush(true);
set_time_limit(5);
$in = fopen("php://stdin","r");

// toggle debugging output (more verbose)
$debug = false;
//$debug = true;

function __read__() {
global $in, $debug;
$input = str_replace("\n", "", fgets($in, 4096));
if ($debug) echo "VERBOSE \"read: $input\"\n";
return $input;
}

function __write__($line) {
global $debug;
if ($debug) echo "VERBOSE \"write: $line\"\n";
print $line."\n";
}

//read the standard agi variables
while (!feof($in)) {
$temp = str_replace("\n","",fgets($in,4096));
$s = split(":",$temp);
$agi[str_replace("agi_","",$s[0])] = trim($s[1]);
if (($temp == "") || ($temp == "\n")) {
break;
}
}

//get the variable 'ORIGVAL' that was passed as command line argument to this script
$origval = $argv[1];

//get the variables and strip off all the extra stuff around
__write__("GET VARIABLE ARG2");
$arg2 = substr(strrchr(__read__(),"("),1,-1);
__write__("GET VARIABLE ARG3");
$arg3 = substr(strrchr(__read__(),"("),1,-1);

$cf = fopen("/tmp/cb2_".$agi["callerid"],"w+");
fputs($cf,"Channel: Local/8600".$arg3."@default/n\n");
fputs($cf,"Set: CALLERID(name)=".$agi["calleridname"]."\n");
fputs($cf,"Set: CALLERID(number)=".$agi["callerid"]."\n");
fputs($cf,"Set: _ORIGCIDNAME=".$agi["calleridname"]."\n");
fputs($cf,"Set: _ORIGCIDNUM=".$agi["callerid"]."\n");
fputs($cf,"Set: _ORIGVAL=".$origval."\n")
fputs($cf,"MaxRetries: 0\n");
fputs($cf,"RetryTime: 10\n");
fputs($cf,"Application: MeetMe\n");
fputs($cf,"Data: 99".$arg2."|dpqx\n");

//Now move (!) the file to the outgoing dir AFTER we closed it
fclose($cf);
exec("mv /tmp/cb2_".$agi["callerid"]." /var/spool/asterisk/outgoing/");

fclose($in);
?>

asterisk voicemail 


I archive messages that haven't been touched in <x> number
days and send the compilation of messages being archived to the
voicemailbox's owner. You could modify to delete them and leave it at that.
Since I'm leaving newer messages in the directory, and Asterisk doesn't like
nonsequential filenames - I renumber all the remaining files.

I also had an issue with abandoned voicemail - where the caller would hangup
at the exact right moment leaving a zero length message. The .txt file
would be created but none of the audio formats. It was a rare occurrence -
but the user was unable to fix it from the phone interface meaning I had to
manually correct it every time, so I automated it with a script and a
cronjob.

Setting up shared voicemail on Asterisk 


It’s a requirement that people often seem to ask for - a single voicemail box, taking messages for a department, that can be easily monitored and accessed by several different users. A typical application would be to record out-of-hours messages which are then checked in the morning by any of a number of users, perhaps just depending who arrives first at the office.
While it is fairly easy to configure Asterisk or Trixbox to record the messages, it is less clear how to configure an indicator lamp to show messages are waiting on several IP extension phones. Oh yes, and of course we will want the programmable key to also work as a single-press access for retrieving messages from the voicemail box.
In part 1 of this 2-part article I describe how to create a shared mailbox, send your out-of-hours calls to it, configure a custom device state to control a programmable key’s lamp on an arbitrary number of IP phones and insert code into the dialplan to allow the BLF key to talk to Asterisk. In part 2, I explain how to switch the status of that custom device state to reflect whether there are any messages in a specific voicemail box.

Creating the shared voicemail box

In Trixbox or FreePBX

Just add a new dummy extension and make sure the Voicemail status is enabled. If you select “Generic SIP Device” when creating the extension, then be sure to assign an unused extension number to it and – very important – an obscure, unguessable string for the SIP password (shown as “secret” in the “Device Options” section). For example, use 8 randomly chosen characters and digits for “secret”. No one will ever need to use the SIP password, but if you use a weak one like 123 then it may render your Asterisk system vulnerable to hacking.
The voicemail password is different – it is located in the “Voicemail & Directory” section and should be set to something that all your users can remember while not being so obvious that anyone could guess it. For the examples shown here, I created a SIP extension 4444, set the Display Name to “Dept Voicemail” and in the Device Options section I kept the default setting for mailbox as “4444@default”. The voicemail password was set to 1471. Email notification is optional and is activated simply by inserting an address in “Email Address”.

In raw Asterisk

Edit the file /etc/asterisk/voicemail.conf and scroll down until you see the [default] section. In this section, add a definition for your departmental mailbox. The format for adding new voicemail boxes (as explained in the comments in the sample file) is as follows:
<mailbox>=<password>,<name>,<email>,<pager_email>,<options>
My examples use the following voicemail box definition (the email address and attach option are optional and control delivery of message alerts by email):

4444 => 1471,Dept Voicemail,group@mymaildomain.com,,attach=yes

Sending out-of-hours callers to the shared voicemail box

In Trixbox or FreePBX, it is simply a case of setting the destination for your inbound calls to Voicemail: <4444> Dept Voicemail. If you want to use a timer to send your inbound calls to this shared voicemail box, then take a look at the modules called Time Groups and Time Conditions. Time Groups defines the hours, days, etc and Time Conditions controls the routing of calls to different destinations at times defined in the selected Time Group.
If you are using raw Asterisk, you will need to edit the file /etc/asterisk/extensions.conf and find the appropriate context where inbound calls are handled. To send a call to the shared voicemail box, add a line like this:

exten => _X.,n,Voicemail(4444,u)

The option u, shown above, tells Asterisk to play the “unavailable announcement” to the caller, followed by instructions. For the complete list of announcement options go to
http://www.voip-info.org/wiki/view/Asterisk+cmd+VoiceMail
If you want to use timers to only route the call to this voicemail at certain times of day then check for details at http://www.voip-info.org/wiki/view/Asterisk+cmd+GotoIfTime

About custom device states

If you have not already done so, I now recommend that you read my earlier article about Asterisk’s custom device states. In it, I explain how you can check if your version of Asterisk supports custom device states and I also explain how a device state can be set from the dial plan and how it can be linked to a programmable BLF key using Asterisk hints. Click here to go to that article.

Setting up a custom device state and linking it to a hint

We are going to use a custom device state called groupmwi to show when there are messages waiting in the shared mailbox 4444. The phone’s BLF key tells Asterisk that it is interested in the state of a device by sending a subscribe request – Asterisk knows which device it is interested in because the BLF key also sends an ID string, usually numeric, to specify what it wants to subscribe to. Asterisk hints map these ID strings to objects that it knows about.
To proceed, we must first choose the ID string that will be mapped to our custom device state, groupmwi. The shared mailbox in my examples is 4444. The default feature code to access a voicemail box is *97. The ID string actually does two jobs – it links the BLF lamp to the custom device state, but it is also used to retrieve messages from the box when the BLF key is pressed. I therefore chose to set the ID string to 974444. So my hint looks like this:

exten => 974444,hint,Custom:groupmwi

As well as defining the hint, I will also include dialplan entries that allow access to the stored messages when the BLF key is pressed, because they go in the same section as the hint. So the code we need to add looks like this:

; Retrieve messages from the group message box by dialling 974444
exten => 974444,1,Answer
exten => 974444,2,VoicemailMain(4444@default)
; Add hint to link to the Custom Device State
exten => 974444,hint,Custom:groupmwi

Ok so far? – I hope. But where does this code need to be added? The answer depends if you are using Trixbox/FreePBX or raw asterisk:
For FreePBX based systems, you must edit the file /etc/asterisk/extensions_custom.conf and add the lines to the end of the file in a new context section called [ext-local-custom]:
For raw Asterisk, edit the file /etc/asterisk/extensions.conf and add the lines to the end of the default context (or whichever context you use for calls from extensions):

Setting up the BLF programmable key on the IP phone

On your IP phone, configure one of the programmable keys to be of type BLF and set the number (or value) field to 974444. This is all explained in more detail in the companion article mentioned earlier.

Changing the Custom Device State when voicemail arrives

All that remains now is to make the custom device state change to INUSE when there are messages waiting and NOT_INUSE when there are no messages. This is achieved by:
  1. Configuring the Asterisk voicemail option externnotify to call a bash script whenever the number of messages changes in a voicemail box 
  2. Writing that bash script – its job is to check the input parameters sent from Asterisk and run an appropriate portion of dialplan code 
  3. Writing two special context sections in the dialplan which change the custom device state to INUSE or NOT_INUSE. These are used by the bash script. 

Asterisk cmd VoiceMailMain2

Synopsis:

Enter voicemail system

Description:

VoiceMailMain2()

Enters the main voicemail system for the checking of voicemail. The mailbox can be passed as the option, which will stop the voicemail system from prompting the user for the mailbox. If the mailbox is preceded by 's' then the password check will be skipped.

Return codes

Returns -1 if the user hangs up or 0 otherwise.

Asterisk cmd VoiceMail2

Synopsis:

Leave a voicemail message

Description:

VoiceMail([flags]extension[@context])

Leaves voicemail for a given extension (must be configured in voicemail.conf ).
If the extension is preceeded by one of the following flags:
  • s: instructions for leaving the message will be skipped.
  • u: the "unavailable" message will be played (that is, /var/lib/asterisk/sounds/vm/<exten>/unavail) if it exists.
  • b: the the busy message will be played (that is, busy instead of unavail)

Return codes:

Returns -1 on error or mailbox not found, or if the user hangs up. Otherwise, it returns 0.

Example:

exten => 100,1,VoiceMail(u100@myContext)

No comments:

Easy Way to Handle Android Notifications

Android Notifications Android Toast class provides a handy way to show users alerts but problem is that these alerts are not persist...