X-callback-url Support and Reference

I had a quick try with raw urls and it seems to all work fine here:

agenda://x-callback-url/create-note?project-title=My%20Project&title=New%20Post29&text=Hello%20World&on-the-agenda=false&start-date=yes

so the issue must be with how you set up the shortcut and how it generates the url.

Could we get an example of what getting an x-callback result might look like? I’ve had absolutely no luck getting anything returned on a simple create-note call in Shortcuts. The notes are created just fine, but the X-Callback Result variable doesn’t contain a thing.

First make sure you use version 5, earlier versions didn’t return anything. Next, the return value is an added parameter to your return x-success url. In other words, the call itself returns nothing, but if you provide a callback url with the x-success parameter, that url will be called with an additional parameter containing the return value.

For example, if you call it with an x-success parameter that is something like:

myApp://callmeback/123

we’ll call that on success as:

myApp://callmeback/123?note=someID

Hope that helps.

I think I understand. So to use the note ID, the shortcut would have to look something like…

agenda://x-callback-url/create-note?project-title=Project&title=Note&text=something&on-the-agenda=false&x-success=shortcuts://run-shortcut?name=Copy%20Agenda%20Note%20ID%20to%20clipboard

The result would be to create a new note in the project Project with the title Note and text something, and then to copy the note ID to the clipboard via an x-success callback to a Shortcut named Copy Agenda Note ID to clipboard.

Assuming the Shortcut works as prescribed, that would work?

Update: I tested it and it worked—sorta. I updated the “Copy” shortcut to create a full x-callback-url to open the ID’d note but can’t seem to make that work and I’m tired of trial and error right now. :wink:

Yes, so if you provide the following x-success URL:

It will be called by Agenda as:

shortcuts://run-shortcut?name=Copy%20Agenda%20Note%20ID%20to%20clipboard&note=123456

In the short cuts app you can then extract the identifier of the created note from the note parameter.

1 Like

Just an observation… Agenda doesn’t appear to be listed on the Apps page of http://x-callback-url.com which you reference above. You might want to get yourself on that list.

Thanks for the tip, I’ve pinged them.

There was some mention of providing search support with the x-callback API. I would settle for being able to open Agenda in the Search All “tab” with text I passed in the URL as a good starting point. This would allow for some basic Alfred integration for me.

Also, while I am thinking of it, is there a way to create a note in a project and category? It is possible to have duplicate project names in different categories. Or do I have to rely on the identifier?

On the first problem: Keyboard Maestro would likely give you a way of doing the paste-text-in-search thing via Select Menu Item actions. I think.

The list above is complete, so you can’t create projects at this point. There are a bunch of things there (eg listing projects, listing categories, adding projects, searching) still to do. No rest for the wicked!

2 Likes

Has your development team look at implementing a prepend to note action?

Append is wonderful and prepend may prove useful for keeping the most recent information at the top of a note versus scrolling to the bottom.

Maybe it’s possible. Maybe it’s not. I hadn’t seen it mentioned on any of the other comments.

I personally use Agenda’s URL scheme daily. Thanks for your effort!

It isn’t possible at the moment I’m afraid. Does it really need to be a prepend of text in the same note though? Wouldn’t it make sense to create a new note with the desired text? Given the default reverse chronological order this new note would sort to the top and as such keep the most recent info at the top of the project.

1 Like

Your reply makes me think I may not be using Agenda as intended. While the app doesn’t lock users into a specific workflow, there does appear to be an ideal paradigm.

If you have the patience, I can briefly explain how I use Agenda. I do welcome feedback from the community, and I am willing to adjust my workflow in favor of a more efficient process.

Currently, I keep several generalized Agenda projects (i.e., Finances) within broad Agenda categories (i.e., Family.) Within these general projects, I keep one note per specific project. For instance, last month my village sent out trash tax statements, so I created a note in the Finances project to keep track of the taxes. I updated this single note as I progressed through the project. I used Drafts to append text to the note with each update adding a timestamp followed by the update text.

I safeguard my events, only linking notes to actual events on my calendar. I do not assign new notes to the current date by default. I realize this causes complications with searching notes using Agenda’s date tools. Using the village taxes project as an example, I added the due date to my calendar and linked the tax note to that date. For projects not associated with a calendar event, I keep the note organized and updated but do not connect it with a date.

I hope I described my note setup clearly. I realize my workflow may not embrace all of Agenda’s functionality. I am happy to entertain other’s opinions or ideas if I can improve my workflow.

Your workflow sounds fine to me.

There is not really one way to use the app. It depends on the “granularity” of your projects as to what is best. For example, if you were finding that your notes for each project you have were getting really long and ungainly, you might consider making the real life project into an Agenda project, and splitting that really big note over several notes (eg one per week, one per sub-topic etc).

But if you find your notes are workable with the current setup, I think your approach is the right one.

1 Like

I am trying to set up a x-callback-url which will append a line to a note if it exists. If the note does not exist I am trying to use the &x-error parameter to add the note (with the intent of then putting an &x-success behind that to add the line). This currently works if the note exists, but it does not seem to add the note if it does not. Hoping someone can see what I am doing wrong.

`agenda://x-callback-url/append-to-note?project-title=Travel&title=test&text=testentry&on-the-agenda=true&date=today&x-success=shortcuts://callback&x-error=agenda://x-callback-url/create-note?project-title=Travel&title=test&on-the-agenda=true&date=today`

Thanks

Hmm, we haven’t tested this type of thing, to be honest. You are trying to call into Agenda while Agenda is still handling the previous request. I suspect that could lead to some odd behavior.

A way around may be to go back to shortcuts on error and issue the create-note there.

Ah, and you probably need to “percent encode” the special characters in the error URL, otherwise they could be confused for the first URL. Eg. & and ? etc.

To do this, you can use a web site like this:
https://meyerweb.com/eric/tools/dencoder/

Gives:
agenda%3A%2F%2Fx-callback-url%2Fcreate-note%3Fproject-title%3DTravel%26title%3Dtest%26on-the-agenda%3Dtrue%26date%3Dtoday

To add to Drew’s comment, the Shortcuts app has a URL encode step you can use in your workflow.

1 Like

I’ve just created a Shortcut that seems to almost successfully create a note with an image attachment using the URL scheme and base64 encoding. The image appears as a thumbnail in the note as I would expect; however, when I long press the image to get the image options popover, the “Preview” button does nothing. When I insert an image into a note normally, this button shows a full-screen version of the image. Does adding images via the URL scheme make the Preview function not work?

Can you give an example of how one would extract the note ID from Shortcuts after this step? I can’t seem to figure it out. See this Shortcut that I’m working on to create a new Agenda and Things item at once: I’d like the Agenda note ID to be passed into a new Things task, but am getting stuck.

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