Action Group

Draftotion

Posted by FlohGro, Last update about 1 year ago - Unlisted

created by @FlohGro / more on my Blog

Draftotion Introduction

this introduction is not completed - it might miss important points but should be sufficient to get Draftotion up and running. It explains the content of the Action Group and how to use it

If you have any questions reach out to me

Setup

After you installed the Action Group you can start using it - no need to configure anything in the included Actions.

Authentication

When you run one of the Actions the first time, you need to authenticate Drafts for Notion.

During the authentication you will be asked which pages / databases / workspaces you want to share with Drafts. You only need to allow access Drafts to the Databases you want to use this Action Group with.

The only important thing to know is: If you want to add tasks to a database that contains relations to another database, you might want to share those with Drafts, too. Not sharing the related databases with Drafts makes it impossible to add the relations as metadata from Drafts.

The quick and dirty soultion: allow Drafts to access everything in Notion, but you can also start small and add access to other pages / databases later.

To change the pages Drafts can access, go to your Notion Settings → My connections → click on the three dots next to Drafts and select “Access selected pages”.

Action Descriptions

Draftotion contatins a few actions that will be described in the following subchapters

Draftotion

This Action contains the JavaScript code that the Actions of the Action Group use. If you run it, nothing will happen since no functions are called. All other Actions in the Action Group include this Action and call functions that this Action contains in the Script steps.

There are two Script steps in this Aciton:

Draftotion.js - the main script for this Action Group containing all the functions related to the Notion API

chrono.min.js - a library / script file for natural date parsing in JavaScript by wanasit on GitHub; this is used to parse dates as due dates for the created tasks. It is designed to handle most date/time format and extract information from any given text:

Today, Tomorrow, Yesterday, Last Friday, etc
17 August 2013 - 19 August 2013
This Friday from 13:00 - 16.00
5 days ago
2 weeks from now
Sat Aug 17 2013 18:40:39 GMT+0900 (JST)
2014-11-30T08:15:30-05:30

note: this will parse every date related text (e.g. if you type “now” it will return the current date & time) if a task gets an unexpected due date in Notion check the line in your draft and try to think like a computer :D

copy Id of selected Item

This Action displays a prompt with the titles of all pages and databases Drafts can access in Notion. The Notion Id of the selected item will be copied to the clipboard

open selected Item

This Action displays a prompt with the titles of all pages and databases Drafts can access in Notion. The selected item will be opened either in the Notion App or on the web depending on the platform you’re using and if the Notion App is installed or not.

create tasks with date

This Action considers each line of the current draft as single task.
It will first ask you for the database in your Notion account where the tasks should be added to.

For each line in the draft it tries to find a date in it (e.g. tomorrow,… see examples above) and add this as due date to the created task. The date will be added if the action finds a property in the database that is a date (note: this might cause some trouble if you have several properties in a database that are dates - this could be improved if necessary). Each line will be considered individually so if each created task should have the same due date you need to add it to every line in the draft.
If the database contains a checkbox property this will also be added and set to false

No further metadata (= database properties) will be added to tasks created with this Action.

The current draft will be trashed on success

create tasks with date and metadata

This Action considers each line of the current draft as single task.
It will first ask you for the database in your Notion account where the tasks should be added to.

For each line in the draft it tries to find a date in it (e.g. tomorrow,… see examples above) and add this as due date to the created task. The date will be added if the action finds a property in the database that is a date (note: this might cause some trouble if you have several properties in a database that are dates - this could be improved if necessary). Each line will be considered individually so if each created task should have the same due date you need to add it to every line in the draft.
If the database contains a checkbox property this will also be added and set to false.
Additionally this Action allows you to add more metadata to each created task. It checks the properies of the database and will display prompts with options for the following property types: “relation”, “select”. The Action tries to resolve a relations and the select properties. It will display a prompt where you can set the property for the task (e.g. select a related page).

The current draft will be trashed on success

Miscellaneous

Please note that the code in the Draftotion JavaScript file is not cleaned up! There are several test functions included that I created during development and testing. This is by no means a perfectly designed JavaScript library or someting like that. It might also contain some code that is commented out which was needed during testing :) The goal was to solve the “problems” / requirements.


If you find this useful and want to support me you can donate or buy me a coffe

Buy Me A Coffee


Included Actions

  • Draftotion
  • copy Id of selected Item
  • open selected Item
  • create tasks with date
  • create task with date and metadata
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.