Notion Rollover TODOs
What is it?
A script that stores and archives your done TODOs from a Notion database. It runs on a daily schedule thanks to Netlify Scheduled Functions.
Why?
I want to keep track of done TODOs over time. I might also want to see some stats in the future 🤓.
Caveats
- If you add any new properties to your TODOs database, you need to also add it to the TODOs archive database.
- If a done TODO has children pages, these won't be copied to the archive database. If there's interest in this I can make it happen in the future but for now, I don't need it.
Setup
A. Notion
My current TODOs format is a Notion inline table (database). This is a nice setup since it allows you to add various properties to each TODO and even children pages if you like.
The gist of the Notion setup is that you want to create two of these inline tables (databases), one for your TODOs and onoe for your TODOs archive. Once that is done, we need to set up an integration and connect it to your databases ✅
- Create a new Notion page with any icon, cover and title. I'd suggest simply using "TODOs" as the title.
- Add a new "Database - Inline" with any title to this page.
- Add a few properties to the database. At a minimum, the script needs a
Done
checkbox property. You can use any other properties, my current setup is:Name
text,Priority
select,Resume On
date,Due Date
date,Done
checkbox. Note your database_id. You'll add this in step B.4 asNOTION_TODOS_DATABASE_ID
. - Now create an integration and connect it to your new TODOs database. Note your "Internal Integration Token". You'll add this in step B.4 as
NOTION_API_KEY
. Now you have a working TODOs database 😄 - Let's create the TODOs archive database. To do this, simply duplicate the TODOs page and name it anything else, e.g. "TODOs Archive". Note your database_id. You'll add this in step B.4 as
NOTION_TODOS_ARCHIVE_DATABASE_ID
. - Connect your integration created in step A.4 to the duplicated TODOs archive.
B. Netlify
Basically you want to create a fork of this repo, connect it to Netlify and add the relevant environmental variables ✅
- Create a fork of https://github.com/shaunsaker/notion-rollover-todos.
- Connect the forked Github repo to Netlify.
- Add a build hook to your Netlify site. Note this url as you'll add it in step B.4 as the
NETLIFY_BUILD_HOOK_URL
. - Add the following environmental variables to the build settings:
NODE_VERSION=18.12.1
NETLIFY_BUILD_HOOK_URL=?
NOTION_API_KEY=?
NOTION_TODOS_DATABASE_ID=?
NOTION_TODOS_ARCHIVE_DATABASE_ID=?
- Crack a beer, your're done 🍻
Modifying the code
Feel free to modify the code as you see fit. The script itself can be found in ./src/main.ts
and the netlify scheduled function handler can be found in ./netlify/functions/notion-rollover-todos.ts
. Simply push the new changes to master
for the new build to take affect 🙂