Table of Contents
Weather Bot is an automation tool designed to fetch data from the National Hurricane Center and the National Weather Service, identify relevant weather alerts and warnings, and publish weather reports.
This project was originally built for El Vocero de Puerto Rico in San Juan, Puerto Rico. The Associated Press and the Knight Lab at Northwestern University collaborated to develop this application as part of the Local News AI Initiative, funded by the John S. and James L. Knight Foundation, which aims to leverage AI for the benefit of local news.
The development team thanks the staff at El Vocero de Puerto Rico for proposing this project, and for their participation, feedback, and encouragement.
- Timely Information: Ensuring that weather alerts are delivered promptly to keep the community well-informed about potential risks in critical times.
- Reliable Data: Sourcing data from government sources to provide the most up-to-date and accurate information.
- Efficiency: Utilizing automation to streamline the process of translating weather reports from English to Spanish and writing stories.
The Weather Bot functions through a simple process:
- Data Collection: The bot continuously monitors data feeds from the National Hurricane Center and the National Weather Service API.
- Alert Identification: The bot uses predefined scenarios to identify weather events that require attention and story generation.
- Report Generation: When an alert is detected, the bot generates comprehensive weather reports capturing the key details.
- Publication: These reports are then published to the CMS of El Vocero and an email notification is sent to the newsroom.
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
weatherbot
is developed based on Python. The earliest python version it has been tested with is 3.8.10
Basic software dependencies are listed in requirements.txt
and are readily installed from PyPi.
As written, the system depends on three external systems, not including the NWS and NHC feeds:
-
Email: the code uses the python standard library to send mail via
SMTP
. Assuming you have access to one, you can simply define the following environment variables, and email sending should work. If necessary variables are not set, the system will log information about the email it would have sent.- SMTP_SERVER
- SMTP_USERNAME
- SMTP_PASSWORD
- SENDER_EMAIL
-
Posting to Content Management System: the code is tightly coupled to the Blox CMS used by El Vocero. If your organization uses Blox, you probably need to get IP addresses whitelisted; you'll need to edit
blox.py
to changeWS_ROOT
to your organizations API endpoint; and, you'll need to set the environment variables listed below. If the variables are not set, the system will log information about the CMS actions it would have taken.- AUTH_USER
- AUTH_SECRET
-
Translation: NWS and NHC bulletins are issued in English. The code is set up to automatically translate text to Spanish, using DeepL. To use the translation, you must establish a DeepL account, generate an authentication key, and set it as the value of an environment variable,
DEEPL_AUTH_KEY
. If the environment variable is not set, the system will simply not translate text.
- Clone the repo
git clone git@github.com:NUKnightLab/weatherbot.git
- Install requirements
pip install -r requirements.txt
- Test the code
python main.py --nws test_files/nws_rip_current.json
Testing the application was challenging, because there are not good archives of bulletins. We've begun developing some testing processes. A handful of test files are in the repository in the test_files
directory. You can collect others from current data provided from the NWS and NHC.
To run a test, specify the path to an NWS JSON file, an NHC XML file, or both. If you only specify one, the other code path will be ignored. (That is, it won't go out to get live data.) You may want to adjust logging configuration, currently in main.py
. (In the future, logging configuration should probably be externalized to a configuration file.)
Example test commands:
python main.py --nws test_files/nws_rip_current.json
python main.py --nhc test_files/nhc_franklin_tropical_storm_watch.xml
Distributed under the GNU GENERAL PUBLIC LICENSE. See LICENSE
for more information.
The Associated Press does not provide technical support for this open-source application.
Joe Germuska - @JoeGermuska - JoeGermuska@northwestern.edu
Project Link: https://github.com/NUKnightLab/weatherbot
- Mame Coumba Ka - @coumbaK - Northwestern University
- Maria Ximena Aragon - Northwestern University