Things/Agenda Crosslinked Item Shortcut

I’m trying to write a shortcut that creates a new item in both Things and Agenda, and adds a link to the other app in the notes of each. I think this should definitely be doable with x-callback-url, but I’m stuck on the last step where I want to get the Agenda note ID into the Things task. I can’t figure out the x-success URL that will achieve this. Can anyone take a look and let me know what I should be doing in the last step?

Shortcut here: Shortcuts

After a quick look on your shortcut a guess from my side: the x-success url gets call from agenda with additional parameters like note:. But you somehow have to tell Things what to do with this parameter.
So I would process the x-success event within the shortcut and craft a dedicated update call to Things.

That’s exactly what I’ve been trying to do, but I can’t figure out for the life of me how. Here’s another version of the shortcut, where I try to call the x-success URL without using Shortcuts’ built-in “x-callback-url” action, which seems like it might be iffy. But this isn’t working any better currently. (Actually I’m now getting a Things error that says “The parameter “i’d” must be provided”, but I’m definitely providing the correct Things ID parameter.)

https://www.icloud.com/shortcuts/ba8391f7a7594ee9bcd3f42913007601

agenda://x-callback-url/open-note?project-title=Project&title=Note

Maybe this shortcut is doing the trick, where you provide the project and the notes title instead of the agenda ID.

While creating the agenda note via x callback url you already provide those information, so why not paste them into the things task?
I do so In OmniFocus and it works perfectly.

Well, I was planning on creating items with the shortcut that would land in an Agenda project called “Inbox”, and then I would process my inbox and it would move to a different project. So the Agenda URL, which refers to a specific project, would no longer work after the item changes project, which theoretically it would always do at some point.

EDIT: It seems the Agenda URL could open notes just based on note title, not project… but I think I will probably have more than one note/task with the same title, but living in different projects, so I’m not sure how that would work.

So I have been trying to figure this out for the last couple of days as well and have a very similar Shortcuts script to you but am running into the same issue. My notes below.

Linking to Agenda note in Things using multiple criteria
I don’t think there is anything wrong with the x-callback script you are using but when it is parsed by Things the second “&” in the Agenda link (e.g. agenda://x-callback-URL/open-note?project-title=Project**&**title=Note) is actually parsed by Things as being part of its input arguments and as it isn’t recognised can cause some strange looking links or is skipped completely. This means you can only link by name or Agenda identifier.

The Agenda x-callback-URL scheme
So when the Agenda URL is run in Shortcuts (same example as above) it seems that it is properly executed in Agenda (given the note is created) but I can’t seem to find any evidence that Agenda provides a return x-callback to the source app including the note identifier. I have tried the suggested workaround by providing a custom x-success url that runs another shortcut to copy the identifier but I still can’t find any evidence that the new “copy” shortcut app receives Agenda’s appended “note” parameter. Likely because the shortcuts:// scheme doesn’t seem to recognise the “&note=” portion of the x-success URL.

Not sure how to fix it but it would be good if the identifier was returned to the source app as a string in the same way that Things and other apps work.

1 Like

Yep, that’s the conclusion I reached as well.

In terms of debugging this, does it help to try using a standard http url as x-success instead of shortcuts. I think that will then open in Safari, and you can actually look at the URL to see if it has the identifier.

I set up a simple create note callback with a custom x-success URL that is a http:// address. All came back with an iOS error that says: “The operation could not be completed. (InterchangeCall-backErrorDomain error 0)”.

You could for example try: x-success=https%3A%2F%2Fapple.com

Note that it should be URL encoded. Eg. using https://www.url-encode-decode.com

If you test that, it should open Safari, and include the note details in the parameters. Just look at the URL in Safari and see if they are there.

(Note that I think you need https, not http, otherwise Agenda doesn’t have permission to open it)

When I try that, the URL seems to do nothing… Safari doesn’t launch.

I just tested this URL On My Mac in Safari: agenda://x-callback-url/open-note?title=Blind%20Faith&x-success=http%3A%2F%2Fapple.com&x-error=http%3A%2F%2Fms.com

This will open a note called “Blind Faith” in Agenda. On success it goes to apple, and on failure to ms. Perhaps try this in Safari on iOS, and see if it works. If it works, it may give you clues about what is wrong with the Shortcut.

What exactly are you putting in the x-success field? I guess it will depend on how that is being set, because Shortcuts may automatically do the percent escaping for you.

Drew

When I try that link on iOS, I’m sent to ms.com with the following URL:

https://www.morganstanley.com/?reason=The%20x-success%20URL%20may%20be%20for%20another%20device.%20Not%20authorized.

I also got this result when building the same link from scratch on iOS using a note that I know exists in my copy of Agenda. I did it with both the %20 and with just a space in the note title. Shortcuts seems to convert spaces into %20 automatically so I think either should work.

By the way, I tried it both with http links and https links for the Apple and ms.com URLs.

In my Shortcut, I tried putting in the custom X-Success URL field the following three things:

x-success=https%3A%2F%2Fapple.com

https%3A%2F%2Fapple.com

https://apple.com

None of these seemed to work.

Ah, I realize now why the test is failing: we have a security measure that does not allow x-success to use the web. The reason is that someone could setup a link, seduce you to click it, and have data transferred from your Agenda to their web site via x-success.

This makes it a bit more difficult to test, but x-success should work via the shortcuts or other URL schemes (drafts?)

Well, I tried it with this Drafts URL:

drafts5://x-callback-url/create?text=

But that returned nothing, which I kind of expected. I’m honestly not sure how to construct an x-success URL that would return the note ID that I want to see. That’s basically the whole problem.

I guess one problem here is how you convert the parameters that Agenda passes (eg note id) into something that Drafts can process. I’m not really sure how people are doing this. I assume they use the x-success to go back to the shortcuts app, extract the parameters, and then make a new request to drafts with parameters it understands.

Anyone got some insight into this? Is there something we need to change about our x-success URLs to help?

I’m not really sure how people are doing this. I assume they use the x-success to go back to the shortcuts app, extract the parameters, and then make a new request to drafts with parameters it understands.

I’ve seen no evidence that anyone has done this successfully with Agenda’s URL scheme. If you’ve seen it done successfully, please show me where and I’ll gladly copy it.

Is there something we need to change about our x-success URLs to help?

The URL scheme I’ve used the most before is Things’. I would humbly suggest you look at it. Here are some basic examples of Shortcuts using both URL schemes that you can compare and contrast:

Things URL Scheme Example: Shortcuts

Agenda URL Scheme Example: Shortcuts

Notice that in the Things example, the task ID is the return value once the URL is opened. In the Agenda example, which is set up the exact same way, there is no such return value.

1 Like

OK, I think the only problem there is you are using “AgendaID” as the parameter, when it should be “note”.

Take a look at the shortcut page. Go down to the one for creating a note, and look at the “result parameter”. That is what comes back in the x-success. There is no standard for that. Every app can return something different. Agenda returns the note identifier as “note”.

“AgendaID” is just a variable name I made up within Shortcuts as something to store the return value of the URL. Changing that variable name to “note” makes no difference. The shortcut still demonstrates that the URL produces no return value, which differs from other URL schemes I’ve used. Again, if you can show me an example of an Agenda note ID being returned from your URL scheme, I’d be happy to emulate it, but I’ve been spinning around over and over trying to get one out.

OK, I’ve tracked down the problem. It’s really dumb: we did implement all the result passing, and it works fine on macOS, but somehow we forgot to add the few lines of code on iOS to pass the results back. I have done that now, and it works with your Shortcut.

This will be in a version for iOS in a few weeks I expect.

Sorry for the trouble. Thank you for reporting the issue and persisting until the problem was found. (For some reason nobody else reported it that I am aware of.)

Kind regards,
Drew

4 Likes