Skip to content

willesq/SyncNotionCalendar

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated synchronization of Notion databases and Apple Calendar

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 :

  1. You add a task in your board database, with a date specified
  2. 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.

Installation

In this section, I go through all the necessary steps to set up the project on your local machine.

Requirements

  • 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 :

  1. 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 :

    1. Open up your Terminal application

    2. 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.

    3. 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/
    4. Clone the repository

    git clone https://github.com/thibaultspriet/SyncNotionCalendar.git
  2. In your python environment run :

    pip install -r requirements.txt

Notion integration

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.

  1. From Notion go to settings & members.

  2. From the pop-up click on integrations

  3. 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.

  4. Click on new integration Give it a name and associate it with a workspace. Finally click submit.

  5. 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

Config file

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.

Crontab job

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

Questions

In case you have a question, feel free to email me to [email protected] or open an issue.

About

Automate synchronization between Notion databases and Apple Calendar

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.4%
  • Shell 0.6%