Do you often use Notion board databases for roadmaps or for your day-to-day todos ? Do you want your tasks to be automatically added to your Apple Calendar when a date is defined ? Hopefully you are on the good repo.
In brief here is a typical use case :
- You add a task in your board database, with a date specified
- This task will be added to your Apple Calendar app
Then if the Notion card got modified or deleted, the changes will automatically be taken into account in the Apple Calendar.
Note : The synchronizations are trigered based on the crontab job you will define.
In this section, I go through all the necessary steps to set up the project on your local machine.
- macOS version 10.5 or later
- tested on python version 3.8.12
- pip requirements can be found here
If the previous requirements are fulfilled then follow these steps :
-
Clone the repository in your desired location
A repository is like a folder on GitHub. This repository contains all the code needed to run the project.
To get the repository on your computer you need to clone it, this will download a copy of all files on your computer. To do so :-
Open up your Terminal application
-
Check if git is installed :
git --version
You should get output like :
git version 2.32.0 (Apple Git-132)
Otherwise check the official documentation to install the git client.
-
Move to your desired location
Inside your terminal app cd to the location where you want to clone the repository
As matter of example :
cd /Users/sprietthibault/scripts/
-
Clone the repository
git clone https://github.com/thibaultspriet/SyncNotionCalendar.git
-
-
In your python environment run :
pip install -r requirements.txt
You will have to create an internal integration in the Notion app. If you want to know how to get the Notion integration token, more info here. Here is a simple step by step tutorial to create an integration and get the corresponding token. This token will be needed for what follows.
-
From Notion go to settings & members.
-
Then click on the link where you can read "Develop your own integrations" It should open up a new window inside your browser. From here you may need to connect to your account.
-
Click on new integration Give it a name and associate it with a workspace. Finally click submit.
-
You should be able to show you integration token. Keep it somewhere you will need it later.
The final step is to share your integration with the database you want to link with Apple calendar. To do so, come back to Notion and open your database as a page. In the top right corner, press share, click on the text box and you should be able to select your integration. Finally, click invite
After that, you need to create a config file in the root directory of the project. Name it config.ini and fill it as follow :
[GLOBAL]
NOTION_TOKEN=<your notion integration token>
APPLE_CALENDAR=<Name of your Apple Calendar>
[DATABASES]
<your chosen database name 1>=<notion database id>
<your chosen database name 2>=<notion database id>
You can add as many as you want DATABASES entries.
Once you have done all the previous tasks, you only need to create a crontab job to run your task with the frequency you want.
Firstly edit this script with your python interpreter path and your actual path to main.py
๐ก To know your python interpreter path : which python
Then open up a terminal and create a crontab job as follow :
crontab -e
It will open a vim editor.
Write : * * * * * cd <absolute path to the project> && ./syncNotionCalendar.zsh
You can edit * * * * * to configure when to run the job.
๐ก use this site to generate the command.
As matter of example, I run my script once per hour everyday between 8:00 am and 10:00pm. My crontab file look like :
0 8-22 * * * cd ~/scripts/notion-ical && ./syncNotionCalendar.zsh
In case you have a question, feel free to email me to [email protected] or open an issue.