Links

Add to do list in page

Tags: #notion #todo #page #snippet #naas_drivers
Author: Florent Ravenel
Last update: 2023-04-28 (Created: 2023-04-28)
Description: This notebook explains how to add a to do list in a Notion page using naas_drivers from a list.
References:

Input

Import libraries

from naas_drivers import notion
import naas

Setup Variables

  • to_do_name: Name of your to do list
  • to_do_list: List of actions to do
  • notion_token: Notion token shared with your database
  • page_url: Notion page URL or ID
# Inputs
to_do_name = "My first todo:"
to_do_list = [
"Task1",
"Task2",
"Task3",
]
# Outputs
notion_token = naas.secret.get("NOTION_TOKEN") or "YOUR_TOKEN"
page_url = "https://www.notion.so/naas-official/Test-93655d0408c14923bcd305dd4599cda9?pvs=4"

Model

Add to do list

page_id = page_url.split("/")[-1].split("?")[0].split("-")[-1]
page = notion.connect(notion_token).page.get(page_id)
page.paragraph(to_do_name)
for to_do in to_do_list:
page.to_do(to_do)
page.update()

Output

Display result

print("To do list updated in your page:", page_url)