Morning Joy

How I Built It

I signed up for Twilio and followed their quickstart guide for Node.js. I bought a phone number and tested sending a text to myself. This was painless. I probably spent more time picking the phone number than I did writing the code.

Reddit JSON

Next, I needed to find a content source that I can count on to be renewed on a daily basis and to be of high quality. I decided to use Reddit’s r/aww and r/UpliftingNews subreddits. They are two of the largest subreddits, so I should never get duplicate content. I also wanted to grab the first post when sorting by top for today, which means the community has heavily upvoted the post.

Hosting

Lastly, I needed a way to schedule the script to run every morning. To keep it simple, I converted my script into an AWS Lambda function and set up a CloudWatch Events rule that triggers on a schedule to fire the function every day at 10 a.m. UTC. The schedule expression is: cron(0 10 * * ? *). I also added environment variables to pass DESTINATION_PHONE_NUMBER, TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, and TWILIO_PHONE_NUMBER to the function.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store