Doing 100,000 push-ups this year with the help of Siri

Ante Barić
6 min readFeb 4, 2022

--

Photo by Ketut Subiyanto from Pexels

Update/Spoiler: I did it! https://pushups.dev/ 💪 💪 💪

As a New Year resolution I challenged myself to do 100,000 (one hundred thousand) push-ups until the end of the year. As most people know new year resolutions are often abandoned so I did not lose any time with fancy counters and instead I opened Google Sheet and started logging my progress.

My pushups logging sheet
My push-ups logging sheet

I basically have:

  • cell A1 (sum of total push-ups this year)
  • cell B1 (goal for this year)
  • cell C1 (push-ups left to do, B1 minus A1)

And then in the column A i just log my sets as I do them throughout the day.

There is also Google Sheets mobile app so I was able to log my push-ups throughout the day but if you ever tried editing sheet on your phone you would see it is not the best experience.

Then one day as I was doing a set of 20 push-ups I heard my girlfriend asking Siri to set some reminder for her work. As I was doing the last 2 push-ups my brain I guess got a little bit more blood so I got an awesome idea.. What if I can make Siri keep count of my push-ups throughout the day?

I already knew about Shortcuts, Apple automation app (available for iOS, iPadOS and macOS) that lets you do all kinds of task by using other apps and functions on your iPhone. So after a few more push-ups I decided to give it a try that afternoon.

Basically what I needed was:

  • Access data inside my Google Sheet.
  • Update data inside my Google Sheet, same as I was doing manually after each push-ups set that I did.
  • Let Siri know how to react when I say “I did some push-ups” and update my Google Sheet automatically

First I checked googleapis package on npm. It provides a client with methods to access all features of Google REST API. As Google Sheets are available through that API I was on the right track.

First I needed to authenticate, I tried few options but creating a service account proved to be the easiest. I followed these steps. Basically you go to Google Cloud Console, create a service account that has “Editor” role for you account and download JSON file which you then push inside the auth constructor with correct scope.

List of valid scopes can be found here

After that I was ready to actually query data from my sheet. This proved to be an easy step, a simple range like string (as you would write in sheets expressions) and we get the cells data.

Now that I had the data (my push-up sets) it is time to update the cells, there are multiple ways of doing that but I found that the easiest was to take current values for range and then just append another cell at the end with the number of push-ups I just did.

Ok, so I managed to programatically read and update data inside my sheet. When I run my script the Google Sheet inside my browser automatically syncs and shows new data. Let me quickly do 10 more push-ups and then jump on the final part.

So now I needed to find a way to run my JavaScript code through Siri. Luckily Siri has plenty of options for running code, programs or scripts through Shortcut actions, let’s take a look at the actions that are available:

  • Run a bash script - I managed to run my code through node but then I realised that running a bash script is only supported on macOS Shortcuts so this was a no go.
  • Run a bash script through SSH - managed to do this but I was not in the mood of setting up a whole server or exposing my Mac through ngrok just so I can run one script through SSH.
  • Run JavaScript through Safari - I was already stuck with Node and this was a deal breaker because it would actually open up a website when I called “Hey Siri” and would need to use Browser APIs.
  • Run a HTTP server and making an API call - this proved to be solution I went with and here is why…

There is this thing called Serverless Functions on Vercel. As I host most of my static sites through them I decided to give serverless a try. This is my serverless function (or lambda).

My pushups.js file which is then exposed as API endpoint

If you ever worked with express routes or middlewares this should be pretty familiar syntax without going into much detail to what lambdas actually are and how they work. Basically function gets reqand res objects and then you can send response after it executes your logic. Inside Vercel project you can put files like this inside /api folder and Vercel will automatically expose it on POST /api/pushups endpoint for new deployment. If you wish to read more about the setup you should check Get Started guide on Vercel. Only note here is that in free tier on Vercel max execution time for single lambda is 5 seconds, but that is plenty for 2 Google API calls I needed to do.

Now that we have everything ready, let’s assemble it into our first Shortcut. I opened Shortcuts app on my Mac. The interface is pretty straightforward and consists of few building blocks.

Shortcuts app interface on macOS showing my Shortcut

On the left we have a toolbar where you can search for different actions. I used:

  • Ask for input action which triggers Siri to prompt you for some input, you can even write what do you want her to say. Also you can define type for you input (by selecting Number Siri language processor can know what to expect and be more precise).
  • Get contents of URL action is basically JavaScript fetch equivalent in Shortcuts, It lets you do HTTP requests and works great, you can see the options above. This is where I call POST /api/pushups endpoint to update data inside my Google Sheet.
  • Speak action which lets you use Siri voice feature to make her say something, the input for that can also be dynamic but let’s keep it simple for now.

Ok, so creating a Shortcut was actually pretty easy, but how do we actually connect it with Siri? Well, you may notice that name of my Shortcut is “I did some push-ups”. By default the name itself is a trigger for you shortcut. So when I say “Hey Siri I did some push-ups” Siri will first look at my shortcuts and if any one of them matches it will trigger actions defined inside. This is the result:

Pretty neat right? She even made me do even more push-ups because while I was testing this I swear I did like 100 of them 😰 💪

Later I made Siri responses random by adding few alternative cheers to make things fun. I also added few more Shortcuts.

Apple also automatically syncs shortcuts across all you devices.

They were implemented with the same 3 actions and now I can also check my current progress for the day or how much more I need to do in total until end of the year.. actually let’s check right now…

Me: “Hey Siri How many push-ups left”
Siri: 97590
I better do some more push-ups…

Thanks for reading!

If you are interested in more advanced Shortcut examples and how you can actually do programming in them — check out the links below:

--

--

Ante Barić

I am experienced software developer, probably not that much freaky movie freak and passionate runner hailing from Croatia.