dvargas92495 / SmartBlocks

Useful examples from developer community for Roam42 SmartBlocks
147 stars 7 forks source link

Universal Quick Capture for Roam Research Beta #187

Open mlava opened 3 years ago

mlava commented 3 years ago

āœ‚ļø 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

pomdtr commented 3 years ago

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

mlava commented 3 years ago

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 commented 3 years ago

New version 0.1.5 Beta in first post.

lifsys commented 3 years ago

Fantastic work on this!

eatondpe commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

lifsys commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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

mlava commented 3 years ago

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 commented 3 years ago

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

mlava commented 3 years ago

Updated to v0.18 - see first post

This version includes advanced settings configuration options to:

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

mlava commented 3 years ago

New version 0.1.9 beta

Download in first post.

kmaustral commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

mlava commented 3 years ago

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 .

kmaustral commented 3 years ago

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 commented 3 years ago

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 .

ariiiak commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Have the same issues because of smartblock V2

JustinHatchett commented 3 years ago

@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 commented 3 years ago

I;ve uploaded a new version t the marketplace

JustinHatchett commented 3 years ago

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

mlava commented 3 years ago

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

JustinHatchett commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Thank you. I've updated the description in the store to point to this Github issue. Hopefully, people will be able to get it working.

On Sun, Oct 31, 2021 at 4:29 PM WalterChr @.***> wrote:

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

ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dvargas92495/SmartBlocks/issues/187#issuecomment-955639836, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUKIPSRBA4L5MG422O3CBDUJTH3RANCNFSM4WIJOP7A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

markpmccoy commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Hi Mark,

Thanks for getting back to me so quickly. Responses below.

  1. The SB will pull in duplicate Todoist tasks when it's called again.
  2. The error message definitely points to the problem (screenshot attached)
    • Not sure if it helps, but I usually use the Roam Desktop app. To capture the screenshot I opened Roam in my browser.

Thanks for your help!

Mark

On Wed, Nov 17, 2021 at 21:03:27, Mark Lavercombe @.***> wrote: Screenshot 2021-11-17 at 21 53 42

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

ā€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dvargas92495/SmartBlocks/issues/187#issuecomment-972020879, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGJXYW3QRBG2ANE6SNUMZDUMQKB7ANCNFSM4WIJOP7A .

mlava commented 2 years ago

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 commented 2 years ago

Hi Mark,

While I primarily use the Roam Desktop app, I took the screenshot from a Chrome window (not sure if that makes a difference).

I prefer the Desktop App to having Roam in a Chrome window, though I'm happy to experiment with other solutions. Out of curiosity, what's your current setup, or popular setups that others use?

Mark

On Thu, Nov 18, 2021 at 04:18:32, Mark Lavercombe @.***> wrote:

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

ā€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dvargas92495/SmartBlocks/issues/187#issuecomment-972524060, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGJXYTMN67JU6NJDOLC4BDUMR5BRANCNFSM4WIJOP7A .