URL Triggers to Launch Shortcuts?

I’m trying to create a macro using a webhook whereby I can append the name of a macOS shortcut to the url and KM will launch that shortcut. I know I can do this manually, but rather than having to do this for all of my shortcuts, I’d like to simply create one macro which is dynamic and can launch any shortcut. I would appreciate any help. :grinning:

Lose the AppleScript? You should only need a single action:

image

...assuming your machine is on Monterey or newer (which is why I can't test it here).

I was excited to try this as it makes perfect sense, however I can’t seem to get it to work. I am using the very latest version of macOS. Not sure as it seems pretty simple. Could there be a hidden setting I’m missing?

Start with the basics. Is your macro triggering after you submit the URL -- check the last lines of the Engine log (available via the KM Editor's Help->Open Logs Folder menu item). If so, is the name being correctly passed as the parameter -- add a "Display text in Window" action with %TriggerValue% in the text field. Are you URL encoding the macro's name, if that's required?

You can even test "locally" with a single action "Execute a Macro" macro, set to execute your "Trigger Shortcut via Webhook" macro and passing the Shortcut's name in the "With Parameter" box.

I think I found the problem but don’t know how to fix it. When I display %TriggerValue%, it shows “TriggerValue=Remote”. So it would appear that it’s trying to run a shortcut named “TriggerValue=Remote” instead of just “Remote”.

When in doubt, RTFM:
https://wiki.keyboardmaestro.com/trigger/URL

You're calling the webhook w/ &TriggerValue=Remote right?

use value

I’m copying the url from the macro and appending the name of the shortcut.

https://trigger.keyboardmaestro.com/t/MyKey?TriggerValue=Remote

You're mis-understanding that URL

After the ? IS your TriggerValue

so https://trigger.keyboardmaestro.com/t/MyKey?Remote

1 Like

Boy do I feel stupid! Hours and hours over something so simple. You win a gold start my friend and I should be sent to the back of the room. Thank you so much for your help! :grinning:

1 Like

We've all been there my friend. Anybody who says they haven't made similar mistakes is lying!

2 Likes

Amen. :grinning:

1 Like

If this appears still too complicated for some users, there is 'Hookmark', which, although not cheap, will do a good service of linking different pages and apps (such as Mail.app), creating a hook.
hookproductivity.com

/
best regards,
OmarKN

I've made the exact same mistake. It took an embarrassingly long time for me to figure it out.