If I have Search intent which basically a deeplink to my search screen. How to update it to integrate naturally with Apple Intelligence scehem

Generated on 8/2/2024

1 search

To update your search intent to integrate naturally with Apple Intelligence, you can follow these steps:

  1. Define Your App Intent: Ensure you have an app intent that represents your search functionality. This intent should conform to the new assistant schema for search. For example, if you have a method in your app that routes users to a search results page, you can expose this functionality to Siri.

    @AppIntent
    struct SearchPhotosIntent: AppIntent {
        static var title: LocalizedStringResource = "Search Photos"
        
        @Parameter(title: "Search Criteria")
        var criteria: String
        
        func perform() async throws -> some IntentResult {
            // Your code to perform the search
        }
    }
    
  2. Add Assistant Schema: Add the new assistant schema for search to your app intent declaration. This allows Siri to route users directly to your search results UI.

    @AppIntent
    struct SearchPhotosIntent: AppIntent {
        static var title: LocalizedStringResource = "Search Photos"
        
        @Parameter(title: "Search Criteria")
        var criteria: String
        
        @AssistantSchema
        static var schema: AssistantSchema {
            AssistantSchema(
                domain: .system,
                intentType: .search,
                parameters: [
                    .init(name: "criteria", type: .string)
                ]
            )
        }
        
        func perform() async throws -> some IntentResult {
            // Your code to perform the search
        }
    }
    
  3. Test with Shortcuts: Use the Shortcuts app to create a new action and test your search intent. This helps ensure that the intent works as expected before integrating it with Siri.

    // Example of creating a shortcut action
    let shortcut = Shortcut(name: "Search Photos", intent: SearchPhotosIntent(criteria: "San Fran"))
    
  4. Leverage Apple Intelligence: With the new capabilities of Apple Intelligence, Siri can perform semantic searches. This means Siri can understand the context of your search criteria and provide more relevant results.

    // Example of semantic search
    let searchResults = try await Siri.performSemanticSearch(for: "pets")
    

For more detailed information, you can refer to the session Bring your app to Siri.

Relevant Sessions

  1. Bring your app to Siri
  2. What’s new in App Intents
  3. Platforms State of the Union

These sessions provide comprehensive guidance on integrating your app with Siri and leveraging the new capabilities of Apple Intelligence.