Using Notion with Drafts

notion

Using Notion with Drafts

NOTE: Notion integration requires Drafts v31 or greater. The Notion API used for integration is still in beta, as such aspects of this functionality may change or break and Notion finalizes their API.

Notion is an online project management and information system. Drafts currently two ways to integrate with Notion:

  • Notion action step. Can create new sub-pages, or append to existing pages, as plain text or as to-do lists.
  • Notion script object: Provides a request method which allows you to script calls to the full Notion API, while providing automatic OAuth authenticate flow.

The action step provides a basic, easy to approach way to get your data from Drafts to Notion. Scripting supports advanced integration, for users needing to work with databases and other block types in Notion.

Notion Authentication and Permissions

Like most services Drafts integrates with, Notion uses the OAuth standard for authentication. The first time you use an action that integrates with Notion, you will be redirected to the Notion website and asked to log in and authorize Drafts to use your account.

When authenticating, Notion has an additional step of selecting specific pages in Notions which the integration will be granted permissions to access. It is recommended you give Drafts permissions only to the pages you plan to target with actions.

After you have authorized Drafts, you can add and remove page permissions in the Notion interface:

  • Navigate to the Notion Page you wish to add to the Drafts integration.
  • Select “Share”, then “Invite” and select the “Drafts” integration to allow it permission to use the page.

Permissions are inherited, so granting Drafts permission to access a page or workspace, gives it permission to access child elements of that item.

If “Drafts” does not appear as an option when to invite in your share page, make sure you have run a Notion action in Drafts and successfully authenticated to the correct workspace in Notion.

Notion Action Step

The Notion action step can add text or to-do lists to pages in Notion. Aspects of this step may change, but it’s a start. To get started, install an example action:

By default, these examples ask you to select a Notion page as a target each time they are run. They can also be configured to target a specific page by page ID. See next section on obtaining IDs, and the step documentation for further details on options available.

Obtaining Notion Page IDs

To configure action steps to target a specific page in Notion, you can use the “Select” button in the action step configuration, or obtain a specific Page ID from Notion.

To get a page ID:

  • Navigate to the page in the Notion website or app.
  • Use the “Share” button, and “Copy Link” to get the unique URL for the page.
  • The Page ID is the string of numbers and letters at the end of the URL.

Once you obtain that page ID, you can paste it in an action and change the action to “Assign” the target page.

Be sure the page you wish to target has been invited to the “Drafts” integration (see permissions section above) or the action will fail.

Using the Notion API in Script

For advanced users, Drafts also provides a Notion Script object that allows you to make requests directly against the Notion API. Any API calls can be used, see Notion API docs for information on available methods. This object may add convenience methods for some functions, but right now only has a single request method that allows for arbitrary calls against the Notion API. Example action:

Notion and Markdown/Rich Text/HTML

Notion stores text in its own structured block format. In their own apps and web version, they have tools that convert between Markdown pasted into the interface, and this native block format.

At this time, Notion has not added the ability to convert between this native block format and HTML or Markdown to the capabilities of the API.

It is possible to construct Notion blocks using JavaScript in Drafts (they are just complex JSON objects), and pass those values to the API, but due to the complexity of the format, we do not have any automated tools to do this conversion.

We are hoping Notion adds this capability before the API is final, and we will certain support it to provide a smoother way to pass Markdown and/or HTML to Notion if they do.

10 Likes

Looks like the link for https://scripting.getdrafts.com/classes/notion is not working… or maybe not published yet?

1 Like

Oops, forgot to push the scripting reference updates. It’s there now.

2 Likes

U r the best! Thank u! :smiley::smiley::smiley:

1 Like

Good to see some Notion integrations!

After playing around with these options, I take it neither the “Create Page” or “Append as Text” action steps are capable of creating a new entry / page in a database?

Is that capability on the horizon?

2 Likes

In case it helps, it should be possible now - see “Using the Notion API in Script” above. It is just that you have to do some of the lifting rather than there being a prebuilt action to help.

If there’s a demand and use there for these options in particular, I wouldn’t be surprised if Greg built it into Drafts, or a Notion & Drafts user shared an action to do this based on scripting the interaction.

2 Likes

Understood, thanks! I’ll give that a shot and see what I can come up with.

1 Like

How can I reinstall from 0 actions to create pages in NOTION? I have deleted it from Draft, I have reinstalled it but I can’t get it to ask me again for permissions and authentications in Notion to be able to reinstall it correctly. It always gives me an error.

1 Like

Drafts store account information in Credentials. Visit that section in settings and forget your Notion credentials if you need to re-authenticate for some reason.

You do not need to re-authenticate to change what pages/databaases the integration has access to, however. See information above on inviting the Drafts integration to other content in Notion.

1 Like

Just want to confirm if this update allows for insertion of notes into Notion databases? Does this integration allow for draft notes to be added as new pages (aka new rows inserted) within a Notion database? Thanks!

1 Like

There is a create page example action listed in the original post above, and as noted, you can interact with the Notion API in any way you like via the scripting object. So as long as the API supports an interaction, the Drafts implementation also supports it as it supports interacting with the official API.

1 Like

+1
I agree - that would be very helpful.
For instance in order to be able to create an Actions/Task in an Action Item database.

As noted, it is possible to script updates to databases. I’m working on some example actions to demonstrate. It’s not too easy to have a baked-in action step to update databases, because every database has a different structure so it can’t really be done in a simple way that work work for any database.

4 Likes

Hello, I am trying to use the new action to add a page to the database, but it’s not working.

  • Added integration with Notion<>Drafts
  • Shared DB with the Integration
  • Got Database ID and pasted to the scriptthe (part where you mention YOUR DATABASE ID HERE
    I tried multiple times with different databases, but nothing is going to Notion

Can you help, please?

Databases are not supported by the action step. Only pages at this time.

Databases could be addressed directly with scripted actions.

HI, I created the action you are referring to.
It has stopped working recently - I’m not very experienced in this so I am trying to work out what has changed. It may be the Notion API changes.
Apologies for the problem, if I work out what is wrong I will post an update!

I have updated the action.

I also added a note in the script to check that your database pages title property is called “Name” which is the default. I did not explain this in the last version.

If you changed the default, then you will need to replace “Name” in the script with exact name of the title field.
Hope it works for you !

2 Likes

Its working well, many thanks

1 Like