How to implement a next intent in alexa

旧街凉风 提交于 2019-12-08 07:57:40

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!