Automate Your Life and Save Time By Going Serverless
Tags: serverless, development, api
Published: 2023-02-22 12:57:39


I recently had an epiphany. I've been working with serverless for years but I haven't been *taking advantage of it*. 

Don't get me wrong, I've been building enterprise-scale apps with it - so in that regard, I'd say I am taking advantage of it. But I haven't been using it to make my daily life easier.

There are many tasks I do day-to-day that I spend a lot of mental energy on. What is my workout going to be today? What's for dinner tonight? Are my chickens laying enough eggs?

In late 2022, I got the itch to make [cross-posting my blogs easier](https://dev.to/aws-heroes/i-built-a-serverless-app-to-cross-post-my-blogs-3eoe). I used to spend hours each week updating markdown in various formats so they would render properly on Medium, Dev.to, and Hashnode. 

Ain't nobody got time for that.

So I built something that does it for me. It runs in less than a second and does it right every time. I don't even need to review to content on the various websites. I push the post to [Ready, Set, Cloud](https://readysetcloud.io) and my automation handles the rest. 

Then I learned that Twitter's newsletter service, Revue, was shutting down. I took that as a sign to automate sending [my weekly newsletter](https://readysetcloud.io/newsletter). I followed the same pattern as my cross-posting automation and was able to completely take out the manual work of [transforming the newsletter copy for my website to the email copy](https://dev.to/aws-heroes/how-i-built-an-open-source-serverless-newsletter-platform-3bm2). This not only saved me *more* time every week but it also made my email format consistent and easily updatable. 

After the newsletter project, I was hooked. It finally clicked that I can use the power of serverless to rapidly build automations that do routine tasks for me... for free!

I quickly realized I could integrate with the OpenAI API to do some of the other routine tasks I did completely unrelated to tech or Ready, Set, Cloud. I built an app that [generates workouts and emails them to me every day](https://dev.to/aws-heroes/chatgpt-is-my-new-personal-trainer-55oa). And I'm not stopping there. 

## What's In It For You

Besides the obvious, "you now have daily tasks done for you," automating as much of your life as you can has some cool other perks. 

### Serverless Toolbox

Build your automations expecting to reuse something from it. For me, that usually means triggering something off an EventBridge rule. In my newsletter platform, I built a Lambda function that [sends an email via SendGrid](https://github.com/allenheltondev/serverless-newsletter-app/blob/main/template.yaml#L171). I spent a good amount of time configuring in SendGrid, validating my email address, and storing secrets for that project. *I wanted to reuse it for other projects!*

So I added an EventBridge rule to the function and now I can send an email with a simple call to `PutEvents`. Here's an example taken from a [Step Function workflow definition](https://github.com/allenheltondev/serverless-ai-fitness/blob/main/workflows/send-workout-email.asl.json) in my workout generator.

```
"Send Email": {
  "Type": "Task",
  "Resource": "${EventBridgePutEvents}",
  "Parameters": {
    "Entries": [
      {
        "Detail": {
          "subject.$": "$.subject",
          "html.$": "$.message",
          "to": "${AdminEmail}"
        },
        "DetailType": "Send Email",
        "Source": "AI Fitness"
      }
    ]
  }
}
```

Just like that, I have a working mechanism to send emails. No fuss, no configuration. `PutEvents` and done. This can be used for all my projects in the future, too!

Currently in my toolbox, I have the ability to [make a query to OpenAI models](https://github.com/allenheltondev/serverless-ai-fitness/blob/main/functions/query-chat-gpt/index.js), [secure any API in my AWS account](https://github.com/allenheltondev/serverless-api-key-registration) with an API key (even though it's best practice to include another form of auth), or [run a load test](https://github.com/allenheltondev/serverless-load-testing) with a simple trigger.

Build your side projects with reuse in mind. Before you know it, you'll have a suite of utilities you can tie into to rapidly accelerate new projects! 

### Personalized Reference Architectures

We all like things done in a specific way. Some of us like CDK, others prefer SAM, and others prefer Terraform. Beyond that, some people structure their projects into function folders, while others do service folders. Coding is not an exact science, we all have a certain way we like things done. 

With that said, as you build your automations you're bound to approach different problem areas that use a wide range of services. As you build with new services you set yourself up for reference architectures in the future. 

For example, I did a [series on AWS WebSockets](/blog/allen.helton/intro-to-aws-websockets/) in early 2022. But I don't have a perfect memory. I was recently working on a demo that used WebSockets but I couldn't remember some of the implementation details to get it working in AWS. So I went back to the project in GitHub, copied the source, and had a working solution in minutes (instead of hours or days). The best part about it? *It was already structured and written the way I like!*

Sources like [Serverless Land](https://serverlessland.com/) are invaluable. They aggregate patterns, repos, examples, and blogs from the community and make them available in one location. But because of that, you get a grab-bag of layouts with the code samples. Exposure to the different ways people build repositories is good, but you don't move as fast as if you did it yourself.

### Experience

Another obvious one worth mentioning is experience! Getting exposure to third-party APIs, machine learning models, and other various software components is a huge boost to you as a developer.

You learn so much when working with something new. When you're building something that benefits you directly (like automating a manual process in your life), you're bound to retain it better and understand some of the details you normally might have glossed over. It also opens the door to some more advanced or unique automations.

In 2020, I made a "[Christmas gift experience](https://dev.to/aws-builders/i-made-the-best-christmas-present-ever-again-this-time-with-alexa-websockets-and-mobile-apps-5akp)" for my brother. I made a dungeon crawler game on a mobile app that communicated with an Alexa skill to coordinate movement. The dungeon would lead him around to the next present he was allowed to open in real life. It was pretty neat.

From that, I learned some of the intricacies of Alexa skills. I built what I felt was a relatively simple skill, but it uncovered so much into a previously unknown world for me. It made me feel like I was now able to build a skill for other things. And I have! Because I opened that door initially, I now have the know-how to extend it and use it to automate more of my life.

## Getting Started

There are plenty of reasons to get started automating your life! Things are done for you, it accelerates future projects, you get reference architectures the way you like them, and you build a wealth of experience. But you might be thinking to yourself, *where do I start?*

Start with a problem. What do you do every day/week/month that you wish could be handed off? Is it something a digital solution can help with? You obviously can't build software to do the dishes for you (not yet, anyway). But you could build software to order your groceries for you. 

You could build an Alexa skill that takes input like "*put chicken piccata on the menu.*" The skill could look up a recipe for chicken piccata, then use a grocer API like [Kroger](https://developer.kroger.com/reference/) or [Walmart](https://www.walmart.io/docs/opd/) (if you're in the US) to add the ingredients to your cart. When you're ready, just tell Alexa to "order groceries" and 3 hours later everything you need for next week's meals is at your doorstep.

We're all in different places. We have different priorities and opportunities. It's impossible to be prescriptive on what would be a good automation for one person vs the next. You know what you do day in and day out. *Be creative*. 

Some of this might feel obvious. But it's always good to hear it from someone else if you've been on the fence about whether or not [you should start that side project](https://readysetcloud.io/blog/allen.helton/5-reasons-to-finally-start-that-side-project-youve-been-putting-off-3970dbcc0b27). Do it!

Coding is one of my hobbies. A common misconception I see is that all hobbies need to make you money. *That's not true!* Build something to increase your quality of life. Take some mental strain off yourself by pushing critical thinking to AI. Eliminate manual processes by using 3rd party APIs to do them for you. Boost the power of voice commands by building your own Alexa skill. 

The possibilities are literally endless. If you can dream it, you can do it. And you can make your life a little easier while you do.

Happy coding!