Try it out! Call: 1-219-933-9000 (NWI Time & Temperature line)
This FreePBX dialplan module plays dynamic time, date, and weather temperature to callers using custom audio files. It supports personalized greetings, robust number parsing, and seamless temperature integration via a shell script that fetches live data.
- Accurate playback of current time and date
- Personalized "Good morning / afternoon / evening" greetings
- Temperature fetched from Open-Meteo API and played as whole number
- If actual temperature is different from the "feels like" temperature, play "but it feels like X degrees"
- Support for negative temperatures (e.g. “minus 5 degrees”)
- Modular number pronunciation using
custom-play-number - Graceful fallback logic and caching if temperature is unavailable
Defined under from-internal-custom, this extension parses and plays:
- The current time:
custom/the-time-is, followed by hour and minute using custom audio (custom/1,custom/5,custom/20, etc.) - The current date and day:
custom/today-is, day/month/date parsed as audio - Temperature: fetched live, sanitized to whole number, parsed and played
The number playback logic intelligently handles:
- Single digits
- Teen numbers (10–19)
- Compound tens (e.g. 73
custom/70,custom/3) - Hundreds (e.g. 103
custom/100,custom/3)
Located at /usr/local/bin/get_temp.sh, this Bash script:
- Queries Open-Meteo with predefined
LAT/LONvalues - Rounds float temperature to whole number
- Strips newline characters from output
- Logs readings and fallbacks to
/var/lib/asterisk/temp_script.log - Caches last known good value to
/var/lib/asterisk/last_known_temp
Sample Output:
73or-5(cleaned before passing to dialplan)
- All
Playback()calls are immune to DTMF input — no caller breakouts - No
Background()orWaitExten()used - One-second
Wait(1)before hangup to avoid call clipping - Caller routed to
*987internally via static mapping (<your DID here>) - Invalid numeric values route to
custom/error(optional audio fallback)
| File / Context | Purpose |
|---|---|
extensions_custom.conf |
Dialplan logic |
/usr/local/bin/get_temp.sh |
Temperature fetch script |
/var/lib/asterisk/temp_script.log |
Temperature script logging |
/var/lib/asterisk/last_known_temp |
Cache fallback for weather |
/var/lib/asterisk/sounds/custom/ |
Custom audio files (*.slin) |
- FreePBX, asterisk or similar with custom dialplan capability
- Bash shell &
curlandjqfor weather parsing custom/audio files matching digits and phrases (e.g.custom/70.slin)- Executable permissions and ownership for temp script:
chmod +x /usr/local/bin/get_temp.sh chown asterisk:asterisk /usr/local/bin/get_temp.sh
These instructions walk you through installing and configuring the Time & Temperature playback system in FreePBX/Asterisk from the main system terminal.
- A working FreePBX server with terminal access
- Basic knowledge of Linux command line - Or google/copilot help
- Audio files for number playback placed in
/var/lib/asterisk/sounds/custom/(slin format, .wav will work but with a slight delay in playback because they get converted on the fly)
This assumes you have installed FreePBX and setup your SIP trunks, (google for that or get free config samples from your sip provider)
From your local machine or audio workstation, use scp to copy your .wav or .slin files to the server:
Either drag and drop to /var/lib/asterisk/sounds/custom/ using the windows version of SCP or:
scp /local/path/to/audio/*.slin youruser@yourserver:/var/lib/asterisk/sounds/custom/Make sure the files are all located in the custom/ directory, and not in a sub directory.

After uploading, from the command prompt on the FreePBX server, set ownership:
chown asterisk:asterisk /var/lib/asterisk/sounds/custom/*.slin🔧 Tip: For best performance, convert
.wavfiles to.slinor.ulaw.
From your local system, upload the script to the server either by drag and drop /usr/local/bin/ or:
scp get_temp.sh youruser@yourserver:/usr/local/bin/Then from the FreePBX terminal, make it executable and install the required packages for weather parsing:
chmod +x /usr/local/bin/get_temp.sh
chown asterisk:asterisk /usr/local/bin/get_temp.sh
yum install -y bash curl jqTest it:
/usr/local/bin/get_temp.sh🧪 The output should be a clean whole number (e.g.
72). If it includes hidden characters or fails, see log at/var/lib/asterisk/temp_script.log.
-
Login to FreePBX Admin Interface
- Open your browser and go to:
http://yourserver/admin - Authenticate using your admin credentials.
- Open your browser and go to:
-
Navigate to Custom Destinations
- Go to Admin > Custom Destinations
- Click Add Custom Destination
-
Define the Dialplan Context
-
Add Logic to extensions_custom.conf
- In the GUI, go to Admin > Config Edit (or use System Admin > File Editor if available)
- Open
/etc/asterisk/extensions_custom.conf - Add the dialplan provided in this github, copy/paste and don't forget to update it for your inbound DID
-
Route all calls from specific SIP trunks to the Time & Temp script
Do it this way only if you are using a whole set of trunks exclusively for the Time & Temp Service
-
In the GUI, go to Connectivity > Trunks
-
Set your trunks you wish to dedicate for Time & Temp, context to
from-trunk-time-temp
- Reload Dialplan
- Hit Apply Config or
- Navigate to Admin > Asterisk CLI
- Run the command:
dialplan reload
- Hit Apply Config or
To monitor the playback flow:
tail -f /var/log/asterisk/fullTo monitor the temperature script:
tail -f /var/lib/asterisk/temp_script.logYou can also run this to add the temp_script.log to your asterisk log directory so you can view it from the FreePBX menu Reports > System Logfiles
ln -s /var/lib/asterisk/temp_script.log /var/log/asterisk/temp_script.logThe temp_script.log will show any issues with the script, as well as when the weather api didnt work and the fallback was used.
The CDR records will also show a Userfield that contains something like 90°F & 96°F* This is handy to let you know your script is working and what it did. For example this one means the actual temperature is 90°F, the "Feels Like" temperature is 96°F, and the * at the end means the difference between actual and feels like was greater than 3° so the caller heard "but it feels like 96°". If that * was not there the actual and feels like were probably pretty close to each other like 90°F & 91°F in this instance the caller would only have heard "the current temperature is 90°" then the call would have disconnected, leaving off the "but it feels like X°" or the user hung-up before the script got to that part (you can see and example of one of these in the below CDR).
This was a fun project of mine, I don't have much time to assist with issues, but i'll do my best if you need a hand, use the Discussions tab at the top of this page to ask for some help or Click here.
This project is provided under a custom license:
You are free to use, modify, and adapt this code for personal or internal use.
You may not sell, distribute, or offer this code (or derivatives of it) as part of a commercial product or service, whether modified or unmodified.
Redistribution is allowed only for educational or non-commercial personal purposes, with proper attribution to the original author.
© Pir8Radio All rights reserved.
