Relevant Shortcuts on Siri Watch Face

Abdul Aljebouri
6 min readOct 8, 2018

--

With the introduction of iOS 12 and watchOS 5, Apple has opened up Siri to developers. One of the ways it was opened up, that I was most excited about, is having 3rd party applications appear on the Siri Watch face. As an avid Apple Watch user, and a developer, I wanted to add this capability to my own app.

Shameless plugin for my own app. 😁

In this post, I’ll go through getting an informational shortcut to appear on the Apple Watch. Let’s start with some definitions.

  • An intent is a request that Siri can fulfill
  • A shortcut is an intent that you want the system to recommend or that you want to allow the user to add to Siri

An informational shortcut is meant to give the user glanceable information when they need it. For example, a weather app can show the user that it will rain between 3PM and 5PM. In this case, the intent is showing the user the weather conditions. An action shortcut is meant to give the user easy access to perform an action. For example, showing the user her favourite workout when she gets to the gym so that they can track a run. In this case, the intent is starting the workout.

Apple’s documentation found here states that a Watch application is not required to show shortcuts on the Siri Watch face. I, however, have not been able to get things to work without a Watch application present. This guide will have creating an empty Apple Watch app as one of the steps. You should customize the Watch app to show something relevant to the user.

The first step as usual, is creating a project. A Single View App will do.

Must’ve been through this a thousand times by now. 🧐

Next, let’s add a label, a text field, and a button to the main view.

No UX/UI designer was hired for this magical layout.

Connect the UI elements to the view controller class.

Run the app, and make sure things are fine. You should be able to enter a message into the field and upon tapping the button you should see the message label change.

Next we create an Intents definition file and call it Intents.

Then we create an Intent, call the intent ShowMessage.

Can be found at the bottom left in the Intents.intentdefinition file we created

Let’s call the intent ShowMessage and define it’s properties as below. The information added under “Custom Intent” is used when the shortcut is presented under Settings -> Siri & Search, when presented under Siri Suggestions when searching from home screen, and in the Shortcuts app. This section won’t affect what we are doing, since we won’t be donating the intent for it to be picked up in those places. One thing that will affect the shortcut is the Category of the intent. The category chosen will dictate the action that appears when tapping the shortcut. In this case I selected “View” because you “View” a message. While Apple has opened things up with custom intents, they still must fit into these categories.

I was hoping for a “Log” intent

The Title and Subtitle defined for the given parameter combination under “Shortcut Types” will determine how your shortcut will appear on the Siri Watch face. The Apple Watch is not very large, so be very terse in your messaging. The UI can be customized but the default style will be:

  • Application icon and name
  • Shortcut Title
  • Shortcut Subtitle

Let’s not forget to enable Siri capabilities for the project. This can be done by selecting the project from the Navigator, choosing the Target and going to Capabilities.

We will also create an empty WatchKit App. This can be done by selecting the project from the Navigator then tapping “+” to add a new target.

Once the WatchKit app is created successfully, we will need to update the Info.plist of the WatchKit app (not the extension) and adding a new row for NSUserActivityTypes, of type array, with one element titled ShowMessageIntent.

At this point, all the setup of the project is complete. Let’s go back to the code to donate the shortcut. Donating the shortcut lets Siri know what shortcuts to show the user and when are they most relevant. I’ve abstracted this logic in a class called IntentManager.

The main functions in the IntentManager are creating an Intent and donating a Shortcut. The ShowMessageIntent class is automatically generated based on the definition inside the Intents definition file we created earlier.

When creating the shortcut, we can define two things:

  • The role of the shortcut: action and information as discussed above.
  • An array of relevance providers: used by Siri’s predictive engine to determine when to surface your shortcut.

The relevance providers can be one of three types:

  • INDateRelevanceProvider used to let Siri know a period of time when your shortcut is relevant to the user. It takes a start date and an optional end date.
  • INLocationRelevanceProvider used to let Siri know a location where your shortcut is relevant to the user. It takes a region.
  • INDailyRoutineRelevanceProvider used to let Siri show your shortcut corresponding to a routine the user always has: when she is at work, in the morning, or when she gets to her gym.

If no relevance providers are provided, Siri will use machine learning to determine when shortcut is most relevant.

The last step is to add the logic to donate the shortcut. We do that inside the showButtonTapped function inside the ViewController class.

Run the Apple Watch app to make sure both simulators are running and that the app is started.

If this option is not available, you need to pair a simulator and watch together. To do this go to Window -> Devices & Simulators -> Simulators. Choose a device you want to pair with a watch and tap + under “Paired Watches”.

Once the app is running on both the Apple Watch and iPhone, make sure to go to the home screen on the Apple Watch and switch to the Siri face. Now, whatever you enter into the label and tap Show should appear on the Apple Watch.

Debugging

If the shortcut is not appearing on the Apple Watch face, go to Settings -> Developer on the iPhone and enable “Display Recent Shortcuts” and tap “Force Sync Shortcuts to Watch”.

Notes

Your users will not be able to tap “Force Sync Shortcuts to Watch”. So you should test on devices at some point without resorting to using this functionality. What that means is you have to wait for Siri’s AI to kick in and determine that your shortcut is the most relevant to show. There is a WWDC talk that goes over the prediction engine.

The sample project for this tutoriak can be found on GitHub here. If you found this post useful please leave a clap or two, and if you have any questions please leave a comment.

Update: I am currently working on project to help people complete their goals by turning goal tracking into an adventure game. Please sign up here to get the latest information about this project: http://eepurl.com/ggqKR1.

--

--