SmartBlocks icon indicating copy to clipboard operation
SmartBlocks copied to clipboard

Universal Quick Capture for Roam Research Beta

Open mlava opened this issue 4 years ago • 38 comments

✂️ Copy of your #42SmartBlock from Roam

Please download the latest code: Universal Quick Capture for Roam Research.zip

📋 Describe the SmartBlock

This SmartBlock allows you to utilise the excellent Todoist Quick Capture mechanisms as an alternate Quick Capture to the inbuilt Roam Research one. You can capture thoughts, notes and ideas using the Todoist app, popular voice assistants and email into Todoist.

All of that data can now be imported into Roam Research.

✅ Describe any prerequisites or dependencies that are required for this SmartBlock

Roam42 obviously. A Todoist account. This script works with Free and Premium Todoist accounts. Free users can't import comments or attachments (Todoist API limitation). Premium users can also assign a label in their Todoist inbox to only import certain items and not the whole inbox, which is useful if you already use Todoist in its own right.

📷 Screenshot of your #42SmartBlock workflow/template from Roam

image

💡 Additional Info

Import this json file to start: Universal Quick Capture for Roam Research.zip

mlava avatar Jan 19 '21 06:01 mlava

This is great! The only feature I miss is support for todoist dates. Is this information available in the API?

pomdtr avatar Jan 19 '21 21:01 pomdtr

Hi everyone. There have been lots of queries about how this script is intended to work, and it occurs to me that I should have clarified the design brief before working on it. I assumed I knew what people meant in the thread about using Todoist inbox as a Quick Capture replacement for the inbuilt Roam Research one, but lots of questions suggest that maybe it isn't as clear as I thought. https://roamresearch.slack.com/archives/C0190JLGDUJ/p1610276819246200 So, here are some explanations for design choices that I hope will help. This can also be used as a starting point for discussion, as I am open to tweaking if there is agreement.

  1. This set of SmartBlocks is not intended to link Task management via Todoist into RR. I am not outputting a TODO for these imported items as I didn't think they were tasks. My understanding of Quick Capture as a concept is that it could be ideas, thoughts, emotions and tasks. The quick part suggests relatively frictionless and easy, and that there will be some kind of later review. There are SB in the github that are for task management, but my intent with this set is to manage quick capture. The choice of Todoist as a gateway is largely that their QC is excellent, and their ubiquity means that ideas can be captured by voice assistants, mobile apps and email.
  2. As my vision for this was to Quick Capture thoughts, ideas, emotions etc, I did not implement due dates. @David I am not sure that we should, but would suggest that the task management Todoist scripts in github be modified to allow for this. I answered @Mark about adding dates in the Quick Capture thread, but he was really referring to the scripts in Github for task management, not this set of SB. I perhaps should have made it clear in the thread that it was off-topic.
  3. Assignment of a label on import. @RoamHacker I understand Quick Capture to be a way of getting a thought down immediately so it isn't lost, but that it requires triage later as to whether it remains relevant and what it actually means. Therefore, I thought forcing a tag on import into Roam would allow for storing until such triage occurs. These tags should not be conflated with labels in Todoist. I am not importing Todoist labels (I don't see creating them as part of Quick Capture as too much friction), and the config options to use labels to guide the import from Todoist are only for Todoist Premium account holders who already use their Todoist inbox and might not want to import all items to Roam. As such, I gave those Premium users a way to tell the script which items to import. This isn't possible with the Free Todoist option. I could modify the scripts to make assigning a tag in RR optional, but am already wary of how many config options there are. I've had multiple messages and queries about getting the SB running despite the documentation in the page. I can add more and more config options and if/then in the script, but I wonder if it will be overwhelming.
  4. Import of attachments @Owen Cyrulnik The way Todoist Quick Capture works is that an idea/thought/whatever will be called a task. It can then have comments. I have created this SB to allow import of comments as nested blocks / sub-blocks. This choice was made as they are related thoughts and this structure will keep them together in RR. An unrelated thought should be captured as a different item in Todoist. In addition to importing text comments, Premium users can also hotlink to attachments including pdf and jpg/png hosted by Todoist, while Free users cannot. This is a Todoist limitation. I am planning to modify to have a setting for Free vs Premium account holders, and will remove the linking/embedding that occurs for people on Free Todoist as it is not helpful as is. For those on Premium, however, the possibility to have pdfs and images as part of Quick Capture is really useful. I am emailing myself things to review later into Todoist and then importing to Roam and being able to see the pdf inline is really helpful. I am happy to talk more about this, as these are only my thoughts and assumptions. It is possible that I misunderstood some things. The biggest differentiation I would like to make is that these SB are not intended to support task management, but only Quick Capture. Cheers! :slightly_smiling_face:

mlava avatar Jan 19 '21 22:01 mlava

New version 0.1.5 Beta in first post.

mlava avatar Jan 20 '21 08:01 mlava

Fantastic work on this!

lifsys avatar Jan 20 '21 21:01 lifsys

For anyone who just really wants to have due dates come across as well, this is pretty easy to do.

First, copy and past this code immediately following the vars at the top of the code block in the TQC - Todoist QC Inbox SmartBlock.

function convertToRoamDate(dateString) {
  var parsedDate = dateString.split('-');
  var year = parsedDate[0];
  var month = Number(parsedDate[1]);
  const months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
  var monthName = months[month-1];
  var day = Number(parsedDate[2]);
  let suffix = (day >= 4 &&  day <= 20) || (day >= 24 && day <= 30)
    ? "th"
    : ["st", "nd", "rd"][day % 10 - 1];
  return "[[" + monthName + " " + day + suffix + ", " + year + "]]";
}

Then, replace this line - which occurs in two places

roam42.common.setEmptyNodeValue(document.activeElement, "" + task.content) + " #[["+TodoistImportTag+"]]" );

with this

      if (task.due) {
        roam42.common.setEmptyNodeValue(document.activeElement, "" + task.content + " " + convertToRoamDate(task.due.date)) + " #[["+TodoistImportTag+"]]" );
      } else {
        roam42.common.setEmptyNodeValue(document.activeElement, "" + task.content) + " #[["+TodoistImportTag+"]]" );
      }

You should end up with something like this. image

image

image

eatondpe avatar Jan 24 '21 00:01 eatondpe

For anyone who just really wants to have due dates come across as well, this is pretty easy to do.

First, copy and past this code immediately following the vars at the top of the code block in the TQC - Todoist QC Inbox SmartBlock.

function convertToRoamDate(dateString) {
  var parsedDate = dateString.split('-');
  var year = parsedDate[0];
  var month = Number(parsedDate[1]);
  const months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
  var monthName = months[month-1];
  var day = Number(parsedDate[2]);
  let suffix = (day >= 4 &&  day <= 20) || (day >= 24 && day <= 30)
    ? "th"
    : ["st", "nd", "rd"][day % 10 - 1];
  return "[[" + monthName + " " + day + suffix + ", " + year + "]]";
}

Then, replace this line - which occurs in two places

roam42.common.setEmptyNodeValue(document.activeElement, "" + task.content) + " #[["+TodoistImportTag+"]]" );

with this

      if (task.due) {
        roam42.common.setEmptyNodeValue(document.activeElement, "" + task.content + " " + convertToRoamDate(task.due.date)) + " #[["+TodoistImportTag+"]]" );
      } else {
        roam42.common.setEmptyNodeValue(document.activeElement, "" + task.content) + " #[["+TodoistImportTag+"]]" );
      }

You should end up with something like this. image

image

image

There were some issues with the closed parens. This change fixed and allowed the script to work in the new beta:

		if (task.due) {
        		roam42.common.setEmptyNodeValue(document.activeElement, "" + task.content + " " + convertToRoamDate(task.due.date) + " #[["+TodoistImportTag+"]]" );
      		} else {
        		roam42.common.setEmptyNodeValue(document.activeElement, "" + task.content + " #[["+TodoistImportTag+"]]" );
      		}        

lifsys avatar Jan 24 '21 21:01 lifsys

Thanks, @lifsys. Yep. I made that mistake in preparing to post it here. Appreciate you helping others with this.

eatondpe avatar Jan 24 '21 21:01 eatondpe

Thanks, @lifsys. Yep. I made that mistake in preparing to post it here. Appreciate you helping others with this.

@eatondpe, the least I can do. You all make this magic possible!

lifsys avatar Jan 24 '21 21:01 lifsys

Updated code to (hopefully) fixed the dropped items reported by Jason Philips on Slack...

https://roamresearch.slack.com/archives/C0190JLGDUJ/p1611413283091700?thread_ts=1611363111.083300&cid=C0190JLGDUJ

mlava avatar Jan 25 '21 02:01 mlava

I removed the import tag and found items were given #[[]] by default. I know you were wary of adding more configuration, but would there be a way of including no tag if the setting was blank? It's a little cumbersome deleting the tag for every import. I'm still hoping that someone will develop a Workflowy style action to delete tag by alt-click.

kmaustral avatar Jan 28 '21 10:01 kmaustral

@kmaustral

Remove this string from lines 25 and 51 of the TQC - Todoist QC Inbox code block.

#[["+TodoistImportTag+"]]

Note the space ahead of the #

mlava avatar Jan 28 '21 11:01 mlava

Thanks Mark. I get that string on lines 34, 39, 63, 73,78 and 83. Sorry if I misinterpret.

kmaustral avatar Jan 28 '21 21:01 kmaustral

Hi Kevin. I think you're using an old version. Latest is 0.1.7 beta. Suggest update to latest and then change lines 25 and 51. Don't forget to backup your config somewhere else before deleting the SB page and re-importing. Cheers. Mark

mlava avatar Jan 28 '21 22:01 mlava

Fine. I updated and removed the tag. Nice and clean. Thanks Mark.

kmaustral avatar Jan 30 '21 05:01 kmaustral

Updated to v0.18 - see first post

This version includes advanced settings configuration options to:

  • remove the tag assigned on import
  • show item created date
  • show the due date if set
  • show priority

Each of these is set to False as default and need to be enabled by changing the setting to True.

mlava avatar Feb 23 '21 05:02 mlava

New version 0.1.9 beta

  • New feature: import Todoist subtasks nested under primary task with comments
  • Update: use Roam Research alpha API allowing faster data entry

Download in first post.

mlava avatar Apr 05 '21 01:04 mlava

Hi Mark. It would be great if there was a way to import attachments as links. That way we could access the content of emails.

And can you remind me if there is a setting to delete imported tasks from Todoist. I've uploaded the latest version and can't find that setting.

Thanks for all your work.

kmaustral avatar Apr 13 '21 22:04 kmaustral

Hi Kevin, It should be automatically deleting the tasks from Todoist. Is that not happening??

Do you have premium or free? With premium you can import attachments.

mlava avatar Apr 13 '21 22:04 mlava

It's not deleting at the moment, but that might be temporary.

Todoist generously has just allowed attachments for the free plan: https://todoist.com/help/articles/whats-included-in-the-new-free-plan

On Wed, 14 Apr 2021 at 08:58, Mark Lavercombe @.***> wrote:

Hi Kevin, It should be automatically deleting the tasks from Todoist. Is that not happening??

Do you have premium or free? With premium you can import attachments.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/roamhacker/SmartBlocks/issues/187#issuecomment-819104598, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARTR6NYCDEFQS4EM5SGVNZLTITEABANCNFSM4WIJOP7A .

kmaustral avatar Apr 13 '21 23:04 kmaustral

Mark, I can download the first task, but not the others. The first task is not deleted from Todoist.

kmaustral avatar Apr 14 '21 11:04 kmaustral

Kevin, I just tested again and it's working for me with both free and premium accounts. Is there anything in the console? Cheers, Mark

On Wed, Apr 14, 2021 at 9:50 PM kmaustral @.***> wrote:

Mark, I can download the first task, but not the others. The first task is not deleted from Todoist.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/roamhacker/SmartBlocks/issues/187#issuecomment-819457794, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUKIPSIIWPZ6N24OJVDOQ3TIV6QHANCNFSM4WIJOP7A .

mlava avatar Apr 15 '21 23:04 mlava

I couldn't locate anything specific, but I'm not sure what I would be looking for. Should this setting be filled out even if you are not tagging items: #42Setting TodoistImportTag

kmaustral avatar Apr 15 '21 23:04 kmaustral

Not sure if I included logic. Maybe just add a tag and let me know what happens?

On Fri, Apr 16, 2021 at 9:19 AM kmaustral @.***> wrote:

I couldn't locate anything specific, but I'm not sure what I would be looking for. Should this setting be filled out even if you are not tagging items: #42Setting TodoistImportTag

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/roamhacker/SmartBlocks/issues/187#issuecomment-820793975, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUKIPXNLICUU4AJHNMIYT3TI5YB7ANCNFSM4WIJOP7A .

mlava avatar Apr 15 '21 23:04 mlava

unfortuantely the {{button}} block which includes 42RemoveButton=false, keeps disappearing after successfully imports tasks from todoist. Any solutions? My usual workaround which was adding an empty bulletpoint under the UQC script doesn't help

Now it works, added two blanks as parents and that did the job: #42SmartBlock UQC...

(blank) > (blank) > <%JAVASCRIPT...

ariiiak avatar Oct 03 '21 12:10 ariiiak

I haven't changed anything on my configuration but starting a few days ago I'm getting this when I run this block:

Block threw an error while running: <%JAVASCRIPTASYNC: ```javascript
var myToken = ...

Is anyone else seeing this and is there a way to get more detail than just this truncated error message?

JustinHatchett avatar Oct 19 '21 01:10 JustinHatchett

Have the same issues because of smartblock V2

gijs-epping avatar Oct 19 '21 20:10 gijs-epping

@mlava, do you know if SmartBlocks V2 caused this? If so, is this amazing tool being worked on? No worries if not, I just wanted to check before looking for another tool. 👍

JustinHatchett avatar Oct 22 '21 13:10 JustinHatchett

I;ve uploaded a new version t the marketplace

mlava avatar Oct 23 '21 00:10 mlava

Thanks @mlava! The RoamJS marketplace? I'm not seeing it there yet, is that where you mean?

JustinHatchett avatar Oct 23 '21 02:10 JustinHatchett

Yep, RoamJS marketplace. I just checked and it's in there for me. Maybe refresh your roam?

mlava avatar Oct 23 '21 03:10 mlava