Building a sleep quality tracker and AI-powered sleep coach in Notion

Poor sleep habits are common knowledge: stimulants such as caffeine and alcohol, screen time before bed, irregular bedtime, heavy meals…

Building a sleep quality tracker and AI-powered sleep coach in Notion

Poor sleep habits are common knowledge: stimulants such as caffeine and alcohol, screen time before bed, irregular bedtime, heavy meals, high stress and anxiety, etc. But you don’t need a PhD to know this. After all, people have an intuitive sense of what negatively impacts their sleep.

However, there are two problems:

In this quick guide, I will show you how to:

  1. Build a sleep diary in Notion heloping you track your sleep quality and identify key patterns and sleep disruptors.
  2. Use Notion’s AI agent to identify problems and potential sleep disruptors

Why you should keep a sleep diary

A sleep diary is a personal record that tracks your sleep patterns and behaviors, providing valuable insights into how various factors affect your sleep.

In his excellent book Why We Sleep, author Matthew Walker explains why keeping a sleep diary can help you improve sleep quality.

  1. Identify patterns — By recording your sleep habits, such as bedtime, wake-up time, and sleep quality, you can identify patterns or irregularities. This can help pinpoint factors that may be disrupting your sleep.
  2. Track influences — A sleep diary helps you track how lifestyle choices, like caffeine intake, exercise, and stress levels, affect your sleep. Understanding these influences allows you to make more informed decisions about changes to improve your sleep.
  3. Understand sleep environment — Keeping a record of your sleep environment (e.g., room temperature, noise levels) can help you assess whether these factors are affecting your sleep quality.
  4. Improve sleep hygiene — With a detailed account of your sleep habits, you can more easily identify areas where you can improve your sleep hygiene, such as establishing a consistent bedtime routine or optimizing your bedroom for better sleep.

A sleep diary could be a bare-bones, simple pen-and-paper kind of affair, or something more elaborate (e.g. Google Sheets or a dedicated mobile app). Whatever works for you — as long as it helps you consistently, morning after morning, record your sleep information.

Being a big fan of Notion, I couldn’t help but build out a database, and put Notion’s AI to good use.

Here’s what you’ll need:

Step 1: Build a database in Notion

First, open your Notion. Type /database in a new page co create a database

Build out the database to your needs. Make sure each entry contains the information you want to track. This could include any of:

  1. Bedtime and wake-up time — Note the times you go to bed and wake up each day. This helps track consistency in your sleep schedule.
  2. Sleep latency and disturbances — Record how long it takes you to fall asleep and any disruptions during the night, such as waking up or tossing and turning.
  3. Daytime activities and habits — Document activities that might affect your sleep, including exercise, caffeine or alcohol consumption, and any stressful events.
  4. Mood and energy levels — Track your mood and energy levels throughout the day to see how they correlate with your sleep patterns.
  5. Sleep quality — Reflect on how rested you feel in the morning and the overall quality of your sleep.

In my case, this looks like this:

A sleep quality database in Notion, table view

Let’s now go over the individual columns I used for my database entries:

1. Entry date

The first column is the date, whis also serves as the name for each entry. Type @today to get today’s date.

This tag is relative by dafault in Notion, and has a reach of about a week (i.e. it then changes to “yesterday”, then “last Wednesday” etc.) More than a week, it then changes to showing the actual date. You can change the relative setting by right-clicking @today and adjusting date format settings:

2. Bedtime

This is a simple text input. I just chose the 12-hour format for consistency.

3. Hours of sleep

This is a number field. Click the top line > Edit property to change the format and add the fancy progress bar (8 is max) helping you visualize if you got the recommended amount of sleep. “Divide by” is set to 8 as that’s my target sleep length.

You can copy the number from you smartwatch’s sleep score panel.

4. Sleep quality (aka sleep score)

Like in Hours of sleep above, this one is a sleep score (1–100) that I just copy from my smartwatch.

For this one, also click the top line > Edit property to add the fancy green progress ring (100 is max) helping you visualize if you got the recommended sleep quality. Make sure “Divide by” is set to 100 as that’s the highest sleep score on most smartwatches.

5. Bedtime

This is time I went to bed and tried to get some sleep (not when I actually fell asleep.)

6. Alcohol intake

Text input. Enter anything worth mentioning, especially if consumed in the evening.

7. Caffeine

Likewise, text input. Enter anything worth mentioning, especially if consumed in the evening.

8. Screen time

Text input. Enter anything worth mentioning, especially if this was screen time or social media in the evening.

9. Evening meal

Text input. Enter anything worth mentioning, especially if it was a heavy meal consumed in the evening.

10. Sugary snacks

Again, text input. This one is especially important for me personally. Sugar before bedtime tends to disrupt my sleep more than alcohol and caffeine combined.

11. Exercise, Stress level, Other notable events

All text inputs.

Add any other columns you think would be needed to track your habits (e.g. meditation, medications, etc.)

Averages

As an extra step, you can click the calculate button under a column to calculate the averages or medians for a specific column. This makes sense especially for sleep time and sleep quality information.

Adding an entry

To add a sleep diary entry in the morning, simply click the blue New button in the top right corner. A side panel will appear where you can make an entry for you last night’s sleep, like so:

No need to get verbose. Just keywords and numbers.

Notion AI as sleep disruptor detective

The data from your sleep diary can help you make informed adjustments to your sleep habits and sleep environment. This can involve changes like adjusting your bedtime, reducing caffeine intake, or improving your bedroom environment.

Importantly, one day’s entry won’t tell you much. The point is to track your habits over a longer period and try to see what exactly and consistently disrupts your sleep. This is where AI will help a lot, helping you identify bad habits and disruptive patterns.

Once you have tracked your sleep quality for a couple of days, you can ask Notion AI to identify the reasons behind your bad-sleep nights.

Use the notion AI — click the “star” icon in the bottom right corner, or click Ctrl+J to start the chat. To make sure the AI model focuses on the sleep diary exclusively (rather than all your notes in Notion), specify it in the prompt by directly referring to the database using the @ symbol, e.g.:

Please have a look at my @Sleep Diary.

Remember it’s a conversation, se feel free to ask anything, and use follow up questions if you want to find out more. Try some of these for a start:

Why did I sleep badly yesterday? 
Why did I sleep badly on 8th of July 
What were the main reasons for my bad sleep between 1–8 August 
Recommend tips for improving my sleep 
What's my worst habit before sleep? 
Did I sleep badly every time I drank coffee?

Here’s a short demo:

Notion AI sleep coach in action (bogus data)

Please mind this is not my real sleep pattern journal. It’s a completely fictitious sleep diary.

Enjoy, and sweet dreams!

If you liked the tips, buy me a coffee to keep me going, thanks!

Related

The art of the Almost-Made-in-America label

The art of the Almost-Made-in-America label

Major brands across tech, fashion, and home goods are employing creative labeling strategies to downplay the "Made in China" origin of their products, instead emphasizing design and brand heritage from Western countries.