Append to specific note in Bear using callback URL

Hi friends,

I am fairly new to this so please bear with me, and I apologise if this is a silly question.

I would like to use Drafts to quick capture to Bear.

I have a rolling quick capture note that I capture stuff in. I will like to append to that note.

So far, I have worked out how to do that, but I’m struggling with formatting.

Using an action and the callback URL, I have got the following template built:

bear://x-callback-url/add-text?title=Capture-Note&text=[[date|=longDateTime]]-[[draft]]&mode=append

The Capture-Note is my note.

I have added date and time, but I would really like date and time to the first line of the new Bear Note.

The above produces the following into the Bear Capture-Note:

6 November 2024 at 21:51:53 GMT-This is the first line of the Draft
This is the second line of the Draft. The rest of the content flows thereafter…

In an ideal world, the exported note would look like this when it arrives in Bear:

6 November 2024 at 21:51:53 GMT
This is the first line of the Draft
This is the second line of the Draft. The rest of the content flows thereafter…

I would then like to add a markdown line (—) after the bottom of the Draft. This is where I am struggling. I want to:

  1. Move the opening line of the Draft down as per the above.
  2. Add the markdown line.

I’m sure this should be possible. But I’m absolutely stumped and can’t work it out.

Any guidance would be truly appreciated.

Thanks!

Building URL arguments can be a bit tricky because you have to encode special characters like line feeds and spaces. The easiest way to do this in Drafts is to build with templates, and use the output in the URL.

Break your action into two steps. The first step being a “Define Template Tag” step. This step lets you create a new template tag in a text area, so you can have it configured something like (shown on Mac, but works the same on iOS):

So you can edit your output in a friendly format. Then the in your subsequent Callback URL step, you can use the new tag created by the step before to insert this content like the below, and Drafts will take care of URL encoding anything as needed:

bear://x-callback-url/add-text?title=Capture-Note&text=[[output]]&mode=append

Hope this helps!

Thank you. I appreciate the swift response.

I am excited to try this tomorrow!