Run Action Periodically, but Pause Until Flow App Doesn't Have an Active Session

I'd like to provide myself with periodic checkins during the day by loading a page with some questions in Notion.

However, I'd like to delay the checkins while the "Flow" app has an active timer, so I do not interrupt my focus sessions.

I see that the Flow app supports a getphase method, which returns "flow" when a timer is active.

While I'm familiar with JavaScript for the web, I'm new to using it for application scripting. I tried creating a periodically while logged in trigger, with a pause until conditions are met action, but I'm uncertain how to use JXA (I'm assuming the JAX reference in the app is in error) to check the condition.

Additionally, I'm not sure if there's any way to determine how often the the condition checks are made, or if it's possible to reset the periodic timer once the conditions are met. So if I want the checkins to happen every hour, but the active timer delays it 20 minutes, the next checkin should come an hour after the delay.

Thanks for any help you can provide.

What is the Flow app? Is it an application or a web page?

How would you access the getphase method outside of Keyboard Maestro?

Yes, already corrected for the next version.

The way I would do that would be something like:

  • Trigger every minute
  • Get the current time.
  • Check if the time the macro last successfully executed is at least 60 minutes ago and the getphase is not flow (however you do that).
    • If so, then execute the rest of the macro, and record the current time.

Flow is indeed a MacOS App. I'm unsure how to access the getphase method at this point, I just know it exists by looking at the scripting library for the app, and I'm guessing the return based on a similarly named Shortcuts method.

Interesting approach on checking every minute. I guess I'll need to store the time in a variable and do some date math.

Thanks

Just looking at the API/Scripts section of the documentation provides this AppleScript snippet:

tell application "Flow" to getPhase
1 Like

The AppleScript works like a charm. Will try digging into the date math next.

1 Like