IntentPrediction
A prediction for an app intent that the system might display to someone when it’s relevant.
Declaration
struct IntentPrediction<Intent, T> where Intent : AppIntentOverview
Use the IntentPrediction type to provide a description of your app intent that the system can use when offering proactive suggestions. You create this type from the predictionConfiguration property of your app intent. Use the type to provide a DisplayRepresentation structure with a suitable description of your app intent’s purpose.
The following example shows an implementation of the predictionConfiguration property that creates an IntentPrediction type. During creation of the type, the code passes the app intent’s name property to the IntentPrediction initializer, and maps it to the name parameter in the closure. The description incorporates this value in the text it provides.
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> {
...
}
}Topics
Creating a prediction
init(displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)init(parameters:displayRepresentation:)