Alternative method for Automated announcements

Feb 22, 2008
Reaction score
I really like Ward's automated announcements system, but there are a few things that didn't fit perfectly with the way I wanted to use it. Perhaps I can help put these features in a future release, but until then, I wanted to share this with anyone interested.

I set up some automated announcements to help get my kids out of bed every day for school, and keep them on task so they could get to school on time. I wanted the announcements to go out on a paging group rather than to a single extension, and therefore confirming the message isn't an option. I also wanted to be able to parameterize the file names, since I have quite a few. With this system, you create recordings with names like announcement-0815 which will play at 8:15 am.

The call files are generated by a cron job every night, and the modification times set accordingly. I also built some call files to "page" my cell phone much like the reminder system, but I won't include it here because it would be redundant.

The instructions below are provided As-Is with absolutely no warranty, and all the usual disclaimers. If you destroy your system, I can't help you. That being said...

This setup assumes you have a sound card compatible with pbxinaflash, though you can just send announcements through your speakerphones, if desired.

First, switch user accounts so you're operating as the asterisk user by typing su – asterisk <enter> (there is a hyphen in between su and asterisk, which tells the system you want the environment loaded when you switch to the asterisk user).
Edit the modules.conf file by typing nano -w /etc/asterisk/modules.conf <enter>, which will open a text editor. Use the keyboard arrow keys to change this line near the bottom of the file from:
noload =>
load =>
Type <control> x to exit, type y to save the file, and press <enter> to confirm the save.
Now create a new oss configuration file by typing nano -w /etc/asterisk/oss.conf <enter> to start the editor. The file will be empty, type in the following exactly:

Again, type <control> x to exit, y to save the file, and <enter> to confirm the save.
Now edit your extensions_custom.conf by typing nano -w /etc/asterisk/extensions_custom.conf <enter> and then scroll down until you find the [from-internal-custom] section, and insert the following lines at the beginning of the section (right after [from-internal-custom]) (pick a different extension if 199 isn't available on your system):
exten => 199,1,Dial(console/dsp,20,A(beep))
exten => 199,2,Hangup()
Now go to the very bottom of the file and add the following:
exten => _X.,1,Answer
exten => _X.,n,Wait(3)
exten => _X.,n,Playback(beep)
exten => _X.,n,Playback(custom/announcement-${EXTEN})
exten => _X.,n,Wait(1)
exten => _X.,n,Hangup
And as before, save the file and exit the text editor. Once you are back at the [[email protected]:~] prompt, type exit <enter> to return to the [email protected]:~ prompt. Type asterisk -rx 'restart when convenient' <enter>, which will reload the Asterisk dialplan and the configuration changes we made.
Now it's time to upload the announcement sound files. Record the announcement audio on any computer on the same network with a microphone and save each of them as a .wav file, saved PCM Encoded, 16 bits, at 8000 Hz sample rate. Use a web browser on this computer to connect to the new paging server by typing http://<ip-address-of-server>/admin into the location bar of the browser.
When the page opens, select the link on the left hand side for “System Recordings.” From this page you can upload the announcement sound files. Browse to the sound file, then click “Upload.” After the upload completes, the page will reload. Now enter a name for the recording in the “Name this recording” box. Name each file with a unique name, and use names with no spaces (substitute hypens or underscores, and save all names in lowercase letters for simplicity). I encode the time of day in the name of the announcement to make it easier to change later.
For example, I'll upload announcement-0800.wav to my server for an 8:00 am announcement. Click the “Save” button after uploading each recording, and it will be added to the list on the right side of the window. Note that the file naming convention must match what we put in the extensions_custom.conf above.
The final step is to build cron jobs to generate call files on the server. A call file is saved in the /var/spool/asterisk/outgoing folder, and automatically creates a phone call event at the date and time (modification date and time) of the call file itself. We use the touch command to change the modification dates into the future for each call file, as it's generated. Asterisk places the calls (and plays the announcements) at the right time. The cron job runs once a day, just after midnight, and generates all the call files for the day. You can do this differently, if desired, and you could have a cron job just create a single call file at the time it's needed. If you do so, remember that the call file must be created elsewhere, then moved into the “outgoing” folder, rather than created in place. Otherwise the file may not be complete when Asterisk tries to access it.
Switch back to the asterisk user account by typing su – asterisk <enter> to get to the [[email protected]:~] prompt. Create a folder for the cron jobs by typing mkdir cron.daily<enter> and change to the directory with cd cron.daily<enter>. Create the script by typing nano -w<enter> and copy and paste the following, substituting the file names and times as appropriate for your announcements.
makecallfile ()
cat <<EOF > /var/lib/asterisk/tempcallfile
Channel: Local/[email protected]
MaxRetries: 3
RetryTime: 60
waittime: 60
callerid: "AutoNag" <5551234>
Context: custom-announcement
Extension: $1
Priority: 1
touch -t `date +%Y%m%d$1.17` /var/lib/asterisk/tempcallfile
mv /var/lib/asterisk/tempcallfile /var/spool/asterisk/outgoing/announce$
makecallfile "0800"
makecallfile "0805"
makecallfile "0810"
#and so on...
Save the file with the usual <control>x then y <enter>.
Make this script executable by typing chmod +x<enter>.
Set up the cron job to run by typing env EDITOR='nano -w' crontab -e <enter> and add the following line to the file for weekday-only announcements (the 1-5 in the syntax is for Monday through Friday, change it to * for 7-day-a-week announcements). This will run at 4 minutes past midnight.
4 0 * * 1-5 run-parts /var/lib/asterisk/cron.daily >/dev/null 2>&1
As always, <control>x, y, <enter> will save the file. This concludes the setup of the system. You can test individual announcements by creating a text file with the following (substituting the announcement file name as appropriate, then copying the file to the /var/spool/asterisk/outgoing folder.
Channel: Local/[email protected]
MaxRetries: 3
RetryTime: 60
waittime: 60
callerid: "AutoNag" <5551212>
Context: custom-announcement
Extension: 0800
Priority: 1
The modification time will be in the past, so Asterisk should make the announcement immediately. If it doesn't work, examine the /var/log/asterisk/full logfile for clues to the problem. Perhaps the file names aren't correct, or there is a typo in one of the files you modified.


Oct 26, 2008
Reaction score
Atlanta, GA
I can't get this to work. I put the files in place (uploaded them), and followed the instructions exactly. I tried the last method of putting a file in /var/spool/asterisk/outgoing and it does something because the file is gone in 15 seconds. For some reason, I can't get to /var/log/asterisk/full - permission denied...
Any solution?

Oh, sorry for resurrecting an old thread!

Members online

PIAF 5 - Powered by 3CX

Forum statistics

Latest member