Getting Started with Notion Integrations — with Rust

Sahu
4 min readAug 17, 2024

--

Photo by Rubaitul Azad on Unsplash

All code used in this post is available on my Github: https://github.com/mrsauravsahu/spikes/tree/main/svc/blog-notion-integrations-expenses

If you’ve done any sort of note taking, journalling, or productivity management, Notion always seems to pop-up as a popular choice. It has many features that I’ve come to love over the years of using it — clean writing experience, databases to organize things, available on all my devices and also works offline; just to name a few.

Comment below: What do you use Notion for?

For the everyday user, Notion works great, with their amazing pre-made templates, plus, more from the Notion Template Marketplace. If you want to connect Notion to other services, for example, Slack for communication, or Calendly to create calendar updates, the Notion Integration Marketplace has you covered.

Notion, now also comes with Notion AI features to help you with your drafting needs.

Custom Integrations with Notion

Even with all the available Integrations on the Notion marketplace, if any of those still don’t fit your needs, you can create custom Notion Integrations.

I’d categorize Custom Notion Integrations into two major types —

Custom Pre-made Notion Integrations

There are third party Notion integrations available from a variety of places — one I’d really like to mention is by IFTTT

Hand-written Notion Integrations

You can also create Integrations of your own, with tools like Tray.io or Make, or code it yourself, if you want to get your hands dirty (or ChatGPT it 😉)

When it comes to writing these integrations by hand, you can either write Internal or Public Integrations. Templates available on the Notion Marketplace are just these custom public Integrations, published by companies.

What’re we building?

The use case I’m showcasing in this Blog is for a Custom Internal Integration which manages expenses through a Notion Database.

The Notion Database has transactions which are pushed to Notion from my mobile phone whenever I receive a text message. We’ll run a cli tool locally to parse transactions nightly, but you can easily run this on the Cloud as a CRON job for example — using something like Github Actions.

The Database also has a Notion Chart view, which shows the cumulative spending per month (these are sample numbers and not my spending 😂).

Link to the Sample Expense Database on Notion: https://mrsauravsahu.notion.site

Monthly Spending View for our Expenses

You can also check out my Payobills Project, which does the same thing, but puts all data locally in a self-hosted kubernetes based homelab environment.

To create a Custom Integration, head over to https://www.notion.so/my-integrations; give it a name, select your Associated Workspace, set the Type as Internal, and you can also add a Logo.

Creating a Notion Integration

This will give us a Token which can access various parts of our Workspace once we connect the Integration. So, to connect the Integrations to the Pages/Databases we want to access to — we can use the page settings, which will give access to the Page and all child content.

Connecting your Custom Integrations to your Notion Pages

You can see I’ve added various meaningful properties which will be extracted from the TransactionText. You can view the Database here

Now, we can use the Notion API and parse the transactions with any tool we like. Because these transaction messages are in a standardized format, simple Regex matches will work. But you always have the option of using NLP or even a Language Model like OpenAI’s ChatGPT to do this.

I wrote the tool in Rust, but you can use the language of your choosing. Notion SDKs are also available, but you can always use their REST APIs to query or update data in Notion.

The code for the parser is on my Github (link below)

As you can see the original TransactionText is used to calculate the other fields, and updated back in the Database, which is used to create the Chart as well.

Transactions after parsing

Obviously, the possibilities are endless, but the idea is to familiarize yourself with the Notion API and see what you want to use it for.

--

--

Sahu

All opinions shared are personal and not influenced by my Employer • Senior Software Engineer @ McKinsey & Company