How do you implement an 'AMAZON.NextIntent' in an alexa skill. suppose I have 3 audios(a1, a2, a3) enqueued and a1 is playing. If the user sends the request using 'nextIntent', what should be the response so that alexa plays a2?
Alexa SDK provides you ability to keep the state in session attributes. For Node.js it's this.attributes
. You can read more about here in Skill State Management section.
You can keep the current step in that attribute. Once your skill is started you can set the current step to "first" (or 1, or whatever).
Once the AMAZON.NextIntent
is triggered, you check the state of the attribute and decide which audio file to play next.
Something like:
if (this.attribute['currentStep'] == 1) {
playSound('a2')
}
You will be able to even persist those attributes in DynamoDB later on. Check that section.
In case you are not using Node.js for that, I'm pretty sure it is supported by other languages.
来源:https://stackoverflow.com/questions/48144499/how-to-implement-a-next-intent-in-alexa