如何在 alexa 中实现下一个意图

编程入门 行业动态 更新时间:2024-10-06 06:52:33
本文介绍了如何在 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 中实现下一个意图

本文发布于:2023-11-28 04:20:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640932.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:意图   如何在   alexa

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!