I am using the AWS SDK to add a AWSLexVoiceButton to my app. I have it configured for client fulfillment in the Intent I set up, as I want to make the app show something on the screen based on voice command in the AWS Console for my Intent:
This all works, and I get a callback in the code below when the Bot recognizes my Intent:
func voiceButton(_ button: AWSLexVoiceButton, on response: AWSLexVoiceButtonResponse) {
// `inputranscript` is the transcript of the voice input to the operation
if response.dialogState == .readyForFulfillment {
print("Ready to fulfill")
// I want to provide speech output
say(text: "OK, I will show the train status screen")
showTrainStatusScreen()
}
}
Two problems:
When I tap the AWSLexVoiceButton, there is no audio indication that it is listening, and you see no indication you even tapped on the button unless you make a loud enough sound to cause its microphone sound detection animation. I can find no way to add a voice prompt like "How can I help you?" because there are no AWSLexVoiceButtonDelegate
callbacks when the button is initially tapped.
Q: Is there any way to add an audio prompt when Lex beings listening?
Similarly, there is no audio indication that the client is fulfilling the intent. Because there is a callback, I can add my own response. But to do so, I manually set up a AVAudioPlayer
and integrate with AWS Polly to convert my text to speech in a custom say
method I wrote. My approach works, but it seems like it must be the wrong way.
Q: Is there any way to trigger Lex to give a custom audio response as a result of client fulfillment?
You cannot provide a response via Lex without a request from the user. I'm not familiar with iOS, however in Android you can add this functionality within your application to handle this situation manually. I would guess iOS allows similar functionality. Please comment if I am wrong. Unfortunately, this is not something that Lex provides.
Lex will only respond once the fulfillment is complete. Since you do not require server side fulfillment, you can create a lambda function which does nothing except return the completion response you are looking for.
Hope that helps