today i'll show you how you can sync your health metrics from apple health straight to your notion you'll be able to see all the data you have in your apple health directly in your notion databases if you're the one who loves to keep track and analyze your health metrics like body mass sleep quality or workouts and you want to integrate them into your major notion ecosystem this solution is one of the best currently out there so how is it going to work let's say you have some health metrics that you want to track if you have smart scales it can be your body mass data for example it can also be your sleep quality data that you can track with devices like apple watch for example when you wake up when you go to bed your total sleep time and things like that you can also track your workouts so in the end all this data goes to apple health and what we want is this apple health data to be stored and synced to our notion database and we want to do this every 24 hours so that at every point we end up with the most recent data in the end we will end up with some kind of a notion table that has days as records and different metrics as page properties for this demo i'll use three metrics as an example the body weights total time sleep and time wake up let's go so what do you need to make it work first of all you'll need some data in your apple health for exporting next you're gonna need a health auto export app which we'll be actually using for exporting the apple health data next we're gonna need the automate. io account with multi-step bots plus webhooks for processing this data in the end we'll only need one board so it's not as difficult as it may seem and we also need the notion database we will will be storing the health matrix as for the notion setup we'll first need to set up the table where we're going to be storing our data from apple health this table will contain the days as records and health metrics as properties so that each day has its own set of metrics recorded for this day to actually process and send data from apple health i use health auto export mobile app this app supports automatic and periodic syncs with api so that's what makes it a perfect choice for our use case in the end you'll need to download this app and connect it to your apple health and we'll be using this app to send data from apple health to notion as it's pretty easy to set up and use in automated io we're going to be accepting the data from webhooks so in the end you'll need to have a single bot that can receive webhook data format this data and update the notion database i think you can use zapier for this purpose but i'm used to doing the automations in automate. io so that's why i'm sticking to it we start by creating a bot with the trigger of webhooks and incoming hook so now we'll need to set up the actual web hook we press setup webhook button and now we need to use this webhook url and set it up in our alt auto health export mobile app so after we copied the webhook url we need to go to our health auto export app and we need to go to automations section and api export option here we will need to paste the webhook url in the configuration so simply copy the webhook address from automated io and put it there enable the automatic syncing export format should be json the period should be today and aggregation days since we want to make a sync on a daily basis this is the type of configuration that would match our use case and next we want to select categories for exporting and since for this demo we're using the body weight and sleep data we select sleep analysis and weight and body mass categories you can also include workouts in this integration later on so after you set it everything up you can test the connection so we press i'm done in automated io window and we can press test connection in api health export app and now we can see that the data from health expert app was fetched to automated io we can see different metrics time first sleep time and bad source we can see the dates and we can also see the bodyweight metrics down below if everything looks good if all the data is here we can press looks good and now we can work with this data within automated io interface to put it to format it and put it in our notion the next step in the automation is to update our notion database with the data we have from the webhook for this we'll need to select an action at the app notion and update database action for this demo we will assume that the notion records for days they already exist so we just need to update them with proper data we don't need to create new records but if we were to create new records based on the data it would be possible although it might not be the best solution simply because if we create a record every time the bot is triggered then we might end up with multiple records for the same day simply because the data is synced asynchronously and can lead to a duplication of records updating is much more flexible uh also when you keep track of other things in your daily calendar maybe tasks or yeah different habits habit tracker things like that so i would recommend having a different automation that would create daily records and use this bot simply to update so we'll need to choose the [Music] the database in our action the daily tracker so the next important step is to figure out which record to update right so we need to update the right records so there needs to be an extra step before this one and we'll need to figure out uh which records to update so for this we will use the search function and we will search item by property so what we need to do is we need to find uh what's the record that is today and only then update this record so in order to figure out what's the day which has the today's date we need to add extra step to get the date for the current day this can be used by the timer action get current date time we will get only the date and this step will just give us the current date which we'll use to search the right item in our database we select our database and we put this current date as the filter parameter so if the date of the notion record matches the current date matches today then we will update it which is what we want so after we located the record with the current date we need to use the item id to update it right and the first the first thing we will update is the body weight so we'll need um in all this webhook data we'll need to locate the data that corresponds to the body weight and use use this property in our update database notion action so this property is called data metrics last data last quantity so this will give us the latest value of your body weight recorded and we will just use it to put it in our notion with this setup we can test it so we can turn on the bots and within the api export app we can simply open it on the api export page and it will send another web hook right and we take a look at our notion database and the body weight was synced successfully if we take a look at our bot activity we can see that it first received the data then it got the current date date for searching the right notion record then it's found the right notion record with the date and updated it with our weight data so this is how you set up the web hook integration from apple health to notion another health metric that we want to think is our total sleep time and in order to sync it to notion we first need to find out what uh what this metric is in our web hook data so this metric is called data metrics first data last sleep and uh we simply need to do the same thing as with body weight drag and drop it to our update database item in notion action and it will sync the data from the web hook to notion we can test it out again to test it out you simply need to go to your health export mobile app and open it right now it works like that if it doesn't work you just need to press test connection button and it will send the test webhook for this integration so now it's updating the database item and yeah we currently can see that both body weight and total time sleep was synced to our notion daily tracker and if you also want to keep track of the time you go to bed fall asleep or wake up it's also possible to do although it will require some data processing and data formatting extra steps uh because uh all the times from apple health uh of this matrix they are recorded in date and time format so if we want to store them as the number like this as um yeah the the number with decimal points will need to process it and format it in a certain way uh storing them as number has multiple benefits one of the main ones is that you can plot these numbers on the charts and to see like the dynamics of how it changes over time when if you have it stored just as a date and time you cannot do it at the moment so if you want to do this we will set it up in automated taiyo for this one we will need to set up the formatting uh we will be using awake time right the the time we woke up as our last metric so we will first format it in the proper way for this we will use the formatter action format date format date option and we're going to use the data from our webhook that corresponds to that and this data is called data metrics first data last sleep and so this is when you woke up basically and first we want to format it in the desired format we will use the hours formatting option automated io to get the number of hours in this date then we're going to get the number of minutes from this date so we'll use again the custom value and format id in minutes for extra processing of minutes we will use the math action to multiply the minutes by this magic number and why are we doing it because for example if you woke up at 7 30 a.
m then the number of minutes will be 30 so what we need to do is we want to first divide it by a hundred so it's so it's less than one so it's not the whole hour because the single digits will be used for the whole hours and then we want to multiply it by 1. 67 so that it's in within the range of 0 to 100 because all the minutes go from 0 to 60 but this way it will transform nicely to 0 to 100 formatting and after that we will simply add the number of hours to the number of minutes and we get this sum of numbers and this sum of numbers will be our time that we woke up so what we need to do is we need to put it in our notion uh update database item action we can save it and test it to see how it looks and now we can see that our time we woke up was added to our notion records in the number format it's not the date and the time format so what this number basically means is that today we woke up at around 7 25 um a. m and this we can use this further to measure the average time you wake up and perform different calculations on this number that's it with this board enabled all your data will be synced to notion from your apple health automatically every 24 hours and will be stored in the notion database like this the one last thing we have to do is to add extra step uh into this process which is related to ios system due to its restrictions it cannot uh export and sync data on the background automatically when the phone is locked so in order for the api health expert app to do this your phone needs to be unlocked or you need to be simply inside the health export app so what we'll do is we'll use the apple shortcuts automation to open our health export app every day at certain time in order to make sure that the sync happens as it should so in order to do this we need to go to our shortcuts app automation section and create new personal automation that trigger will be the time of day and you can simply use the any time of day you want let's say what 11 30 a.