Skip to content

Code developed with Associated Press and El Vocero to automatically generate stories for weather emergencies.

License

Notifications You must be signed in to change notification settings

NUKnightLab/weatherbot

Repository files navigation


AP Logo

Weather Bot

Table of Contents
  1. About The Project
  2. Getting Started
  3. License
  4. Contact

About The Project

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.

Project Objectives

  • 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.

How It Operates

The Weather Bot functions through a simple process:

  1. Data Collection: The bot continuously monitors data feeds from the National Hurricane Center and the National Weather Service API.
  2. Alert Identification: The bot uses predefined scenarios to identify weather events that require attention and story generation.
  3. Report Generation: When an alert is detected, the bot generates comprehensive weather reports capturing the key details.
  4. Publication: These reports are then published to the CMS of El Vocero and an email notification is sent to the newsroom.

(back to top)

Built With

  • Python

(back to top)

Getting Started

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.

Prerequisites

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 change WS_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.

Installation

  1. Clone the repo
    git clone [email protected]:NUKnightLab/weatherbot.git
  2. Install requirements
    pip install -r requirements.txt
  3. Test the code
python main.py --nws test_files/nws_rip_current.json

Testing

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

(back to top)

License

Distributed under the GNU GENERAL PUBLIC LICENSE. See LICENSE for more information.

(back to top)

Contact

The Associated Press does not provide technical support for this open-source application.

Joe Germuska - @JoeGermuska - [email protected]

Project Link: https://github.com/NUKnightLab/weatherbot

Original Developers

  • Mame Coumba Ka - @coumbaK - Northwestern University
  • Maria Ximena Aragon - Northwestern University

(back to top)

About

Code developed with Associated Press and El Vocero to automatically generate stories for weather emergencies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •