Request for a working example of remote trigger

Hi guys,

I'm a bit of a slow learner and am struggling to interpret the instructions for getting remote trigger working.

https://trigger.keyboardmaestro.com/t/<UniqueID1>/<UniqueID2>?TriggerValue

Could I please ask anyone who has a working example to show it, along with a screenshot of the macro showing the entry in the remote trigger field, and maybe if anyone else has the same problem we could even add a working example to the wiki? I know it's probably embarrassingly simple, I just don't understand...

Edit: That syntax above isn't showing up correctly, UniqueID1 and UniqueID2 should also be a part of it but its seems to get trunctated in the post for some reason.

[Moderator Edit: 2018-07-15 02:07 GMT-5. Put the http code above in a html Code Block.]

Take a look at this macro:
MACRO: @Web Open URL Passed from KM Web Server


From My Release Notes

Author.@JMichaelTX

PURPOSE:

  • Open ANY URL (including custom URL schemes) passed by the KM Web Server

HOW TO USE:

  1. Create a URL like this:
    http://127.0.0.1:4490/action.html?macro=<YourMacroUUID>&value=<TheURLYouWantToOpen>
    • where the <YourMacroUUID> is the UUID of this macro
    • and the <TheURLYouWantToOpen> is just that, but MUST be URL encoded.
  2. Execute the above URL from anywhere that will process normal, web, URLs.

WHAT IT DOES:

:warning: Warning! This uses the KM Public Web Entry, which may have some security issues. See KM wiki for details.

The KM Web URL is like this:
http://127.0.0.1:4490/action.html?macro=<YourMacroUUID>&value=<TheURLYouWantToOpen>

For example:

http://127.0.0.1:4490/action.html?macro=1238B406-69B6-4093-8E59-85431F7483AD&value=/Users/Shared/Dropbox/Your%20File%20Name.txt

Questions?

Are you sure you want to use a Remote trigger?

It might be easier to use the URL Scheme trigger.
You should also see URL Scemes in the Scripting article.

@haptic, it's not you. This is a complicated topic, and the wiki was poorly written.
I have revised two related wiki topics, and if you have time, I'd really like to have your feedback on the rewrite. You can get links to the wiki articles, and post your comments, here:
Wiki Update: Web Server and Public Web Trigger

Note these are still a work-in-progress, but I think they are complete enough for a review.

Thanks.

1 Like

Hi @JMichaelTX, I reviewed the web server wiki, the Public Web Trigger one reads fine to me but it might be because I had already absorbed most of it from reading the first entry and getting it up and running.

Having digested some (not all) of this, I am left pretty amazed and also slightly confused. The web server and public web trigger methods for remote control of KM work well, but the URL Scheme Trigger is just so quick and intuitive and easy to use I think I will go with that. Having seen all this I'm left wondering what remote trigger can offer that the other methods can't? Also I still don't know how to get remote trigger working but thats not so much an issue now.

I know these methods are all different, but they seem to me to have a great degree of overlap. Which is no bad thing, KM is pretty powerful after all. Does this all seem pretty reasonable to you more knowledgeable types?

Ultimately my goal was to have my computer email me when something went wrong with my macros, and prompt me to make a call on whether it should restart itself and get back to work or not. So using this URL Scheme trigger I can in very few clicks do that. I'll just bookmark the URL address on my phone and click the icon when I want to set it off.

1 Like

Sorry one other comment I have I can't seem to find an answer to-

why does URL Scheme Trigger give you four options?

Edit: No I am back in a land of confusion now- I assumed those 4 options would allow you to trigger the macro from any device anywhere but I can see that is not so because I tried it on my iPad and phone and neither worked.

Edit:
I get part of my answer now:

1 Like

So having said all this, here is what I suggest as a wiki entry "how to" for remote trigger.

  1. Select "remote trigger" as the trigger for your macro. 19%20pm

  2. Click on the string of Blue text, and not the copy button next to it. This will open up a browser. The address in that browser is your remote trigger.

  3. Make a copy of this and use it where you want.

I know there are other ways of doing this, I know remote trigger comes with caveats, and also that I'm probably not expressing myself clearly but do you get my gist?

2 Likes

Great suggestion. I'll try to update the Wiki soon.

There are several different ways to trigger a macro (probably more, but I'll leave it at these for this discussion).

They differ in a variety of ways, including security and remoteness.

The first three basically work only on your local Mac, and if you are triggering a macro from your local Mac, they are the ones to use. Which one depends on what you are doing on your Mac to induce it to be triggered. These have minimal security issues, since anything that can open files on your Mac, run AppleScript, or fire off URLs can almost certainly do a lot worse than running a macro.

The Public Web trigger works only if Keyboard Maestro’s built in web server is enabled, and for most people will work only within your local network, since almost everyone these days uses Network Address Translation and so you cannot access your Mac from outside your environment. Unless you don't have NAT (very rare), or you use a VPN or explicitly set up port forwarding, chances are you Mac cannot be executed from outside your own network. Thus these triggers are relatively secure, but can be accessed from elsewhere in your network (such as from your phone when you are also on your local network) or other Macs on your local network. Thus if you want access from elsewhere on your local network, this may well be the correct choice for triggering a macro.

The Remote Trigger works from anywhere on the Internet. It works via a http://trigger.keyboardmaestro.com/, which is a server that Stairways runs, and so Keyboard Maestro keeps a connection to the Stairways server, waiting for a trigger to come in, and you trigger it by accessing the Stairways server. These macros can thus be triggered from anywhere, so they have significant security implications. This is fine as long as your macro is relatively innocuous - for example I use it for displaying alerts if one of my systems goes down. If someone managed to trigger this macro the worst that happens is I get spurious alerts.

In theory, you can only trigger the macro if you know both the magic numbers in the trigger URL, which by default are UUIDs, so they have lots of random bits making them essentially impossible to guess. One is specific to your Mac, and one is specific to the trigger. Unless there is a need, you should use the random ones that Keyboard Maestro makes. However it is valid to have semi-public or public triggers, and multiple instances of Keyboard Maestro can have the same trigger, in which case all the different Keyboard Maestro’s with that trigger would execute the macro. For example, say you wanted multiple people to be alerted when some tickets go on sale, you could have single well known trigger value and anyone could trigger it all the Macs would be alerted. More likely you would use this in semi-public cases, say a macro for a bunch of Macs in a lab to tell them all to shut down.

In practice, if the Keyboard Maestro server was compromised, then any of the triggered macros could be triggered, so there remains additional risk on top of the secret trigger number being discovered. So it is a good idea to ensure the macros are innocuous.

The Copy button copies the same URL that you would get if you open it in the web browser and then copy the link.

Thanks for your suggestion. I have used it in this update:
Remote Trigger

Please feel free to post your comments here:
Wiki Update: Remote Trigger

Is it just me or does the "copy" button or linked blue URL (the same URL) only lead to a blank white page with only "0" on it - having not triggered any Macro?

The “0” is the number of macros that have been triggered.

Your macro is probably disabled or otherwise inactive.

Is there someplace else that I need to enable it?

34%20PM 12%20PM

The Keyboard Maestro web server has nothing to do with the Remote trigger - Keyboard Maestro’s web server does not even need to be enabled.

The Remote trigger works through our server (trigger.keyboardmaestro.com). So your Keyboard Maestro, on your Mac, when the trigger is active, will contact our server and register itself, and then stay connected, and when you use the link, the server will report the event to all the connected Keyboard Maestro’s with a matching trigger.

The fact that the URL is returning 0 means that the server does not know of any matching triggers.

So if the macro group is enabled, and active, and the macro is enabled, and your Mac can connect to the trigger.keyboardmaestro.com server, then it should work.

Well, I don't know what I'm doing wrong then. I am connected, everything is enabled but any of those trigger links get me to the server and I just get that white "0" page.

I found the issue!!! It was a VPN thing. Fixed it and the remote triggers work flawlessly! Thanks for your help anyway.

1 Like