Using Obsidian with Drafts

Disclaimer: We are not Obsidian experts! This guide is meant to get people started with the basics of using Drafts with Obsidian. Feel free to expand on these ideas, or let us know if we’ve missed something important.

Obsidian is a popular personal knowledge management application that focuses on organizing and cross-linking Markdown files.

Drafts works nicely as a capture front-end for Obsidian. This article covers methods available to send items you have captured in Drafts to your Obsidian vaults. The actions provide here are all cross-platform and will work on both iOS and Mac.

Not all ways to work with Obsidian are covered here, just some basics to get you started.

URL-Based Actions

Obsidian’s URL scheme support allows Drafts to create new files in Obsidian, passing details to control which vault, file name, and content to include.

Below are example actions with variations of what is possible with URLs, see “Modifying URL Action Examples” below for details on adapting these to your needs:

  • Send to Obsidian
    • This action creates a new file with the content of the current draft in the active Obsidian vault, using the first line of the draft as a file name. It also appends any tags assigned in Drafts as #hashtags at the end of the file. The file will be stored in the default location for new files, as specified in Obsidian settings.
  • Send to Obsidian Vault
    • A modified version of the above action, this action also specifies which vault to use. If you have multiple Obsidian vaults, you might create multiple duplicates of this action, specifying a different target vault in each. See the “Modifying…” section below for details on changing the vault name.

For advanced use cases, see the Obsidian URL documentation for details on available parameters. It is possible to use different parameter combinations to target specific paths, etc.

Modifying URL Action Examples

Each of the example actions above defines the parameters used to construct the Obsidian URL in a series of “Define Template Tag” action steps. To modify these parameters, you can edit the templates of each of these steps.

For the “Send to Obsidian Vault” example to be useful, you will have to edit the action and change the template value “MY-VAULT” in the first step of the action to match the name of a vault in your Obsidian installation.

URL Pros & Cons

  • PROS:
    • Not important where you store your vaults.
    • Works with encrypted vaults.
    • After completion, you are left in Obsidian editing the newly created file, if you need to make any additional tweaks.
  • CONS:
    • Obsidian app must opened to complete the action.
    • Obsidian does not support callback URLs, so this method cannot return results to Drafts, or be combined with other action steps as effectively.
    • Cannot update existing files, only create new ones.

File-Based Actions

Obsidian vaults are a set of text files in a folder. Drafts can read-write-update files. Therefore, as long as your Obsidian vault is stored in a location accessible to Drafts actions, Drafts can also add to files in your vault directly, without the need to launch Obsidian.

Both of the below example actions rely on Folder Bookmarks, a new feature introduced in Draft v28. Make sure you are up-to-date before using these actions.

Below are file action examples:

  • Save to Obsidian Vault
    • Save current draft to the root folder associated with the bookmark named “Obsidian Vault”, using the first line as the file name.
  • Append to Obsidian Journal
    • Appends text of current draft to daily journal file named like Daily-YYYY-MM-DD in the folder Journal. If the file does not exist, it will be created.

About Bookmarks

Both of these examples rely on Folder Bookmarks. The first time you run each of these examples on a device, you will be prompted to select your Obsidian Vault folder to grant Drafts permission to create files in that folder. More details on how bookmarks operate in the docs, but your vault must reside in a location which can be accessed by bookmarks. On Mac, this is any folder you have permissions to modify, but it is more limited on iOS, as many file provider apps (like Dropbox, Google Drive) do not support bookmarking. The most reliable place to store a vault to be able to use file-based actions on iOS is in your iCloud Drive folder.

Modifying File Actions

Each of the above examples uses a single File action step. File action steps have extensive options for configuring the path, file name, and content of the file. See docs for details on configuring these options.

File Pros & Cons

  • PROS:
    • No need to launch Obsidian to add content to a vault.
    • Actions can also append-prepend-update files, not just create new ones.
  • CONS:
    • Vault must be store in a location accessible to Drafts.
14 Likes

Just wanted to share something regarding using URL schemes to append/prepend to existing files. It is possible to do this but for now at least, you need to use a plugin such as the Advanced Obsidian URI plugin. It will require you to use a different syntax and obviously isn’t supported by the main development team but something for people to consider.

Thank you so much!!!

Yes! The Advanced Obsidian URI plugin works well. Matt Edwards helped me figure out how to append to my daily note in Obsidian, as well as how to create new files anywhere in Obsidian—all from Drafts.
Here are the two actions he made:

I wrote about how I use these actions in my Obsidian productivity system, here.

2 Likes

Thank you for this guide! I had used the build-in and Advanced Obsidian URI plugins, but found them flimsy, especially on mobile. The app would need to open and often the text would get lost somewhere along the way.

The “File-Based Actions” workflow is much more reliable for me.

2 Likes

I love these plugins, but I’m still having difficulty defining my valutName.

My vault is in my iCloud Drive > Obsidian > BillPetro

However, even using Advanced Obsidian URI, I’m still getting an error:

What am I doing wrong?

I can get the action to work. However …

I am using Obsidian Sync (not iCloud sync). This means that the local folder name for Mac, iPad and iPhone all different.

How do I use the same action but applying different folder names on different devices? Or I have to set up different action for each device?

You can use scripting to detect the OS/device, and specify the variations in the URL to use. Then you can have one that deals with all cases.

I use actions that works directly with the files rather the URL scheme. This has the advantagea of not only being a little quicker and not requiring app switching, but it utilises bookmarks, which you specify per device.

2 Likes

Hi guys. What’s the best / easiest way to learn to build my own actions?

I have a very weird use case. I am streamlining my Zettelkasten workflow and I’ve realized that:

  1. Fleeting notes are captured and expanded in Drafts. Then they are:
  2. transformed via a drafts action into:
  3. Zettels/ atomic notes / evergreen / permanent notes that live in Obsidian, where they can be linked nicely.

It’s step 2 where I need to create an action that does the following:

  1. Asks the user for tags
  2. Inserts a YAML frontmatter field with tags entered above as well as a creation date and some other data like my name as the author.
  3. Places the file into my Obsidian vault.
  4. Trashes the Draft. No need to ask me if I want it trashed.

I don’t know how to code JavaScript, and I’m wondering if there is some kind of WYSISYG editor drag and drop thing that can help me build this action.

Any suggestions? Thanks so much :blush:

What you describe, I believe, could be done without Javascript. At least if the “asks the user for tags” is just a text entry field.

Start an action with a Prompt action step with “Include Text Field” set to true to prompt the user to enter a list of tags.

Follow that up with a “File” action step that writes the content to the right place in your Obsidian vault…you can start with one of the File-based example actions above in this guide.

Then modify the template use for the body content in the File step. It could contain the front matter, creation date, and input from the prompt with template tags. See this article to get started on how template tags work.

1 Like

Thanks a lot! I’m relieved to hear I won’t have to learn JavaScript :blush: I’ll try those steps and let you know if I have any luck with them. Thanks again.

It worked! Hurray hurrah!!! Thank you so much. I greatly appreciate the assistance. Woop woop! :clap: :clap: :clap:

1 Like

Hi All

I am using the “Append to Obsidian Journal-Posted by agiletortoise” Action to append to a novel draft I am writing- works perfectly from Mac however exactly same action on IOS sends nothing - very infuriating. Any ideas appreciated.

Does your Obsidian Vault bookmark on your iOS device point to your Obsidian vault? I think that is the most likely thing you may have missed aligning.

If it is, what does your action log say about what it is doing? Any errors?

1 Like

Am I right in thinking that the reason I can’t find any info about setting a shortcut hotkey for this is because I need the pro version to customise actions?

Base configuration options, like keyboard shortcuts, are available in the free version. See User Guide for details on configuring actions.

1 Like