PredictableIntent
An interface that indicates the system can suggest the intent as a potential action to run.
Declaration
protocol PredictableIntent : AppIntentMentioned in
Overview
Add support for the PredictableIntent protocol to an app intent to improve the descriptions that the system displays for your app intent. When making proactive suggestions in interfaces like the Siri Suggestions widget, the system displays the descriptions you provide using this protocol. Create descriptions that explain your action clearly and concisely using only the parameters you find relevant. For example, you might build a description that incorporates only one of several of the app intent’s parameters, if doing so leads to a more concise phrase.
In your implementation of this protocol, provide one or more IntentPrediction types in the predictionConfiguration property. In each intent prediction, convey the purpose of your app intent using zero or more parameters. The following example shows an app intent offers a description using only the name parameter of the app intent.
struct CreateBook: AppIntent, PredictableIntent {
@Parameter(title: "Book Name")
var name: String?
@Parameter(title: "Author", query: AuthorQuery.self)
var author: AuthorEntity?
static var predictionConfiguration: some IntentPredictionConfiguration {
IntentPrediction(parameters: (\Self.$name)) { name in
DisplayRepresentation(
title: "Create a book named \(name)"
)
}
}
@MainActor
func perform() async throws -> IntentResult<BookEntity> {
...
}
}