I have a very simple script which I would like to run from the Apple Watch (Series 6). I created a shortcut which calls the Scriptable script but what I get is “Run Script”, I touch run and it just ends. I would like it to speak the result without any extra intervention. I know there are easier ways to do this without scriptable but I’m just trying to get a handle on how to get anything to work on the watch. I would also like it to show the results as text but when I tried to use the alert function that didn’t work on the watch either.
Here is the script:
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
today = mm + '/' + dd + '/' + yyyy;
var date1 = new Date('06/11/2020');
var date2 = new Date(today)
var Difference_In_Time = date2.getTime() - date1.getTime();
// To calculate the no. of days since Alan was born:
var Difference_In_Days = Math.round(Difference_In_Time / (1000 * 3600 * 24));
Difference_In_Days + " days old.”
Speech.speak("Alan is " + Difference_In_Days + " days old.");
This shortcut works from the watch for what you have above.
The key issue is that you are attempting to use Speech.speak(). You need to be in the scriptable app for Scriptable to be able to access the speech synthesis. You are running the script in Shortcuts, so Shortcuts is what has access to that, not Scriptable; plus Scriptable doesn’t have an Apple Watch component just yet (though Simon has been toying with complications in the last few days).
The workaround is simply to do the text generation in Scriptable, and then pass that back to Shortcuts to speak. That way, Shortcuts can speak it on the watch after the script runs as a purely inline action.
Got it. I look forward to more integration with the Watch. Having Shortcuts back in WatchOS is very nice and being able to extend the range of actions to include Scriptable would make it even more useful.