This project uses an AWS Lambda to send a text message with the current weather.
Here's the process flow:
- Lambda is triggered by a CloudWatch scheduled cron job
- Lambda calls the OpenWeatherMap API for current conditions
- Lambda calls the NOAA API for forecast data
- A message is created with all of the content
- A text message is sent via Twilio's APIs
- Before running your own version of this project, please create an AWS account and setup the CLI.
- Go here to get started
- This project uses ClaudiaJS to generate the AWS lambda
- Checkout the tutorial here https://claudiajs.com/tutorials/hello-world-lambda.html
- In order to get the current weather I used the OpenWeatherMap API. The weather service is free, but you still need to register to create an API Key.
- Go here to get started
- In order to get the weather forecast, I used NOAAs APIs. These are free and open to the public.
- Go here to get started
- This lambda uses several environment variables to do its work
OPEN_WEATHER_MAP_API_KEY
= the registration key for an OpenWeatherMAPAPI accountLATITUDE
= the Latitude of the location you want to get the forecast ofLONGITUDE
= the Longitude of the location you want to get the forecast ofTWILIO_ACCOUNT_SID
= the SID of a Twilio account for sending text messagesTWILIO_AUTH_TOKEN
= the auth token of a Twilio account for sending text messagesTWILIO_FROM
= the phone number that is to be used with the Twilio account for sending text messagesTWILIO_TO
= the phone number you want to send a text message to- In order to easily setup these values, please fill out the corresponding
<VALUE>
and paste this at the bottom of your terminal's bash_profile (or other associated shell)
# weather-text
export WT_OPEN_WEATHER_MAP_API_KEY=<VALUE>
export WT_LATITUDE=<VALUE>
export WT_LONGITUDE=<VALUE>
export WT_TWILIO_ACCOUNT_SID=<VALUE>
export WT_TWILIO_AUTH_TOKEN=<VALUE>
export WT_TWILIO_FROM=<VALUE>
export WT_TWILIO_TO=<VALUE>
- This project has
npm scripts
that will enable you to get up and running without a problem create-lambda
uses the ClaudiaJS CLI and the AWS CLI to create a lambda in the AWS account on your machineupdate-lambda
uses the ClaudiaJS CLI to provision your Lambda with the environment variables mentioned abovelocal-test
enables you to call your lambda from your local terminal
- Create an OpenWeatherMap API account and get a key
- Create an AWS account and setup the CLI on your local machine (the account gives you a free year of services)
- Install the ClaudiaJS CLI on your local machine
- Create a trial account with Twilio (it is free and you get a starting credit)
- Setup the Environment variables in the
npm script
that I mentioned above - Run the
create-lambda
script to create the lambda in AWS - Run the
update-lambda
script to update the Lambda with the environment Variables - Run the
local-test
script to see it in action (and test it on a phone number of your choice) - and tada! 🎉 🎉 🎉 🎉 It should be working!
- This is a very small project, but PRs are welcome!
- Reach out to me at
@AndrewEvans0102
on twitter anytime!