Time & Temp Announcer Script

I read on another website someone wrote a Asterisk script that would say the time and temperature with the Pat Fleet recorded prompts for Asterisk. Please see this link The Magic Cafe Forums - Nostalgia? Time and Temperature phone number

I would like to recreate that script if you could let me know how to set that up that would be great.


I’d be really impressed if you could pull the script out of a hat :slight_smile:

As most things in the world of computers, there are several ways to do a task. You get to choose which is most appropriate for you.

You could do it in ‘dialplan’ (the ‘native’ scripting language of Asterisk) or using AGI (Asterisk Gateway Interface) and then you get to use any ‘real’ scripting or compiled language. Maybe even AMI or ARI could be used as well :slight_smile:

My choice would be to write it as an AGI. I like keeping my dialplans neat and tidy and hide all the logic and details in a nice black box.

It’s not a big deal. You can ask Asterisk for the current date and time, and I’m sure you can find some web site to return the temperature. Would this be for a single location or would you let the caller enter the area code (which may not match their area code), ZIP code, or IATA?

Are you looking at this as a learning experience or as something that may be the basis of an advertising business implying professional services and support?

Assuming you had the requisite recordings and the temperature in a channel variable and you wanted to do it in dialplan…

It would look something like this:

        exten = s,1,                    verbose(1,[${EXTEN}@${CONTEXT}])
        same = n,                       playback(${current-advertisement}&at-the-tone)
        same = n,                       datetime()
        same = n,                       playback(beep&and-the-temp)
        same = n,                       saynumber(${current-temperature})
        same = n,                       playback(degrees&fahrenheit&thank-you-for-calling)
        same = n,                       hangup()

This would be for a single zip code. How would I set it up to pull the temperature from a website and use the Pat Fleet voice?


If you’re looking at this as a learning experience, you may want to start with reading Asterisk: The Future of Telephony and reference that as you examine some of the examples referenced in your other topic.

If you want to hire someone to develop and support this application, I and others on the forum may be interested, but this forum is non-commercial, so you should contact them privately.

This is a learning experience how do I put the temperature in a channel variable.

Read up on the CURL() function.

curl wttr.in/Amsterdam

Correct to pull the temperature?

It does pull the temperature. And a bunch of other cruft to sift through.

This is why I’d use an AGI. Parsing through this ‘ASCII art’ may be challenging in dialplan – especially with the embedded ‘escape sequence’ color changes. (Take the 4th line, search for the open parenthesis, back up over the escape sequence that turned off color, set a mark, search back to the end of the previous escape sequence…)

I’d ‘shop around’ a bit and see if I could find another web site to scrape or one that provides an API with specific values.

It’s not impossible, I’m just guessing you can find an easier source.

Will this API work

curl https://api.weather.gov/gridpoints/BUF/23,26/forecast

Or would this work

curl NOAA's National Weather Service

Both would work, but I’d suggest reading this Reddit thread and see what other people have done since WU shut down their free API.

How did the examples referenced in your other topic get the temperature?

I would like to use the following API


How would I set that up?

Oh, I don’t know…

What have you tried and what results did you get?

So do I need to write a script with that curl in it?

You could use the CURL() dialplan function and then parse the result. It looks like JSON so the proper way would be to treat it as a JSON object, but I’m guessing based on my assumption of your current Asterisk skills that just using the dialplan functions CUT(), REGEX(), REPLACE(), SHELL(), SHIFT(), and STRREPLACE() in some combination may yield a solution.

Or, you could use a shell script…

Or, you could dive in the deep end and try an AGI script.

Can you give an example of how to do that?

Nope. But I’ll review what you’ve done and offer suggestions.

So what type of script do I need to write?