Danny Guo | 郭亚东

Splurge Stopper

 ·  526 words  ·  ~3 minutes to read

Amazon recently ran a developer challenge to build Alexa skills. I only found out about the challenge a few days before it ended, so I decided to build something very small in scope.

The theme was life hacks, and one of my personal life hacks for not spending money on things I don’t need or really want is to think about how much money I could have later if I invest it instead. There are caveats to investing, but this trick has stopped me from buying things I would have regretted later. Exponential growth is amazing when it works in your favor. Small amounts of money can grow to unintuitively large amounts, if given enough time. Humans don’t naturally grasp the power of exponential growth, so I always do a quick mental calculation.

I turned this trick into an Alexa skill called Splurge Stopper (the source code is on GitHub). You ask it why you shouldn’t spend a certain amount of money, and it responds with how much money you might have in the future if you invest it instead.

You: Hey Alexa, ask Splurge Stopper why I shouldn’t spend 80 dollars on fancy socks.

Alexa: Because if you invest it instead, you might have about 143 dollars in 10 years, 257 dollars in 20 years, 459 dollars in 30 years, or 823 dollars in 40 years.

It assumes an inflation-adjusted, annualized return rate of 6 percent. The historical rate for the S&P 500 is between 6 and 7 percent. Because the rate is adjusted for inflation, the amounts reflect current day purchasing power.


  1. Past performance is no guarantee of future results. Losing money is a risk.

  2. You have to actually invest the money that you don’t spend. It’s not enough to just not make the purchase.

  3. You have to hold for the long term. The point of listing the amounts for multiple time periods is to show just how effective exponential growth can be when it has enough time to really take off.

What I Learned

This was my first time working with Alexa or any voice control platform, so I learned the basic concepts as I read the Alexa Skills Kit documentation.

This was also my first time working with a “serverless” platform. The Splurge Stopper code runs on AWS Lambda. I used Node.js for the execution environment because Amazon has a SDK for it.

Parsing the money amount was the hardest part because as of now, there is no built-in slot type for money, which was really surprising. I found an open issue to add a money type. As a workaround for now, I followed this Stack Overflow answer and used two slots: one for dollars and one for cents. I had to use many more utterances to account for various combinations of dollars and cents.

I read about Speech Synthesis Markup Language for the first time. It allows you to control how text is converted into artificial speech, so you can make it sound more natural. For example, you can surround a certain phrase with emphasis tags (e.g. <emphasis>awesome</emphasis>), and the voice will stress the phrase. I didn’t end up using SSML, but it seems like it’d be very useful for a more involved skill.

← Building Dynamic Firefox Themes A Tribute to Kindle →

Follow me on Twitter or Mastodon or subscribe to my newsletter or RSS feed for future posts.

Found an error or typo? Feel free to open a pull request on GitHub.