Skip to content
Stoic Coder

Syncing from reMarkable 2 to Notion

5 min read

reMarkable

TLDR

Use this (Google AppsScript) to automatically sync your notes via Gmail to Notion.

Motivation

Recently I started working with Notion and also bought the reMarkable 2. As much as I love both of these tools I was lacking a way to integrate both with each other. The reMarkable 2 has the great feature to convert handwritten text and send it via email. I wanted to have these converted notes inside my notion database, but couldn't find a full solution on how to achieve this on the web. Here I want to share the solution that I am using for now.

Idea

  1. The handwritten notes are send via email to your Gmail automation account by the reMarkable device
  2. A rule in gmail sets the label 'NotionToSync' on the incoming email from the reMarkable
  3. An AppsScript is syncing the note directly into a chosen Notion database

Overview

To set this up, we need the following steps:

  1. (Optional) Setup a new gmail account dedicated for this automation (you may choose to use an existing account if you use Gmail, but for me this separation feels cleaner)
  2. Create two labels in your Gmail Account 'NotionToSync' and 'SyncedToNotion'
  3. Setup a rule in gmail to label each incoming email from the reMarkable with 'SyncedToNotion'
  4. Setup a Notion database and dedicated integration
  5. Setup the AppsScript to do the Magic

Let's go through these steps one by one (starting with the second - we will not cover google account creation here):

Create Labels in Gmail

In the sidebar menu search for the plus icon ️'+' with the caption 'Create new label' (usually it's at the bottom of the top section in the sidebar).

Gmail Create Label

Then enter the name for your label 'NotionToSync' and click create. Repeat this for 'SyncedToNotion'. You can also choose different labels, in this case you only need to remember to adjust them in the AppsScript at the end.

Setup rule in Gmail

In the sidebar click on the '⚙️' in the top right corner and then 'See all Setttings' to go to your Gmail account settings. Then select the 'Filters and blocked addresses' tab. Click on 'Create a new filter'. In the 'From' field enter 'my@remarkable.com'. Click 'Create Filter'. Then you can select which action to execute when a new email comes in that matches the filter. Select 'Apply the label:' and select 'NotionToSync'. Then click again 'Create Filter'. The result should look like this:

Gmail Rule Settings

Setup Notion database and Integration

In Notion create a new database, that you can name how you like to always know how to find it. I called mine 'reMarkable Automation'. Now setup the integration: Go to 'Settings & Members' -> 'Integrations' -> 'Develop your own integration'. There create a new integration with any descriptive name and allow to 'Insert content' and 'No user information'. After creating the integration you will be able to retrieve the secret for this integration. Click on show and copy it somewhere for later.

Notion Secret

We also need the id of the database where our notes get posted to. If you use notion in the browser and open the database as a page, your url will look somewhat like this https://www.notion.so/f453e55c7fa4482985015cad126a5839?v=82bac12a7a8e4fd3b52a384a0205fb92. The part f453e55c7fa4482985015cad126a5177 is your database id. Copy it for later. In case you use the desktop version, you probably need to select the menu in the top right and select 'Copy link' and paste it somewhere to retrieve the same information.

Notion Copy Link

Setup the AppsScript

Final step to put everything to work. Go to the Apps Script, click on 'Start Scripting' if prompted (you might need to create a Google developer account first). Make sure you are logged in with the Google account that you want to run this automation with (for me it is the one I created in step 1)! Create a New Project and copy & paste the code from here (gist).

const GMAIL_LABEL_NAME = 'NotionToSync';
const SYNCED_LABEL = 'SyncedToNotion';
const gmailToNotion = () => {
const label = GmailApp.getUserLabelByName(GMAIL_LABEL_NAME);
const successLabel = GmailApp.getUserLabelByName(SYNCED_LABEL);
label.getThreads(0, 20).forEach((thread) => {
const [message] = thread.getMessages().reverse();
postToNotion(message);
thread.removeLabel(label);
thread.addLabel(successLabel)
});
};
function postToNotion(message) {
const url = 'https://api.notion.com/v1/pages';
const body = {
parent: {
type: "database_id",
database_id: "<Your Target Notion Database Id>",
},
icon: {
type: "emoji",
emoji: "📝"
},
children: [
{
object: 'block',
type: 'paragraph',
paragraph: {
rich_text: [
{
type: 'text',
text: {
content: message.getPlainBody()
},
},
],
},
}
],
properties: {
Name: {
title: [
{
text: {
content: message.getSubject(),
},
},
],
}
}
}
UrlFetchApp.fetch(url, {
method: 'post',
contentType: "application/json",
muteHttpExceptions: false,
headers: {
Authorization: `Bearer <Your Notion Secret>`,
'Notion-Version': '2022-02-22'
},
payload: JSON.stringify(body)
});
}

Replace the database id in the script at <Your Target Notion Database Id> and the secret of the created Notion integration at <Your Notion Secret>. All that is left to do now is to set a trigger of how often this script should be running. Click on the clock in the menu and on '+ Add Trigger'. You can have it run every minute, if you are the impatient type. For me I selected every 10 minutes that this script should run.

Try it

Last step is to try it all out. Send a new converted text from the reMarkable to your Gmail automation account. Wait some minutes or execute the script manually and see a new entry appear in your Notion database. If you type a subject while sending the converted text from your reMarkable, it will have this as a page title in Notion. The default is something like 'Document from my reMarkable'.

© 2024 by Stoic Coder. All rights reserved.
Theme by LekoArts