Contents

AppIntent

An interface you use to express app-specific actions and make them available to the rest of the system.

Declaration

protocol AppIntent : PersistentlyIdentifiable, _SupportsAppDependencies, Sendable

Mentioned in

Overview

The AppIntent protocol defines the interface you use to make your app’s actions discoverable by Apple Intelligence and Siri, the Shortcuts app, and other system experiences. This protocol defines the common features that help the system identify your app’s actions and access basic information about them. Implement this protocol in all your app intents, and supplement it with other protocols as needed to support specific types of actions.

Implement this protocol in a new type or existing type in your app, app extension, framework, or Swift package. In your type, use the perform() method to perform the action and return a result back to the system. If you require input from the person performing the action, add one or more variables to your type and apply the @Parameter property wrapper to each. For example, an app intent to start a workout might require the person to specify which workout they want. Before calling your perform() method, the system resolves any parameters with this wrapper by inferring values from the current conversation or by asking someone explicitly to provide the value. If your app intent requires app-specific data to perform its action, apply the @Dependency property wrapper to any variables with that data.

In addition to performing an action, an app intent provides information about the action itself. Implement the title and description properties and set them to localized strings describing your action. If your app intent has parameters, fill in the parameterSummary property with a description of the action and parameters together. The system uses this information during conversations or when displaying information about your intent.

The following example shows an app intent for ordering an album of music. The intent requires the person to specify the album name at order time. The intent also uses an internal album manager type to locate albums by name and initiate the purchase.

struct OrderAlbum: AppIntent {
    static var title: LocalizedStringResource { "Order Album" }
    static var description = IntentDescription("Order a vinyl record album.")

    @Parameter(title: "Album", description: "The name of the album to order.")
    var albumName: String

   @Dependency
    private var albumManager: AlbumDataManager

    func perform() async throws -> some IntentResult {
        // Perform the action...
        return .result()
    }

    static var parameterSummary: some ParameterSummary {
        Summary("Order \(\.$albumName)")
    }
}

In addition to this protocol, you can define intents that support common actions. System-defined schemas define the requirements needed to support common actions, including the app intent protocol your type needs to adopt and any parameters it needs to define. For example, the AssistantSchemas.PhotosIntent.openAlbum intent requires conformance to the OpenIntent protocol and a property with an AppEntity type for the photo album. For information about the available schemas, see doc:app-intent-domains.

For additional app intent protocols you can adopt in your app, see App intent types. For information on how to create an app intent, see Creating your first app intent.

Topics

Creating an app intent

Specifying the authentication policy

Specifying the intent’s allowed target

Configuring the metadata

Performing the action

Running in the foreground or background

Requesting more information

Requesting confirmation

Donating the intent to the system

Summarizing the parameters

Deprecated

See Also

App intent definition