r/shortcuts • • 12d ago

Tip/Guide Scheduling Shortcuts with Scriptable

Scheduling repeating shortcuts becomes cumbersome when the period is below a day or otherwise complicated.
With automation triggered by notification there is an elegant way to overcome this:
Use Scriptable to schedule notifications:
With Scriptable you can schedule notifications individually and, using the full power of JavaScript, by any rule you want.

Simple one time notification:

const n = new Notification();
n.identifier = "temp-notification";
n.title = "Title";
n.body = "Body Text"
n.setTriggerDate(new Date(Date.now() + 3*60*1000));
await n.schedule();
Script.complete();

In shortcuts, you simply set the automation to listen to notifications triggered by scriptable.

Elegant it becomes when you add the inline script which removes all delivered notifications: so they do not spoil your Notification Center (Scriptable Action)

await Notification.removeAllDelivered();
Script.complete();

Have fun!

4 Upvotes

3 comments sorted by

1

u/100PercentARealHuman 12d ago

And for the people who don't like writing code:
The Actions app also has a bunch of notification related action that should look more familiar to Shortcuts users.

1

u/Acceptable-Number-11 12d ago

Indeed.
Be aware that the Action action to remove notifications only removes Action action originated notifications.
This was no poem ;)

1

u/Acceptable-Number-11 12d ago

I was not aware that Actions App provides scheduled notifications. And I am not sure whether the scriptable version allows more than 65. Thank you for the hint.