Contents

sendMessage

An intent schema that sends a message with the associated parameters.

Declaration

var sendMessage: some AppSchemaIntent { get }

Discussion

To make your app’s actions available to Apple Intelligence, conform your AppIntent to a schema that describes your action to the system. If your app’s functionality aligns with the messages domain and one of your app’s actions matches the sendMessage schema, you can generate the properties and protocol conformance the schema requires for your intent implementation with the @AppIntent( .messages.sendMessage) Swift macro. To make your app work with Siri, see Apple Intelligence and Siri AI.

The following example shows an intent that conforms to the sendMessage schema:

@AppIntent(schema: .messages.sendMessage)
struct SendMessageIntent {
    var content: AttributedString?
    var destination: <#MessageDestination#>
    var subject: AttributedString?
    var attachments: [IntentFile]
    var audioMessage: IntentFile?
    var locations: [GeoToolbox.PlaceDescriptor]
    var links: [URL]
    var scheduledDate: Date?

    func perform() async throws -> some ReturnsValue<[<#MessageEntity#>]> {
        <#code#>
    }
}

Define a @UnionValue enumeration for the destination parameter, as in the following example, by typing the first few characters of messages_destination in Xcode and selecting it from the code-completion suggestions.

@UnionValue
enum MessageDestination {
    case people([IntentPerson])
    case messagePerson(<#MessagePerson#>)
    case messagePeople([<#MessagePerson#>])
    case conversation(<#ConversationEntity#>)
}

The schema supports the following system experiences:

  • Siri

  • Shortcuts

For more information about the App Intents framework and the experiences it supports, see Getting started with the App Intents framework.

See Also

Actions