Draft Action to file on server

Hello,

I have fallen in love with https://silverbullet.md/ its a text editing solution that just works for my brain. It looks at a folder with markdown files and serve them up in an interface with some fast text management features.

I host the app on a small cloud server and access it through my browser, I rely heavily on Drafts as the starting point of everything I do.

I trying to add Drafts Action to send the current draft to Shortcuts, then shortcuts use “Run Script over SSH” to echo the file into the folder:

echo "[[draft]]" > ~/pages/[[title]].md

Then SilverBullet will index it making it available for further processing or just archived.

My issues is that it appears to me that when I set the Shortcut to receive input from Drafts it only gets the one Magic Variable?

Any way I can get the [[title]] and [[draft]] indepently so Shortcuts can use them as noted above?

Or am I overlooking another option?

Triggering a shortcut from Drafts, you can only pass in a single string argument. You can handle this a couple of ways.

One, you can construct a string with multiple values separated by some delimiter, and then split the values in your shortcut.

Or, you can pass a just the [[uuid]] value, and use a “Get Draft by UUID” shortcut action in Shortcuts to retrieve the draft as an object, then use Drafts “Process Template” shortcuts action in the shortcut to process the draft content to get the template tag values.

If that doesn’t make sense I can elaborate.

1 Like

I will try both options and report back. Thanks

*Is there a way I can see whats coming from Drafts when I send the action to Shortcuts. *

Selecting the UUID option the action fails.


Edited:

I worked it out by trial and error.

My Draft Action looks like this:

  • Siri Short Cut added as Step
  • Input are two lines:
    [[title]]
    [[draft]]

And then my shortcut looks like this:

Any suggestions would be welcome, I could not figure out the UUID method.

I would suggest changing [[title]] to [[safe_title]] since you are using it as a file name. Take a read in the template tag docs as to why this would be advisable.

To use the UUID pass it to the “Get Draft by UUID” action in Shortcuts. This then effectively makes the draft available to the Shortcut along with all the properties, shortcut actions, etc. This is particularly useful if you wanted to easily access meta data such as timestamps and tags to apply to published content.

Technically you don’t need the set variable steps in your shortcuy. You can access the results directly (ref. magic variables). Magic variables can be named, so you wouldn’t lose the clarity of naming. But this is more for info - using set variable works for this use case, it just isn’t often necessary to use.

Overall, I think you could use something like this if you wanted to streamline it.

Please note, the above is untested, and I also tweaked the command as quotes usually span the whole path rather than the filename, and I find the expansion of HOME works in more places than the tilde abbreviation, so out of habit, I use that if I’m not looking at a live prompt.

Hope that helps.

1 Like

That is a lot cleaner and works well, I need to learn more about Process Templates but appears to be working out of the box. Thanks. Workflow is already a lot cleaner!