Triggering Keyboard Maestro macros remotely

whatsnew
km8

#1

Before version 8, there were a couple ways of triggering Keyboard Maestro macros remotely, but none of them were particularly great.

You could use the Keyboard Maestro web server, either directly or from the Keyboard Maestro Control iOS application (which is very old and outdated, sorry!), but that generally only worked on a local network (unless you have a real NAT-free connection to the Internet or set up port forwarding on your router, both of which are very rare these days).

Or you could make some sort of hack using Dropbox or iCloud Drive and sending a file to your Mac somehow to trigger a macro that way.

But Keyboard Maestro 8 introduces the Remote trigger that lets you trigger a macro from anywhere on the Internet. This allows you to integrate with network services like IFTTT or HealthChecks.io. For example, I use HealthChecks.io to monitor my servers and report if they go down, and it reports by triggering a macro that puts a big red floating window on my screen as well as sending me an iMessage.

The Remote Trigger has essentially two parameters, which are usually two unique IDs (essentially passwords). One can be set to an ID for your Mac (so that if you sync your macros, only one Mac will fire), or it can be set explicitly (in which case it would be synced to your other Macs and all of them would fire). The second one is always explicit.

While you can change the unique IDs that are pre-selected, I would encourage you to leave them as the random IDs that Keyboard Maestro generates unless there is a very good reason to change them. A reason you might change the IDs might be for a trigger you explicitly make public.

Note that these two IDs together are shared by everyone using Keyboard Maestro. So if you make a Remote trigger for “a/b”, don’t be surprised if others end up triggering - keeping the random UUIDs is still a good idea for this reason.

There are a bunch of caveats for the trigger, not least among them are:

  • Anyone who knows the IDs used in the Remote Trigger can trigger the macro - so keep them secure, and limit your use to macros that are relatively safe to run (for example, if someone managed to trigger my HealthChecks.io warning, no real harm would be done).

  • The trigger happens by connecting to a Stairways web server, and by Keyboard Maestro keeping in touch with the Stairways web server. That means that a) any Internet outage between the client, the Stairways web server, and the target Mac might block the trigger; and b) since Keyboard Maestro is not sold as a service, this part of Keyboard Maestro is not guaranteed indefinitely, eventually the server will stop working and so will this trigger.

I look forward to seeing what people do with this new facility.


#2

Hi,

Do i need to keep the web server option enabled to use the remote triggers reliably? I have a 2017 MBP and the remote trigger option isn’t working reliably for me. It does work if the web server option is disabled (but its not reliable). After a few hours it stops working and it will then take a few hours for it to start working again. And once I enable the web server the remote triggers seem to wok reliably. So is enabling the web server a requirement to ensure reliable working of remote triggers? or is it some other issue (because the remote triggers do work intermittently even if the web server is disabled)?


#3

No, remote triggers (ie, triggers using the Remote trigger) have nothing to do with the Keyboard Maestro built in web server.

The remote triggers work by Keyboard Maestro keeping a “long poll” connection to the trigger.keyboardmaestro.com web server. I would guess that some part of the connection between your Mac and the server is timing out the connection and so when the message finally comes through, it can’t get from the trigger.keyboardmaestro.com web server to your Mac. If having the Keyboard Maestro web server on makes a difference, then my guess would be that the issue is local to your Mac, so your Mac is deciding not to bother remembering the connection or something like that.

I’m afraid debugging the issue or determining where the problem might lie for your network setup sounds very challenging to me.


#4

Hi,

Thanks for the quick reply. Is there a log that keyboard maestro uses to
keep track of the connection status?

Also you said the app uses a long poll connection and that timeout could be
the reason. So why doesnt the client (my mac) reinitiate the connection
when there is a timeout? I mean it takes hours ours for the trigger to
start working once it stops. So im guessing my mac isnt initiating any
connection during that period (assuming a timeout occured).


#5

Keyboard Maestro will reinitiate the connection if the connection is dropped.

But if there is something in-between that forgets about the connection but doesn’t tell the system, the the connection appears alive to Keyboard Maestro, but the trigger message doesn’t get through. But really that is just a guess, I have no idea.

There is debugging you can enable to see what is happening with the connection status. Run the Terminal command:

defaults write com.stairways.keyboardmaestro.engine Debug RemoteTriggerMonitor

And then relaunch the Keyboard Maestro Engine (File ➤ Quit Engine, File ➤ Launch Engine).

Then the trigger connection status information will be logged in the Engine.log file (Help ➤ Open Logs Folder).


#6

Thank you. I will have a look at the log.