Skip to content

carseven/daily-email-notion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Daily e-mail from notion database

License: MIT LinkedIn

Table of contents

About The Project

I ❤️ Notion! I use it daily to organize my whole life, take notes, my reading list and a ton of other things.

My routine is simple. I check every morning my daily to-do's in Notion. However, I would always like to have a daily email every morning with all the tasks. I think it would help me to focus more and have a mental map of the day. Moreover, it would avoid getting distracted in lower priority tasks.

With the new official Notion API, this idea is finally a reality in my life. This project retrieves the data from a database where I organized all my tasks, generates a simple HTML template like the ones we see in the images below and sends an email using Github actions. Simple and effective.

email-result-black email-result-white

Configuration

Installing dependencies

Update pip:

python -m pip install --upgrade pip

Install dependencies via pip:

pip install requests python-dateutil

Notion

Follow the official Notion api getting started guide here to learn how to set up notion integrations.

⚠️ For having access to relation database columns/properties, you must share the integration in the related database.

Tokens secret file

Generated dailyEmail/tokens.py file with SECRET dictionary with the following properties:

  • notion_test_token: Notion integration token secret key.
  • database_id: Notion database id, extracted from the database notion url. Example:
    https://www.notion.so/myworkspace/a8aec43384f447ed84390e8e42c2e089?v=...
                                    |--------- Database ID --------|
    
  • gmail_password: The password of email_from email.
  • email_from: Email address is going to send the email.
  • email_to: Email address is going to receive email.

Example:

SECRETS = {
    'notion_test_token': '',
    'database_id': '',
    'gmail_password': '',
    'email_from': '',
    'email_to': ''
}

⚠️ Make sure to include this file in the .gitignore to avoid upload sensible information to the repository.

Github action

  1. In local, encode the content of the tokens.py using base64:
    base64 ./dailyEmail/tokens.py
  2. Copy and paste the encode output into your GitHub secrets. Use the name $TOKENS_PY_FILE.
  3. The github action runs at 5:30 AM every day. Change the cron schedule expressions if you want it. Web for cron schedule expressions calculation
    schedule:
        - cron:  '30 5 * * *'

Usage and personalization

Filter and sort queries

For changing the query filtering or sorting, just modify the query dict following the api reference indications.

If no filtering or sorting is need it, just delete the query dict from the dailyEmail/todays-schedule-email.py script.

Example:

query = {
    "filter": {
        "and": [
            {
                "property": "Done",
                "checkbox": {
                    "equals": False
                }
            },
            {
                "property": "Due",
                "date": {
                    "before": tomorrow
                }
            }
        ]
    },
    "sorts": [
        {
            "property": "Due",
            "direction": "ascending"
        },
        {
            "property": "State",
            "direction": "descending"
        }
    ]
}

Email template personalization

Table information: By default the email table will print all the columns/properties from the notion database. If we need just to print some of the columns set the dbProperties list with the name of the columns we want to print.

Be aware of the order, because the dbProperties list sequence will be use. We could re-order the list if we want.

dbProperties = ['State', 'Task', 'Api-projects', 'Due', 'Kanban - State', 'Priority', 'Type']

Style: If we want to change the style of the table you could modify the style string from dailyEmail/html.py. In my case, I use the following tutorial as a reference

Contributing

All contributions are welcome👌🏼.

Just send a PR or open an issue💡.

Also, contact me directly📲!

References

Releases

No releases published

Packages

No packages published

Languages