Woppy Bot

While listening to the Cox ‘n’ Crendor show I thought that creating a Woppy Bot would be a nice research/relax project. The idea is to have an app that will tell the basic weather info for a random place in the US with the push of a button. The result must have the zip code of the picked place alongside the name, state, and weather info of course.

There were two major decisions to make: how/where to access the zip codes database and how to retrieve weather data. For the database, I choose to make a CSV file with the info that I needed: zip code, place name, state name, and state abbreviation. A couple of Google searches later I found a Web site that has various data sets regarding place names, postal codes, etc. The one data set I choose had more info than I needed so I had to reduce it1.

With the data set secured all I had to do is find any weather API that can provide data given the zip code of a place. Sounds simple. Wrong! There is only one normal API out there that accepts zip code as a primary identifier of a place and it’s OpenWeatherMap2. OWM exposes a URL that accepts zip code and returns the current weather data for the place behind it. It also has a little icon (URL) depicting the current weather in the response.

The technology of the choice was Node for the back-end and vanilla JS for the front. Node server’s responsibility is to pick a city using a random number generator and communicate to the OpenWeatherMap API. It exposes one endpoint for the front to retrieve data. The server is hosted on Heroku using the free dyno program. This is very convenient since I needed a way to simulate starting the Woppy bot which is covered by free dyno’s startup time (since it goes to sleep after some idle time).

Front-end is a plain JS/jQuery site that calls the Node back-end for weather and place info. One other requirement was that zip code digits are displayed one by one as if they were spoken out loud. This is handled by using intervals. Check out the source here.

You can try Woppy out here.

[Updated 28.08.2023.] Woppy bot server was hosted on Heroku using a free dyno plan, and since Heroku is no longer free it has been taken down until a suitable alternative is found. Until then Woppy is not operational. :-(


1: By using, among other things, this very nice regular expression: ^(\d{5}\t[a-zA-Z '\-]+\t[a-zA-Z '\-]+\t[A-Z]{2})(.*)$

2: Not counting Yahoo weather API which is a disaster with their YQL language and new OAuth philosophy and the fact it is not working.