Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Universal Quick Capture for Roam Research Beta #187

Open
mlava opened this issue Jan 19, 2021 · 38 comments
Open

Universal Quick Capture for Roam Research Beta #187

mlava opened this issue Jan 19, 2021 · 38 comments

Comments

@mlava
Copy link

mlava commented Jan 19, 2021

✂️ 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 mlava changed the title Todoist Quick Capture for Roam Research v0.1.1 Beta Todoist Quick Capture for Roam Research v0.1.2 Beta Jan 19, 2021
@mlava mlava changed the title Todoist Quick Capture for Roam Research v0.1.2 Beta Todoist Quick Capture for Roam Research Beta Jan 19, 2021
@pomdtr
Copy link

pomdtr commented Jan 19, 2021

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

@mlava
Copy link
Author

mlava commented Jan 19, 2021

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! 🙂

@mlava
Copy link
Author

mlava commented Jan 20, 2021

New version 0.1.5 Beta in first post.

@lifsys
Copy link

lifsys commented Jan 20, 2021

Fantastic work on this!

@mlava mlava changed the title Todoist Quick Capture for Roam Research Beta Quick Capture with Todoist Gateway for Roam Research Beta Jan 21, 2021
@eatondpe
Copy link

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

@lifsys
Copy link

lifsys commented Jan 24, 2021

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+"]]" );
      		}        

@eatondpe
Copy link

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

@lifsys
Copy link

lifsys commented Jan 24, 2021

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!

@mlava
Copy link
Author

mlava commented Jan 25, 2021

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

@kmaustral
Copy link

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.

@mlava
Copy link
Author

mlava commented Jan 28, 2021

@kmaustral

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

#[["+TodoistImportTag+"]]

Note the space ahead of the #

@kmaustral
Copy link

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

@mlava
Copy link
Author

mlava commented Jan 28, 2021

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

@kmaustral
Copy link

kmaustral commented Jan 30, 2021

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

@TfTHacker TfTHacker pinned this issue Feb 7, 2021
@mlava
Copy link
Author

mlava commented Feb 23, 2021

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 mlava changed the title Quick Capture with Todoist Gateway for Roam Research Beta Universal Quick Capture for Roam Research Beta Feb 23, 2021
@mlava
Copy link
Author

mlava commented Apr 5, 2021

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.

@kmaustral
Copy link

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.

@mlava
Copy link
Author

mlava commented Apr 13, 2021

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.

@kmaustral
Copy link

kmaustral commented Apr 13, 2021 via email

@kmaustral
Copy link

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

@mlava
Copy link
Author

mlava commented Apr 15, 2021 via email

@kmaustral
Copy link

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

@mlava
Copy link
Author

mlava commented Apr 15, 2021 via email

@ariiiak
Copy link

ariiiak commented Oct 3, 2021

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...

@JustinHatchett
Copy link

JustinHatchett commented Oct 19, 2021

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?

@gijs-epping
Copy link

Have the same issues because of smartblock V2

@JustinHatchett
Copy link

JustinHatchett commented Oct 22, 2021

@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. 👍

@mlava
Copy link
Author

mlava commented Oct 23, 2021

I;ve uploaded a new version t the marketplace

@JustinHatchett
Copy link

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

@mlava
Copy link
Author

mlava commented Oct 23, 2021

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

@JustinHatchett
Copy link

Found it. I wasn't looking on the SmartBlock store, but the marketplace that is part of the roamjs website.

Glad you're getting a few bucks for this great integration now, thanks for the update!

@WalterChr
Copy link

On the contrary I now found it on the Smartblocks-Store :)
But you should post a documentation in the store. Because for me the addon initially didnt work because I had both versions (the one here and the one from the store) "installed".
I figured out that you have to put in all the data again in the new addon (which of course makes sense after thinking about it), but it nevertheless took me 10 minutes or so to make it running again because there is no documentation.
And the link in the description in the smartblock store cannot be opened (at least I dont have access there).

@mlava
Copy link
Author

mlava commented Oct 31, 2021 via email

@markpmccoy
Copy link

I recently bought the plugin through the SmartBlocks store.

Inbox items pull in from Todoist fine but they are NOT removed from the Todoist inbox.

Have you encountered this before / have any ideas for solving it?

@mlava
Copy link
Author

mlava commented Nov 17, 2021

Hi Mark.
Thank you. I haven't seen this, but am going to start experimenting and see if I can reproduce it.
A couple of questions:
Are the tasks that aren't being removed pulled into Roam again the next time you call the SB?
Could you please open Console (F12 in many browsers) and go to the Errors section. Then, call the SB and see if any errors appear. If there are, please screenshot or record a Loom for me?
Thanks in advance,
Mark

@markpmccoy
Copy link

markpmccoy commented Nov 17, 2021 via email

@mlava
Copy link
Author

mlava commented Nov 18, 2021

Hi Mark.
That error looks pretty worrying. CORS issues often aren't fixable without creating a nodejs server as a middleman.
How wedded are you to using Roam in the Desktop app?
I will experiment with trying the other Todoist API from the desktop app and see if I can progress. It might take me a little bit of time.
Cheers,
Mark

@markpmccoy
Copy link

markpmccoy commented Nov 18, 2021 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants