Fill a Notion database via iOS home screen shortcuts through the notion API — with the example of a workout tracker

Thomas Lichtblau
madebywild
Published in
8 min readAug 2, 2022
Animation of entering a value to a iOS Shortcut from the home screen, which automatically gets added to a notion database.
The finished product, track your workout progress directly from your Home Screen into Notion

I personally and also the whole team at wild is extensively using Notion and since I got into all kinds of automations recently, it was time to explore the possibilities of connecting Notion to other apps via their API. In this case I wanted to feed a notion database via a direct input on my iOS Home Screen. To demonstrate it, I built a workout tracker, even if I don’t work out a lot… Muscle Tracker was born.

The goal: Document your workout progress, directly from your iOS Home Screen into a Notion database through an iOS Shortcut, in a frictionless and time saving way.

Icons of the 3 apps that are used. Shortcuts, Notion & Focus
Tools that I use in this tutorial

Here’s a quick mockup of how the user journey from going to the gym till adding a new entry to a Notion database will be. Quite straight forward.

The 4 steps visualised in 4 iPhone screens. From changing the focus till seeing the new entry in Notion.
Simple user flow of the four steps

Now that you know what the end result will look like, let’s dive into recreating it step by step.

Tutorial

Feel free to either follow it step by step or adapt it to your own needs. The same concept could be adapted to a lot of different use cases! Happy to see other use cases coming to life, let me know what you create!

Part 1: Notion Database

The Database will collect all the data we’re submitting and it will give an overview of your workout progress.

Feel free to duplicate the notion template and continue with Part 2.

A notion database with different data that got added via the home screen shortcut
The finished Notion Database with multiple filtered views

Create Notion Database

We want to show the exercise, when we did it and how much weight/time/repeats we did.

An empty notion database entry with 3 properties. Exercise (Tag), Date (Date) & Unit (Number)
Our 3 main properties
  1. Create a new Notion page and select Tableand then + New database
  2. Add a new entry and create three new properties. Select, Date, Number
  3. Rename Select to Exercise
  4. Keep Date as it is
  5. Rename Number to Unit
  6. Add all the different exercises you wanna track to the Exercise property. Examples: Treadmill, Upper Back, Leg Press

*It’s important to plan the properties in the beginning to avoid tedious changes later. Especially when it comes to property names.

Create Filtered View

For a better overview we will create multiple views with different filters. One view that shows all the entries, with the latest entry on top and others that only show the specific exercises with the latest entry on top.

The notion database, sorted and filtered
Sorted Date + Filtered Exercise
  1. Rename the current view to Latest
  2. Click Sort & select Date and then Descending
  3. Click ... next to the Latest View and duplicate it, keep the sort settings
  4. Rename it to one of the Exercise Tags you created. Example: Leg Press
  5. Click Filter, Exercise & select Leg Press
  6. Duplicate this view, rename it and filter it by the other exercises you added earlier.
  7. The Notion Database is ready

Part 2: Notion Integration

We now need to open the door for adding something to a notion database from an outside app.

Screenshot of the notion integration dashboard

Create the Notion Integration

What we need is the Internal Integration Token.

Screenshot of the notion integration settings
After creating a new integration, you’ll see the internal integration token
  1. Go to notion.com/my-integrations
  2. Create a new Integration
  3. Add a Name + select the Associated Workspace (in case you have multiple), leave the rest as it is
  4. Hit Submit on the bottom of the page
  5. Copy the Internal Integration Token and paste it to your notes, you’ll need it later

Share the database with your integration

What we need is to get the Database ID

Screenshot of how to share a notion database and how to get the database ID
Left: Share it with your Integration / Right: Copy the Database ID
  1. Go back to the notion database you created earlier and click Share
  2. You can now share it with the Integration you created
  3. To get the Database ID, click Share and then Copy link, paste it to your notes and only keep part between the / and the ?. See screenshot above.
Note: In case your database is embedded into another page you need to copy the link to the database view in order to get the ID. 

Part 3: Apple Shortcuts

In this part we want to make sure that the input we want to track, finds its way to the notion database

Feel free to download a Shortcut Example (Leg Press). Don’t forget to Add your API Key and your Database ID

Screen shot of the apple shortcut
The full automation from converting the creation date till connecting it to notion

Creation Date

We get todays date and convert it into a format that notion can read

Screenshot of the shortcut action to format a date into a format notion can read
  1. Open the Shortcut app & create a new Shortcut
  2. Add the Date action, you can search for it in the search field in the sidebar
  3. Add the Format Date action
  4. Click on Show more and select Iso 8601 as a date format.

Add Input

That’s the question and the input field that will pop up when you’re using the iOS Shortcut.

Screenshot of a shortcut action that adds a prompt
  1. Add the Ask for Input action, this will be the question you get asked when you use the shortcut
  2. Select Number as an input type and enter “How much did you lift?” as a prompt

Add json code

I can’t code, so I found a couple of snippets online and adapted them. See sources on the bottom of the article. Make sure everything is named exactly like it is named in the Notion database.

Screenshot of the shortcut text action with the json code we need to add a new entry to a database
  1. Add the Text action
  2. Paste in the following Json code snippet:
Database ID = The ID you extracted from the database url
Entry Name
= Name of the entry. In our case “Leg Press”
Exercise Tag = Tag from the select property. In our case “Leg Press”
Formatted Date = Output from step two, the formatted date
Provided Input = Output from the question we added in the previous step
To enter Formatted Date & Provided Input just start typing it in and then the options will pop up

Get contents of …

That’s the part where we post something into the notion database via the API.

Screenshot of the “Get contents of” action from shortcuts
  1. Select the Get contents of … action and add https://api.notion.com/v1/pages as the URL
  2. Click Show More & select Post as a Method
  3. Add 3 Headers
    Authorization: Bearer ‘Secret Key(Key from the notion integration)
    Notion-Version: 2022–06–28 (You can get the most recent version here)
    Content-Type: application/json
  4. Set Request Body to File
  5. Open the Choose a Variable dropdown and choose Select Magic — Variable
  6. Click the small Text icon below the text action

Test the automation

Click the little play icon on the top right of the window. Moment of truth. 3. 2. 1.

Prompt that appears when the action gets played
  1. Click the Play Icon in the top bar
  2. Enter a number as an input
  3. Notion database gets populated with a new entry
  4. You did it!

If there’s an Error, it’s probably a typo in the json code, it’s important that everything has exactly the same name as it has in Notion.

Part 4: iOS Home Screen & Automation

Screenshot of a custom iOS app screen, with a grey background, the notion widget and thumbnails for the exercises that lead to their own shortcut

Create a new Home Screen + add Shortcuts

Let’s dedicate a full home screen to our workout shortcuts so we can fully focus on what’s important in the gym.

Settings on how to add a shortcut to your Home Screen
  1. Prepare square thumbnail images and save them to your photos
  2. Open the Shortcut in the Shortcuts app
  3. Tap the Share Icon
  4. Select Add to Home Screen
  5. Select a thumbnail image + Name your Shortcut
  6. Hit Add
  7. Move the Shortcut to an empty Home Screen
  8. Repeat that with all the Shortcuts you want to add
Bonus: Add a notion widget with your Muscle Tracker to quickly see what your last entries were. See my set up in the screenshot above.

Add new Focus

This will give us the chance to hide all the other apps and only show workout related apps and shortcuts. It suddenly feels like a new phone!

Screenshot of adding a new focus to your iPhone
  1. Go to Settings > Focus
  2. Tap +
  3. Tap Custom
  4. Add a Name (in this case “Fitness”), Color + Icon and hit Next
  5. Go through the other steps and hit Done
  6. Go back to the settings of your freshly created Fitness focus and under options tap Home Screen
  7. Activate Custom Pages + select the screen you want to have visible during the Fitness Focus
  8. Hit Done
Bonus: Turn the Focus automatically on when you arrive at a location or when you join a wifi network. I sometimes had issues with it though, probably because my gym is too close to my home. When you have an apple watch, you could also turn it on automatically as soon as you start a workout.

Create Automations to switch your wallpaper

To have a clear visual cut between your default focus and your fitness focus, it helps to automatically change the background as soon as the focus is changed.

Either follow the steps below or watch this great YouTube video from #QuickTips with Jacob.

First you organise your wallpaper, then create an automation
  1. Prepare two wallpapers, the one you always use and the one you want to add to your fitness focus. Call them Regular and Fitness
  2. Create an album for each background
  3. Open the Shortcuts app, go to Automations and hit the +
  4. Select Create Personal Automation
  5. Scroll down to Focus and select Fitness
  6. Keep When Turning On selected and tap next
  7. Use the following settings:
    a. Find All Photos where Album is Fitness
    b. Set Lock Screen and Home Screen wallpaper to Photos
  8. Do the same, just with the other background, for When Turning Off
  9. Activate your fitness focus and you’re home screen will transform into fitness mode
  10. Happy lifting!

What I would love to add in the future:

  • Show the latest exercise value in the prompt or even in the thumbnail
  • Add units like kg or min to the Notion database (not possible right now)
  • Find out why starting an automation when connecting to a specific wifi isn’t very reliable

Please let me know if you have more ideas!

Sources:
Change iPhone Wallpaper:
#QuickTips with Jacob
Create Json Snipped:
Jon Tormod Nordland

Other Example: Quick Add To-Do List

For a simpler Shortcuts to Notion example, check out the Quick-Add To-Do List, that makes it possible to add a task from anywhere, without opening Notion.

--

--