Unfortunately that really doesn’t address the fundamentals of what I was asking which was for you to share what you actually have and what you are stuck on. I understand that you have taken one of the many possible actions and tried to do something with it by deleting some of its content, and something about it fails.
What I do think I understand now, is that you don’t want two things, but just one thing, and either would do.
So let’s try tackling this from a different angle. This isn’t a solution, but perhaps(?) a guess in the right direction.
Let’s take it that you will trigger a Drafts action via a voice command from a Shortcuts shortcut.
Here’s an example action that can do that.
Now I’ve happened to link this to a Todoist action I downloaded from the action directory.
When run, this allows me to copy the basic task listing from a Todoist project into a new draft with a Markdown heading on the first line as the project name and tasks added to lines below that as Markdown bulleted items.
If I then modify the title (or even if I don’t), I then could use a second action (this could be triggered by a Siri voice command via Shortcuts to create a new project based on the title and then reverse the process.
Next a couple of caveats.
Todoist assigns unique identifiers to projects. The project name is not a unique identifier. Todoist allows you to have multiple distinct projects with the same name … which makes it impossible to reliably use quick add to add a task to the correct project by name.
Project names with spaces cannot be reference by Todoist’s quick add. At lest it never used to back when I used Todoist a lot, and I don’t see anything in a quick Google search to convince me that has changed.
I mention these because the next part uses quick add. Its just a demo after all, but if you have unique project names with no whitespaces, then quick add can be sufficient.
Next I picked up an action from the Action Directory that looked like it would do this sort of thing.
It turned out that this was based on a previous suggestion I’d made to someone on the forum last year … and that also references the spaces in project names limitation.
I took that as a starting point and made a modification such that rather than hard coding the project name, it simply took it from the heading on the first line (the draft’s title).
The result was this action.
Now we have a known set of actions that will copy a project out of Todoist into Drafts, that we can then modify the first line of and have it create a project and populate it in Todoist with the same tasks; or others if we happen to modify the source draft.
Perhaps yo already have something like this? Perhaps this is not the sort of thing you are after ad I’ve got it entirely wrong. But now we have some specific examples to reference and that maybe you can tailor to meet your requirements now, or with further guidance from the community.
Let’s see what’s next.