We have a simple AppIntent to let users ask a question in our app.
The intent has a single parameter: Prompt which is retrieved by a requestValueDialog.
Users have reported that when using Siri, the dialog for "What would you like to ask?" appears, but if they respond with phrases such as "What is the last album by Sting" it just presents the dialog for the prompt again.
Testing it, I find that I can reproduce the behavior if I include words like "recent" or "last". Just providing those words in isolation causes the dialog to be presented over and over again.
Using the same intent from Shortcuts does not seem to have that limitation, it's only when providing the spoken words for speech recognition.
All of that interaction happens outside our code, so I cant see any way to debug or identify why the prompts are being rejected. Is there a different way to specify the @Parameter to indicate the prompt: String could include any arbitrary text - including "recent" or "last" ?
My hunch is those words are triggering a system response that is stepping on the requstValueDialog?
Here's the basics of how the intent and parameter are setup:
struct AskAI: AppIntent {
static var title: LocalizedStringResource = "Ask"
static var description: IntentDescription = IntentDescription("This will ask the A.I. app")
static var openAppWhenRun = false
@Parameter(title: "Prompt", description: "The prompt to send", requestValueDialog: IntentDialog("What would you like to ask?"))
var prompt: String
@MainActor
func perform() async throws -> some IntentResult & ProvidesDialog & ShowsSnippetView {
var response = ""
...
response = "You asked: \"\(prompt)\" \n"
...
return .result(dialog: "\(response)")
}
static var parameterSummary: some ParameterSummary {
Summary("Ask \(\.$prompt)")
}
}