Christopher's HealthKit App Challenge Journal

Siri Shortcuts

For a shortcut, the idea is to tell you how much progress you’ve made to your daily or weekly goal.

For this purpose, I can reuse the SiriKit Intent Definition File I used for the Widget. Of course, I had to configure it some more for use with Siri and Shortcuts.

An Intent Definition File essentially tells Siri what it should expect as input to perform an action, what to expect returned from the action, and how to display information.

For a Widget, this file dictates the input, not the output, which is your Widget view.

Something this file doesn’t do for you is process your input and gather the information for your response.

Just like a Widget, Xcode generates some files for you when you add an Intents Extension to your project. One of these files is the IntentHandler, which you have to code.

This alone is enough for Siri to return information if you create a shortcut in the Shortcuts app.

Depending on the configuration of the Shortcut, Siri will also ask for the parameters of your intent.

I also set up Shortcut donation, or if you do an action, it will appear as a Suggested Shortcut from your app. When a drink exists, “View Daily Intake” and “View Weekly Intake” will be donated.

Now you can create a custom UI for your shortcut, an IntentsUI, but you have to use UIKit for this. As I’m not as experienced in UIKit I skipped this, but it’s something you can do.

This is the resource I used if you’re interested in doing this yourself:

I want to try to display data in the form of a chart or graph. So, over some period of time, you could see your intake graphically. This includes overall and for specific drink types. I do want to expand this past the Daily and Weekly Intake the app already displays. I also think this could be incorporated into another Widget and Shortcut. This might be a new tab in the app altogether or just a rework of the current Logs tab.

2 Likes