如何在 alexa 中实现下一个意图 [英] How to implement a next intent in alexa

查看:29
本文介绍了如何在 alexa 中实现下一个意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何在 alexa 技能中实施AMAZON.NextIntent".假设我有 3 个音频(a1、a2、a3)排队,并且 a1 正在播放.如果用户使用nextIntent"发送请求,alexa 播放 a2 的响应应该是什么?

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 使您能够将状态保留在会话属性中.对于 Node.js,它是 this.attributes.您可以在 技能状态管理中阅读更多相关信息 部分.

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.

您可以在该属性中保留当前步骤.技能开始后,您可以将当前步骤设置为第一"(或 1,或其他).

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).

一旦 AMAZON.NextIntent 被触发,您检查属性的状态并决定接下来播放哪个音频文件.

Once the AMAZON.NextIntent is triggered, you check the state of the attribute and decide which audio file to play next.

类似于:

if (this.attribute['currentStep'] == 1) {
  playSound('a2')
}

您甚至可以稍后在 DynamoDB 中保留这些属性.检查该部分.

You will be able to even persist those attributes in DynamoDB later on. Check that section.

如果您没有为此使用 Node.js,我很确定其他语言也支持它.

In case you are not using Node.js for that, I'm pretty sure it is supported by other languages.

这篇关于如何在 alexa 中实现下一个意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆