Chaining x-callback-urls does not work as expected

Hi,
Thanks for Drafts5. It’s awesome and I believe it can greatly help me.

Here’s what I am trying to do:

  1. Write text in Drafts5
  2. Use a workflow to parameterize the document’s title to use it in the jekyll file name scheme
  3. Use action “URL” to call a callback-url to working-copy like so: working-copy://x-callback-url/write/?repo={{my_jekyll_repo}}&path={{_posts/}}[[date]]-[[workflow_result]].markdown&text=---%0a{{layout: post}}%0a{{title: "}}[[title]]{{"}}%0a{{categories: "newsletter"}}%0a{{date: }}[[date]]{{ 15:00:00 +2000}}%0a---%0a[[body]]&key={{secret-key}}&x-success=drafts5%3A%2F%2F
  4. Use action “URL” to call working-copy again and make a commit: working-copy://x-callback-url/commit/?repo={{my_jekyll_repo}}&limit={{3}}&message={{broadcast}}&key={{secret-key}}

The step (4) produces the error Unable to open URL, but without any further infos. If I use step (4)’s callback url as the URL in step 3, it works without problems.

What I tried:

  • use x-success parameter (with double encoding url params), to call the working-copy commit-callback. I guess, you cannot call an app from within an app?

Any idea how to proceed here?

I was thinking to call Workflow.app in Step (4) again and call the commit-callback from there? Haven’t tried it yet…

Thanks.
Holger

I believe your problem is due to the inclusion of the x-success in part 3, the documentation says not to include it:

Thanks for your answer. I used the URL action, not the Callback-URL action. You can specify x-success there.

But, more importantely: I solved it already.
In this article: https://www.macstories.net/tutorials/guide-url-scheme-ios-drafts/
I found the clue. Chaning three actions like that with callbacks almost never works. The author doesn’t know why. But if you chain a drafts5://x-callback url with another action, than that get’s called and it works.

Like this:

working-copy://x-callback-url/write/?repo={{my_repo}}&path={{_posts/}}[[date]]-[[workflow_result]].markdown&text=---%0a{{layout: post}}%0a{{title: "}}[[title]]{{"}}%0a{{categories: "newsletter"}}%0a{{date: }}[[date]]{{ 15:00:00 +0200}}%0a---%0a[[body]]&key={{secret-key}}&x-success=drafts5%3A%2F%2Fx-callback-url%2FrunAction%3Ftext%3D%26action%3DCommit-in-Working-Copy%26allowEmpty%3Dtrue

So at the end, I just included (url-escaped) the following callback:

drafts5://x-callback-url/runAction?text=&action=MyActionName&allowEmpty=true

And this way I can even chain in another action, if I add another x-success calback again.

Works like a charm. I now have a Jekyll publishing powerhouse that looks like an iPad :wink:

That is the purpose of the Callback URL step/script object, as Rose pointed out.

If you use a URL step, you are leaving drafts and the action continues and finishes. The callback URL step can wait for a result from another app. This is what you want if you do not need a result or to continue the action - e.g. opening a web search.

The Callback URL step (set to “wait for response”) adds it’s own keyed callback parameters, pauses execution of the current action and waits to receive the callback response from the target app to continue - so you can sequence multiple callbacks in one action using it.

Chaining works as well, but there’s no reason you could not do this in one action with the Callback URL step.

I would note also this has the advantage of holding processing of any after success settings until after the completion of the callback.

1 Like

Thank you for clearing that up. I hope I understood everything correctly.