How to : Get weekly emails with my completed tasks from Notion

Alexandre Dubois
6 min readJan 10, 2022

--

Context

In my daily job I use Notion as a way to take meeting notes and also to follow up my tasks. Lately I wanted to implement a “weekly diggest” email of past week completed tasks. The idea was pretty simple: I want to receive every monday morning an email with a list of tasks I’ve completed in the previous week in Notion.

1. Update my Notion database

To do so, I firstly added a new property in my Notion database and called it “Completed date”. This new property is based on the following formula: if task status = “Completed” then “Completed date” = “Last update date” else empty. The assumption behind this formula is when a task is “Completed” then I do not update the task afterward otherwise the “Completed date” will be recalculated.

if(prop("Status") == "Completed 🙌", prop("Last update date"), fromTimestamp(toNumber("")))

I thought this field would be very useful for the automation I wanted to realize but spoiler it was not the case (see later). Anyway this field is still very useful for other processes I have implemented with Notion.

2. Select the good tool to automate my process (Zapier or Integromat)

I needed to decide which tool to use to run automatically this workflow.

Notion module in Zapier and Integromat

I wanted to use Zapier since I already use it for other automations. But very quickly I found out that the Notion module in Zapier (that is the same for Integromat) is far from being perfect. For instance:

  • Notion module in Zapier was not exposing all the fields from my Notion. I read that formula, relations, mutli-select fields were not supported by Zapier yet (remember my “Completed Date” is a formula)
  • Notion module in Zapier and Integromat has limited functions to interact with Notion and I wasn’t able to see how to leverage these functions to achieve my goal.

Then to move forward I needed to rely on Notion API itself and found a way to connect this API to my automation tool. For this I decided to use Integromat for it HTTP module, I did not find a free equivalent in Zapier.

3. Connect Notion with Integromat

Notion API

Hopefully Notion provides a very comprehensive API documentation.

Test Notion API in Postman

  1. Get your Notion Credentials (token). To use Notion API the first thing is to create API credentials from Notion. It has to be done from the web version of Notion. Go to “Settings and member” > “Integration” > “Develop your own integration”. When a new integration is created you can retrieve your Notion token.
  2. Find your database id: You can find your this ID by looking at the Notion url, it is the idea after the domain and before the “?” : https://www.notion.so/YOUR_DATABASE_ID?v=eae568cd3eec41a59039203e67377c59
  3. Share your database with your new Notion integration: by clicking on top right button “Share” in your database page and enabling your new integration to access this database.
  4. Set up Postman request: URL to query a DB is : https://api.notion.com/v1/databases/YOUR_DATABASE_ID/query. It is a POST request (not a GET). In the authorization you select “Bearer token” and provide your Notion token. In the Header you need to provide the following parameters : Notion-Version = 2021–08–16 (should be your Notion Version of course) and Content-Type = application/json
  5. Provide filters. In my case I wanted to retrieve from my Notion db only the tasks completed during the past week. This is where by reading the Notion API documentation I realized that my custom field was not ideal. In fact, filtering on formulas in the API does not provides as much option as filtering on directly dates . Even if the output of my formula is a date then Notion considers it as firstly a formula. Hopefully the filtering options on dates are pretty good then it was easy to filter on the “past week” tasks + the tasks that are completed as shown below (body of my API request):
{        "filter": {            "and": [                 {                   "property": "Last update date",                   "last_edited_time": {                          "past_week": {}                 }},                 {                   "property":"Status",                   "select": {                           "equals": "Completed 🙌"                 }}]}}

Set up the HTTP call in Integromat

Setting up the HTTP call in integromat is pretty straightforward once you have done the job in Postman. Nevertheless I got a small issue that delayed me a bit on this part. I copy pasted my request body from Postman directly into the field “Request content” from HTTP module of Integromat and it kept the json formatting with spaces and tabs. Strangely this formatting caused an issue when processing the request in this HTTP module. Then I removed every tab spaces and it worked correctly.

4. Process API data

The code way

One option in the HTTP module is to directly “parse response” which is great because it breaks down for you the JSON format of the response. But in my API response I got several tasks completed then several nodes of data, so when I naively used the parsed data I realized that I was getting only the first task of API response. It was not what I wanted but dealing with JSON is quite easy with python code so I decided to look into this option. To make it work I needed to uncheck the “parse response” and to parse the data directly with python.

To use python in Integromat you need to use 1Saas.co module. This module enables you to run a python script directly in your integromat process. Then I wrote this code to manage the API response :

import pandas as pdnull = Nonefalse = Falsemy_json_df = {{2.data}}df = pd.DataFrame(my_json_df)results = ""for attr in df['results']:results = attr['properties']['Projects']['title'][0]['plain_text'] +  ", " + resultsresult = {'data': results}
Integromat flow — code option

Using this 1Saas.co module was not perfect in my opinion because:

  • 1Saas.co fremium enables you to have only 25 executions in total (not monthly) then you need to pay 10$ / month
  • It is not no-code
  • Results could be provided only one way

After online research I found a better no code way to do it.

The no-code way (preferred option)

Actually this case of managing several nodes of data from an API is obviously something that Integromat can do for you. There is a native module called the “Iterator” that can helps you to iterate on you several nodes of data.

  1. To start you need to select “parse response” option in the HTTP module
  2. You add an iteration module and select the array on which you want to iterate
  3. In my case I wanted after my iteration to combine all my tasks names in a string. To do so you can add an “text aggregator module”. In my case I used the following row separator “</br>” because in my email (in html format) I wanted to pile up all tasks on top of each other.
Integromat flow — no code option

5. Set up the email automation

You need to connect to your gmail account by following these steps : https://www.integromat.com/en/help/app/google-email

This step is long but pretty simple.

Conclusion

This small project was very fulfilling as a very first no code experience. From this I’ve learnt a lot of new things that I could re-use easily such as how to use Notion API, how to call an API from Integromat and how to manage iterations in Integromat.

I’ve realized after few weeks that having this email dropping in my mailbox at every beginning of the week is very fulfilling in a way it helps to realize how much I’ve done in a week.

Knowing this I think one my next challenge would be to develop more dashboards around this completed tasks.

--

--

Alexandre Dubois

I share my journey about improving productivity, mastering Notion, understanding cryptos and building ideas and business.