Various problems with simple bookmark shortcut

I’m making a simple shortcut for making bookmarks. The idea is that I will use the share sheet in MacOS/iOS to pass a URL to the action. The action will then do the following:

  • It will create a new note in the correct bookmark folder using the bookmark template.
  • It will append a link to the URL to that new note.
  • It will create the daily note if it does not exist.
  • It will append a link to the note that was just created in the daily note.

I thought this would be simple, but there are several problems and annoyances.

I have to manually add separate steps to the action to check for the existence of the daily note and create it myself if it does not exist. The append note action has an option to create note if necessary. It works and creates the daily note at the correct location. However, it does not use the daily note template. That makes it useless.

It seems like the only action which allows for using templates is the create note action. That’s wrong. Every action which has the potential to create a note should allow for selecting a template. There should also be a stand-alone action named “apply template” that can apply any arbitrary template to any note.

The Append note action has a function to append text at the end of the section below the headline. I set the option to show an error if the headline is missing. If I set the headline in the action to something I know does not exist then I see an error as expected. If I set the action to look for the headline ## Bookmarks, which is correct, I do not see an error. However, I also do not see any appended text. The append note action only actually works if I use the end of the note option.

Lastly, this is mostly an issue with Apple Shortcuts, but string templating is very painful. In order to construct a path such as 20 - Bookmarks/YYYY/MM/Name of Bookmark I have to collect all the bits of text separately, add them to a list, then combine the list into a string. There may be a better way to do it in Apple Shortcuts that I’m not aware of.

Even if there is a better way to do it, Actions for Obsidian could still make life even easier by providing some basic actions for managing markdown. Even though I can easily get the path or name of a created note, I still have to do some shenanigans to append the square brackets to both sides of it before I can insert that link into another note. There should be an action that makes it easy to append a link to one note in another note without having to add many steps for markdown formatting.

For reference, here is the current version of my shortcut.

https://www.icloud.com/shortcuts/0094974c86094b4ea30ddf2cbab38461

Thanks.

Hi @Apreche, welcome to the forum! Thanks for checking out Actions For Obsidian. I’ll go through your question and points from the top:

I have to manually add separate steps to the action to check for the existence of the daily note and create it myself if it does not exist.

The Create Note action has “If note already exists” option which can be set to leave the note alone if it exists, which means you don’t need to precede this block with a Check For Existence Of Note action:

If this is set, you can be certain the note in question exists once that block was executed. See the related documentation.

The append note action has an option to create note if necessary. It works and creates the daily note at the correct location. However, it does not use the daily note template.

It does work as expected in current version 2024.2, i.e. the updated Append Text To A Note (not the deprecated Append Text To Periodic Note!) does that correctly:

It seems like the only action which allows for using templates is the create note action. That’s wrong.

No, it’s not “wrong” – it was a conscious design decision. I understand that you might not agree with it, but it’s not an oversight. I’ve built it like this because the “create note if it doesn’t exist” option is not a replacement for the Create Note action, it’s merely a convenience option to gracefully deal with the possible failure state of the note not existing.

There should also be a stand-alone action named “apply template” that can apply any arbitrary template to any note.

That’s a good idea, thanks! That goes straight on my todo list.

The Append note action has a function to append text at the end of the section below the headline. I set the option to show an error if the headline is missing. If I set the headline in the action to something I know does not exist then I see an error as expected. If I set the action to look for the headline ## Bookmarks , which is correct, I do not see an error. However, I also do not see any appended text. The append note action only actually works if I use the end of the note option.

I believe you that it doesn’t work for you but I can’t reproduce it yet. Could you please tell me which macOS or iOS version you’re working on and which version of AFO you’re using?

Lastly, this is mostly an issue with Apple Shortcuts, but string templating is very painful. In order to construct a path such as 20 - Bookmarks/YYYY/MM/Name of Bookmark I have to collect all the bits of text separately, add them to a list, then combine the list into a string. There may be a better way to do it in Apple Shortcuts that I’m not aware of.

Here’s a quick rewrite I just did to show how I assemble paths and strings in Shortcuts. It’s much simpler than what you had but of course there might be reasons why you did it the way it was that I am not aware of. Context is everything, isn’t it :sweat_smile:

Forum#466 Bookmark in Obsidian (overhaul).shortcut (22.9 KB)

Even if there is a better way to do it, Actions for Obsidian could still make life even easier by providing some basic actions for managing markdown. Even though I can easily get the path or name of a created note, I still have to do some shenanigans to append the square brackets to both sides of it before I can insert that link into another note. There should be an action that makes it easy to append a link to one note in another note without having to add many steps for markdown formatting.

To be honest, I’m torn about this request. Many people use the wikilink styling ([[…]]), others use the simple Markdown link styling ([…](…)), and some use the extended wikilink styling ([[…|…]]) – and many use a mix of both, depending on the situation. And that’s just one MD element. Personally, I don’t think adding the full set of Markdown elements to AFO would add much, especially as MD is just plain text, and we’re used to writing plain text in Obsidian all the time. So adding a native Text action, and passing its result as input to an AFO action seems to be the most flexible and versatile of the options.

1 Like

Here’s a quick rewrite I just did to show how I assemble paths and strings in Shortcuts. It’s much simpler than what you had but of course there might be reasons why you did it the way it was that I am not aware of. Context is everything, isn’t it :sweat_smile:

Thank you so so much. I had no idea you could do string templating in the text action like that. I searched so much for how to do it, and there were no results. It was so easy, but wasn’t documented anywhere that I saw. Never mind about adding markdown features. I won’t be needing them.

I believe you that it doesn’t work for you but I can’t reproduce it yet. Could you please tell me which macOS or iOS version you’re working on and which version of AFO you’re using?

My Obsidian version is 1.6.7 with Installer version 1.4.16
Actions URI plugin version is 1.6.3
Actions for Obsidian version is 2024.2.0

This issue was happening for me on the previous MacOS version, but I updated today to Sequoia 15.0, and the problem is the same as before.

I made a bunch of screenshots and screen captures to demonstrate the problems, but this forum told me that since I’m a new user there is a limit, and I can’t include them all. Instead, I’ll just summarize the issues.

  • In the sample action you sent you were taking the result of the Create Note action and passing it into the Append Note action. When I did this, it did not work. I got an error that AFO quit unexpectedly. Instead I have to use the Note Path variable that I already prepared.

  • In your video you use the append note action to create a new daily note. When I did the same exact action the daily note was created, but it was a blank note. The template wasn’t used, and no text was appended. Then I get an error that the header can’t be found. That error is expected because the note is blank and has no header.
  • If I make the daily note myself, so the header exists, I still can not append text below the header. AFO is finding the header, because it does not return an error. However, no text is appended below the header. If I use the end of the note option, the text is appended correctly.

Thanks again. This has been a big help.

I just encountered an additional problem. On my iPhone (12 mini) I have iOS 18 and the same versions of everything I have on MacOS. Sometimes the AFO actions will fail due to timeout. It’s not very consistent. Sometimes it works, sometimes it doesn’t.

Thank you so so much. I had no idea you could do string templating in the text action like that.

Glad I could help!

Thanks for the updates on the used versions. Are you storing your vault in iCloud by any chance? Because I’ve gotten reports like this (“note was created, but the next action couldn’t see the content”) in the past, and in the end it was usually an iCloud problem (Obsidian vaults and iCloud don’t mix). See this FAQ section: Can I use iCloud Sync with Obsidian and Actions for Obsidian?

And thank you for the bug reports, I’ll look into them!

If I make the daily note myself, so the header exists, I still can not append text below the header. AFO is finding the header, because it does not return an error. However, no text is appended below the header. If I use the end of the note option, the text is appended correctly.

Would you be willing to get me some log output from that device? If so:

  • In your vault “Full Life”, please install my plugin Logstravaganza
  • Configure it to output NDJSON, log level “Debug”
  • Enable Logstravaganza
  • Disable Actions URI
  • Enable Actions URI again
  • Run the workflow you’re having issues with. (Alternatively, set up an isolated test workflow in Shortcuts that only contains the action you’re having problems with, and run that.)
  • Disable Logstravaganza
  • Send me the output (via private message or email)

Thanks!

(Logstravaganza logs Obsidian’s internal output that usually goes to the hidden developer console. Actions URI is reporting to that console, so that log output might contain some clues about what’s going wrong.)

I am not using iCloud for the syncing between devices, I am using Obsidian Sync. However, on my Mac the vault is in a folder that is an iCloud folder, just so that it is backed up. On the iOS devices it is not in an iCloud folder, to avoid the syncing. I will try moving it to see if that fixes things, and then I will use another method to make sure it is backed up.

I will get you the logs later today.

1 Like

Sorry, it took a bit longer to come back to this issue.

I moved my vault outside of the Documents directory up into my home folder, so iCloud drive was no longer a factor. The issues persisted exactly the same as before, so I’m comfortable saying iCloud was not the cause.

Rather than try to attack every bug at once, I focused just on the issue of appending beneath the headline in the daily note. I installed the logstravaganza, which works great. I realized after looking at the logs the problem was probably with the Actions URI plugin and not with Actions for Obsidian.

In order to test I constructed a URL and pasted it into the browser. I wanted to use curl, but it wouldn’t work for this purpose. Here is the URL I used.

obsidian://actions-uri/note/append?vault=Full%20Life&periodic-note=daily&content=hello&below-headline=%23%23%20Bookmarks&if-headline-missing=error&create-if-not-found=true&ensure-newline=true&silent=false

I tried with silent true and false, but it didn’t matter. Every time the logs say that it appended correctly, but the reality is that no text was appended in my daily note. Here are the logs.

| Timestamp | Originator | Level | Message |
| --------- | ---------- | ----- | ------- |
| 2024-09-19T00:57:53.861Z | plugin:logstravaganza | info | \[Logstravaganza] Proxy set up (v2.1.1) |
| 2024-09-19T00:59:35.272Z | app.js:1:2281361 | log | \["Received URL action",{"silent":"true","x-source":"Actions For Obsidian","vault":"Full Life","if-exists":"skip","apply":"templates","file":"20 - Bookmarks/2024/09/Google","x-error":"actions-for-obsidian://x-callback-url/response?requestID=2490DD39-585F-448D-B047-F007A2D5B95E&responseType=error","x-success":"actions-for-obsidian://x-callback-url/response?responseType=success&requestID=2490DD39-585F-448D-B047-F007A2D5B95E","x-cancel":"actions-for-obsidian://x-callback-url/response?requestID=2490DD39-585F-448D-B047-F007A2D5B95E&responseType=cancel","template-file":"80 - Templates/Bookmark","content":"","action":"actions-uri/note/create"}] |
| 2024-09-19T00:59:36.009Z | plugin:actions-uri:25:827 | log | \["\[Actions URI]","Call handled:",{"params":{"action":"actions-uri/note/create","vault":"Full Life","debug-mode":false,"x-error":"actions-for-obsidian://x-callback-url/response?requestID=2490DD39-585F-448D-B047-F007A2D5B95E&responseType=error","x-success":"actions-for-obsidian://x-callback-url/response?responseType=success&requestID=2490DD39-585F-448D-B047-F007A2D5B95E","x-source":"Actions For Obsidian","file":"20 - Bookmarks/2024/09/Google","apply":"templates","template-file":"80 - Templates/Bookmark","if-exists":"skip","silent":true,"_resolved":{"templatePath":"80 - Templates/Bookmark.md","templateFile":"\[TFile] 80 - Templates/Bookmark.md","inputKey":"file","inputPath":"20 - Bookmarks/2024/09/Google"}},"handlerResult":{"isSuccess":true,"result":{"filepath":"20 - Bookmarks/2024/09/Google.md","content":"---\ndate: 20240918\ntags:\n  - bookmark\n---\n# Google","body":"# Google","frontMatter":"date: 20240918\ntags:\n  - bookmark\n","properties":{},"uid":""}},"sendCallbackResult":{"isSuccess":true,"result":"actions-for-obsidian://x-callback-url/response?responseType=success&requestID=2490DD39-585F-448D-B047-F007A2D5B95E&result-body=%23%20Google&result-content=---%0Adate%3A%2020240918%0Atags%3A%0A%20%20-%20bookmark%0A---%0A%23%20Google&result-filepath=20%20-%20Bookmarks%2F2024%2F09%2FGoogle.md&result-front-matter=date%3A%2020240918%0Atags%3A%0A%20%20-%20bookmark%0A&result-properties=%7B%7D&result-uid=&pv=1.6.3"},"openResult":{"isSuccess":true,"result":"No file to open, the `silent` parameter was set"}}] |
| 2024-09-19T00:59:36.161Z | app.js:1:2281361 | log | \["Received URL action",{"silent":"","ensure-newline":"true","create-if-not-found":"","vault":"Full Life","x-source":"Actions For Obsidian","x-cancel":"actions-for-obsidian://x-callback-url/response?responseType=cancel&requestID=0BFB62E7-EB37-41FE-AE3C-63CA4EBA6107","file":"20 - Bookmarks/2024/09/Google","x-error":"actions-for-obsidian://x-callback-url/response?responseType=error&requestID=0BFB62E7-EB37-41FE-AE3C-63CA4EBA6107","if-headline-missing":"error","x-success":"actions-for-obsidian://x-callback-url/response?requestID=0BFB62E7-EB37-41FE-AE3C-63CA4EBA6107&responseType=success","content":"\n\[Google](https://www.google.com/)","below-headline":"","action":"actions-uri/note/append"}] |
| 2024-09-19T00:59:36.674Z | plugin:actions-uri:25:827 | log | \["\[Actions URI]","Call handled:",{"params":{"action":"actions-uri/note/append","vault":"Full Life","debug-mode":false,"x-error":"actions-for-obsidian://x-callback-url/response?responseType=error&requestID=0BFB62E7-EB37-41FE-AE3C-63CA4EBA6107","x-success":"actions-for-obsidian://x-callback-url/response?requestID=0BFB62E7-EB37-41FE-AE3C-63CA4EBA6107&responseType=success","x-source":"Actions For Obsidian","file":"20 - Bookmarks/2024/09/Google.md","content":"\n\[Google](https://www.google.com/)","silent":false,"below-headline":"","create-if-not-found":false,"ensure-newline":true,"if-headline-missing":"error","_resolved":{"inputKey":"file","inputPath":"20 - Bookmarks/2024/09/Google.md","inputFile":"\[TFile] 20 - Bookmarks/2024/09/Google.md"}},"handlerResult":{"isSuccess":true,"result":{"message":"Note was appended"},"processedFilepath":"20 - Bookmarks/2024/09/Google.md"},"sendCallbackResult":{"isSuccess":true,"result":"actions-for-obsidian://x-callback-url/response?requestID=0BFB62E7-EB37-41FE-AE3C-63CA4EBA6107&responseType=success&result-message=Note%20was%20appended&pv=1.6.3"},"openResult":{"isSuccess":true,"result":"Open file found and focussed"}}] |
| 2024-09-19T00:59:36.747Z | app.js:1:2281361 | log | \["Received URL action",{"vault":"Full Life","if-exists":"skip","silent":"true","x-success":"actions-for-obsidian://x-callback-url/response?requestID=60481BCC-A981-4FC1-91BD-FB133A783ACC&responseType=success","periodic-note":"daily","x-cancel":"actions-for-obsidian://x-callback-url/response?requestID=60481BCC-A981-4FC1-91BD-FB133A783ACC&responseType=cancel","x-source":"Actions For Obsidian","x-error":"actions-for-obsidian://x-callback-url/response?requestID=60481BCC-A981-4FC1-91BD-FB133A783ACC&responseType=error","action":"actions-uri/note/create"}] |
| 2024-09-19T00:59:36.766Z | plugin:actions-uri:25:827 | log | \["\[Actions URI]","Call handled:",{"params":{"action":"actions-uri/note/create","vault":"Full Life","debug-mode":false,"x-error":"actions-for-obsidian://x-callback-url/response?requestID=60481BCC-A981-4FC1-91BD-FB133A783ACC&responseType=error","x-success":"actions-for-obsidian://x-callback-url/response?requestID=60481BCC-A981-4FC1-91BD-FB133A783ACC&responseType=success","x-source":"Actions For Obsidian","periodic-note":"daily","if-exists":"skip","silent":true,"_resolved":{"inputKey":"periodic-note","inputPath":"00 - Daily/2024/09/20240918.md"}},"handlerResult":{"isSuccess":true,"result":{"filepath":"00 - Daily/2024/09/20240918.md","content":"---\ndate: 2024/09/18\naliases:\n  - \"20240918\"\ntags:\n  - daily\n---\n# 20240918\n\n## Log\n\n## Bookmarks","body":"# 20240918\n\n## Log\n\n## Bookmarks","frontMatter":"date: 2024/09/18\naliases:\n  - \"20240918\"\ntags:\n  - daily\n","properties":{},"uid":""}},"sendCallbackResult":{"isSuccess":true,"result":"actions-for-obsidian://x-callback-url/response?requestID=60481BCC-A981-4FC1-91BD-FB133A783ACC&responseType=success&result-body=%23%2020240918%0A%0A%23%23%20Log%0A%0A%23%23%20Bookmarks&result-content=---%0Adate%3A%202024%2F09%2F18%0Aaliases%3A%0A%20%20-%20%2220240918%22%0Atags%3A%0A%20%20-%20daily%0A---%0A%23%2020240918%0A%0A%23%23%20Log%0A%0A%23%23%20Bookmarks&result-filepath=00%20-%20Daily%2F2024%2F09%2F20240918.md&result-front-matter=date%3A%202024%2F09%2F18%0Aaliases%3A%0A%20%20-%20%2220240918%22%0Atags%3A%0A%20%20-%20daily%0A&result-properties=%7B%7D&result-uid=&pv=1.6.3"},"openResult":{"isSuccess":true,"result":"No file to open, the `silent` parameter was set"}}] |
| 2024-09-19T00:59:36.828Z | app.js:1:2281361 | log | \["Received URL action",{"below-headline":"## Bookmarks","periodic-note":"daily","x-error":"actions-for-obsidian://x-callback-url/response?requestID=39C148FA-DCFF-48DD-832B-FC5CF57ACB8B&responseType=error","if-headline-missing":"error","create-if-not-found":"","x-cancel":"actions-for-obsidian://x-callback-url/response?requestID=39C148FA-DCFF-48DD-832B-FC5CF57ACB8B&responseType=cancel","content":"\n\[\[Google]]","silent":"true","x-success":"actions-for-obsidian://x-callback-url/response?responseType=success&requestID=39C148FA-DCFF-48DD-832B-FC5CF57ACB8B","ensure-newline":"true","vault":"Full Life","x-source":"Actions For Obsidian","action":"actions-uri/note/append"}] |
| 2024-09-19T00:59:37.339Z | plugin:actions-uri:25:827 | log | \["\[Actions URI]","Call handled:",{"params":{"action":"actions-uri/note/append","vault":"Full Life","debug-mode":false,"x-error":"actions-for-obsidian://x-callback-url/response?requestID=39C148FA-DCFF-48DD-832B-FC5CF57ACB8B&responseType=error","x-success":"actions-for-obsidian://x-callback-url/response?responseType=success&requestID=39C148FA-DCFF-48DD-832B-FC5CF57ACB8B","x-source":"Actions For Obsidian","periodic-note":"daily","content":"\n\[\[Google]]","silent":true,"below-headline":"## Bookmarks","create-if-not-found":false,"ensure-newline":true,"if-headline-missing":"error","_resolved":{"inputKey":"periodic-note","inputPath":"00 - Daily/2024/09/20240918.md","inputFile":"\[TFile] 00 - Daily/2024/09/20240918.md"}},"handlerResult":{"isSuccess":true,"result":{"message":"Note was appended"},"processedFilepath":"00 - Daily/2024/09/20240918.md"},"sendCallbackResult":{"isSuccess":true,"result":"actions-for-obsidian://x-callback-url/response?responseType=success&requestID=39C148FA-DCFF-48DD-832B-FC5CF57ACB8B&result-message=Note%20was%20appended&pv=1.6.3"},"openResult":{"isSuccess":true,"result":"No file to open, the `silent` parameter was set"}}] |
| 2024-09-19T01:00:04.758Z | app.js:1:2281361 | log | \["Received URL action",{"vault":"Full Life","file":"console-log.Epsilon.internal.md","action":"open"}] |
| 2024-09-19T01:12:27.988Z | app.js:1:2281361 | log | \["Received URL action",{"vault":"Full Life","periodic-note":"daily","content":"hello","below-headline":"## Bookmarks","if-headline-missing":"error","create-if-not-found":"true","ensure-newline":"true","silent":"true","action":"actions-uri/note/append"}] |
| 2024-09-19T01:12:28.506Z | plugin:actions-uri:25:827 | log | \["\[Actions URI]","Call handled:",{"params":{"action":"actions-uri/note/append","vault":"Full Life","debug-mode":false,"periodic-note":"daily","content":"hello","silent":true,"below-headline":"## Bookmarks","create-if-not-found":true,"ensure-newline":true,"if-headline-missing":"error","_resolved":{"inputKey":"periodic-note","inputPath":"00 - Daily/2024/09/20240918.md","inputFile":"\[TFile] 00 - Daily/2024/09/20240918.md"}},"handlerResult":{"isSuccess":true,"result":{"message":"Note was appended"},"processedFilepath":"00 - Daily/2024/09/20240918.md"},"sendCallbackResult":{"isSuccess":true,"result":"No `x-error` callback URL provided"},"openResult":{"isSuccess":true,"result":"No file to open, the `silent` parameter was set"}}] |
| 2024-09-19T01:14:19.862Z | app.js:1:2281361 | log | \["Received URL action",{"vault":"Full Life","periodic-note":"daily","content":"hello","below-headline":"## Bookmarks","if-headline-missing":"error","create-if-not-found":"true","ensure-newline":"true","silent":"false","action":"actions-uri/note/append"}] |
| 2024-09-19T01:14:20.384Z | plugin:actions-uri:25:827 | log | \["\[Actions URI]","Call handled:",{"params":{"action":"actions-uri/note/append","vault":"Full Life","debug-mode":false,"periodic-note":"daily","content":"hello","silent":false,"below-headline":"## Bookmarks","create-if-not-found":true,"ensure-newline":true,"if-headline-missing":"error","_resolved":{"inputKey":"periodic-note","inputPath":"00 - Daily/2024/09/20240918.md","inputFile":"\[TFile] 00 - Daily/2024/09/20240918.md"}},"handlerResult":{"isSuccess":true,"result":{"message":"Note was appended"},"processedFilepath":"00 - Daily/2024/09/20240918.md"},"sendCallbackResult":{"isSuccess":true,"result":"No `x-error` callback URL provided"},"openResult":{"isSuccess":true,"result":"Open file found and focussed"}}] |

Thanks for the update & data, here and via email.

I moved my vault outside of the Documents directory up into my home folder, so iCloud drive was no longer a factor. The issues persisted exactly the same as before, so I’m comfortable saying iCloud was not the cause.

:+1:t3:

I wanted to use curl, but it wouldn’t work for this purpose

Sadly, curl doesn’t support custom protocols. You probably know this, but open 'obsidian://… from the terminal does work. You won’t get anything back, but that’s x-callback-url for you :sweat_smile:

I realized after looking at the logs the problem was probably with the Actions URI plugin and not with Actions for Obsidian.

You’re probably right, even though I still can’t reproduce it. I’ll get back to you via email.

PS:

This turned out to be a bug introduced by Apple in iOS 18 and (likely) macOS 15, see: Actions asking for File Path when working with note reference (iOS18, macOS Sequoia) - #3 by PeterFInBrisbane – I’m pretty sure it’s the same issue. A workaround for that is incoming in v2024.2.1, hopefully later this week!