Skip to content

Latest commit

 

History

History
33 lines (20 loc) · 1.63 KB

README.md

File metadata and controls

33 lines (20 loc) · 1.63 KB

AQI Bot

AQI Bot fetches air quality and posts that data to slack. This repo consists of two component which operate separately. A stand alone job to fetch and send air data, and a web server to make requests on demand. The project makes use of the air visual api https://www.airvisual.com/air-pollution-data-api

Job

Located in the job folder, consists of a main.go file to run the job and a Dockerfile to build and run as a docker image. When run, the job fetches the aqi and posts it to the configured channel. The job should be set up to run on a cron schedule to periodically post air quality data to slack.

Required:

  • SLACK_WEBHOOK webhook url to post data to slack
  • SLACK_CHANNEL the channel to post the data to
  • AIRVISUAL_API_KEY the api key for air visual

Server

Located in the server folder, it consists of a main.go file and a Dockerfile to build the job. The web server binds to port 8080, and listens for POST requests on / from slack. It will verify the requests came from slack, fetch air quality data, and return the response to post in slack. It is meant to be installed as a slash command in slack.

Valid options to the base slash command include:

  • city "<City>" "<State>" "<Country>" which will return data for the specified city
  • nyc for New York City
  • LA for Los Angeles
  • cigarettes to calculate the number of cigarettes spending all day in the air with aqi is equal to

The default returned values are for San Francisco, California, USA.

Required:

  • AIRVISUAL_API_KEY the api key for air visual
  • SLACK_SIGNING_SECRET the secret with which slack responses will be signed