MustachePrompt and Mail together not work as I expect

I try to join together two actions in my new defined action:

  • I’ve included MustachPrompt as first - it prepare mail (new draft) with filled variables
  • Second action is just Mail

but that workflow doesn’t work. MustachePrompt correctly create new draft and fill editor text with it but Mail action takes previous draft (which is just MustacheTemplate) and put into Mail window.

It seems that Mustache create new draft, fill editor by text from that new draft, but don’t update “current” draft for next action. I’ve tried to modify last script in MustachePrompt by setting:

 draft = d

but it not resolved the problem.

An action runs on a draft. That draft does not change in the course of the action.

I guess you are using this Mustache Prompt action from the directory.

If you want to run another action on the new draft it creates, you should queue that action. So, say you want to run the “Mail” action, you would do this at the end of the last script action…

if (mustache) {
	let d = new Draft()
	d.content = mustache
	d.update()
	editor.load(d)

	// ADDITIONS
	// look up the action you want to run
	let a = Action.find("Mail")
	// queue it to run on the new draft after this action finishes...
	app.queueAction(a, d)
}

(This is instead of including a Mail action step)

Thanks for fast response. Yes I did like you suggest and it works. Maybe I misunderstood the idea of creating new action. I thought that I can build in new actions based on already available actions without writing JS code, like:

  • create draft
  • send draft to mail (using mail action)
  • save draft to Dropbox
  • modify draft and set to script for write to SQL database

and all that in one new action (flow) created by me using as much as possible provided actions.

Am I wrong?

Don’t understand me bad, I like Drafts very much (it is only one Mac tool where I pay subscription without doubts). I just want to understand all aspects of of it.

There are actions that can be combined. There are actions that cannot. It just depends what they do and how they are written. Action can do vastly different things, including querying and working with your whole library of drafts, there’s no way they can just be treated like interchangeable LEGO pieces - you have to pay attention to what they are designed to do.

1 Like

One question yet - how to create action which can cooperate with next actions? How to transfer the context to the next stage? Is any description of that in documentation?

For the most part, the Drafts action steps themselves are building blocks you can combine if you are working with the current draft in the editor.

If you want an action that sends and email and a message in Message, then the “Mail” and “Messages” steps do that and you would just put them in the same action. Also want to save it to a file, add a “File” action step.

Scripts are the main exception to that…a script can do just about anything. It is open-ended. So, if you are trying to use other people’s actions that use scripts, you need to understand what they do to try to combine them with other functionality.

Hopefully that makes sense. Feel free to ask here (or Claude/ChatGPT are pretty helpful with creating Drafts actions as well) to clarify what you are trying to accomplish.