Building a WeatherBot

code • February 22, 2017

We live in Upstate New York so there’s snow and it’s kind of pain for J to plow the driveway if our cars are in the way. I built a little Slack bot that runs three times a day (7 am, 1 pm, and 7 pm). And if there will be more than one inch of snow in the next 12 hours then WeatherBot will ping our Slack:

WeatherBot Slack Post

How it works

  1. Using the Dark Sky API, I run through the hourly data for the next 12 hours.
  2. During each hour, if the forecast shows precipitation which is snow, and the snow will accumulate, then start adding up the accumulation.
  3. If there’s more than 1 inch of snow during the next 12 hours, then post to Slack.

How it runs

WeatherBot uses three AWS resources:

  1. S3 - I deploy and host the code here.
  2. CloudFormation - I created a CloudFormation template that defines the variables and the functions that Lambda will need to run my code.
  3. Lambda - Lambda handles running my code at the days and times I’ve defined. (The CloudFormation template does me a solid by configuring Lambda for me.)

Browse the code!

And now we get to sit back and wait for :snowflake: and then park our cars good.

Keep reading code