This project uses Google Apps Script to interact with the Notion API. It automatically adds daily TODO tasks to Notion at midnight if the task was completed on the previous day.
- Daily Automation: Adds new TODO tasks at midnight every day.
- Task Verification: Only adds new tasks if the previous day's tasks are completed.
- Google Apps Script Integration: Runs entirely on Google Apps Script.
- A Notion account with access to the relevant database.
- Google Apps Script set up with access to your Google account.
- Notion API integration with a token and database ID.
This project uses Google Apps Script to interact with the Notion API and automatically add daily TODO tasks to a Notion database.
What changed: the script now reads Notion credentials from Script Properties and includes helper functions to set/clear them (setNotionConfig, clearNotionConfig). The main function is addDailyTasks().
- A Notion account and a Notion database where tasks will be added.
- A Notion integration (secret token) and the database ID.
- A Google account to run Google Apps Script.
- Create a Notion integration and copy the internal integration token (secret).
- Share the target database with the integration (open your database > Share > invite the integration).
- Get the database ID:
- Open the database in Notion, copy the URL, and extract the ID (the long UUID at the end of the URL).
- Open Google Apps Script (script.google.com) and create a new project.
- Copy the files from this repository into the Apps Script editor (replace the default Code.gs with
コード.jscontents if necessary).
Two options to set credentials:
-
Option A (recommended): Run the helper from the Apps Script editor once.
- Open the script in the editor.
- In the left file list open
コード.js, then open the "Executions" / run menu and choosesetNotionConfig. - When prompted, pass your Notion token and database id as arguments: e.g. run
setNotionConfig('secret_api_key', 'your_database_id')in the editor's function runner.
-
Option B: Set Script Properties manually.
- In Apps Script, go to Project Settings (the gear icon) -> "Script properties".
- Add properties:
NOTION_API_KEYandNOTION_DATABASE_IDwith their values.
If credentials are missing, addDailyTasks() will throw a clear error telling you to set them.
- In the Apps Script editor, open the Triggers page (left sidebar > Triggers).
- Add a trigger:
- Choose function:
addDailyTasks - Deployment: Head
- Event source: Time-driven
- Type of time based trigger: Day timer
- Select time: Midnight to 1am (or your preferred time)
- Choose function:
- After setting credentials, run
addDailyTasks()manually from the editor to test. - Check the Executions / Logs for errors and verify new pages in your Notion database.
Open コード.js and edit the todo array inside addDailyTasks() to change the tasks and genres that will be added.
- If you see permission errors, make sure the Notion integration is invited to the database.
- If the script throws "Missing Notion configuration", set the properties using
setNotionConfig(...)or the Script Properties UI.
Contributions are welcome. Open a pull request with changes and tests where appropriate.