Skip to content

Automating Notion for Better Productivity

Published: at 02:13 AM

The Problem: Repetitive Tasks

Like many developers, I found myself spending too much time on repetitive tasks in Notion, like creating daily notes. I knew there had to be a better way.

The Solution: Automation

I decided to leverage my skills as a developer to automate these tasks. Using Node.js and the Notion SDK, I created a simple script to automatically create my daily notes.

Here’s a simplified version of the script:

import { Client } from "@notionhq/client";
 
const notion = new Client({ auth: <YOUR-NOTION-KEY> });
 
async function createDailyNote() {
  try {
    const today = new Date();
    const formattedDate = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}`;
 
    await notion.pages.create({
      parent: { database_id: <YOUR-DATABASE-ID> },
      properties: {
        title: {
          title: [
            {
              text: {
                content: formattedDate,
              },
            },
          ],
        },
      },
    });
    console.log("Daily note created!");
  } catch (error) {
    console.error(error);
  }
}
 
createDailyNote();