Alexa Skill 的单项答案
Single term answer to Alexa Skill
背景
我正在编写 Alexa 技能并希望从用户那里获取信息。
以下对话为例:
Alexa: What month were you born at?
User: April
Alexa: Good. And what was your favorite movie?
User: April
问题
给出以下语句:
GetMonthIntent {month}
GetMovieIntent {movie}
一旦用户第二次回答April
,可能会触发GetMonthIntent
。
我试过的
要求用户指定使用以下语句提供的条信息:
GetMonthIntent Month {month}
GetMovieIntent Movie {movie}
问题
让 Alexa 根据当前上下文等待单个术语答案的正确方法是什么?
很遗憾,没有解决办法。无法指定应在其中解释用户回复的 'context',因此您必须告诉用户 "what was your favorite movie? Please say 'my favorite movie is' and then the name of the movie".
以下是我认为可以解决您的问题的两个 ASK 功能请求:
https://forums.developer.amazon.com/content/idea/41062/creating-something-to-help-with-more-structured-qu.html
https://forums.developer.amazon.com/content/idea/55525/allow-a-response-to-specify-a-set-of-expected-inte.html
我个人认为这是相当重要的,所以我投了这些票,但它们还没有排在最前面。
我 运行 在创建 "Who's on First? Baseball Skit" 技能时遇到了同样的问题。我通过以下方式处理了这个问题:
- 为 Alexa 给出的每个响应创建一个序列号
- 将此数字写入响应中的 "session"。
- 然后 Alexa 在下一个请求中将会话传回给您的技能。
- 从请求中读取序列号以了解上一个问题是什么。
- 如果给定的意图可能是多个问题的答案(例如,在您的情况下是月份和电影),则使用序列号来确定它是哪个。
这应该会让您了解如何处理重复的答案。该会话非常易于使用。其他选项包括将用户 ID 和状态写入 DynamoDB 等数据库,但我发现会话在大多数情况下都有效。
与这里的其他答案一样,你应该看看这里最新的 Node.JS 库,它处理开箱即用的状态:
https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs#making-skill-state-management-simpler
您可以定义:
- State_Launch
- State_Month
- State_Movie
然后 return 如果在错误状态下调用了 GetMovieIntent 或 GetMonthIntent(等)意图之外的任何内容,则正确的错误响应。
您必须在服务器端进行数据验证以确保 "month" 是有效的,除非您有预期值列表,否则电影更难验证。也就是说,如果您愿意解析它们以供重复使用。
背景
我正在编写 Alexa 技能并希望从用户那里获取信息。
以下对话为例:
Alexa: What month were you born at?
User: April
Alexa: Good. And what was your favorite movie?
User: April
问题
给出以下语句:
GetMonthIntent {month}
GetMovieIntent {movie}
一旦用户第二次回答April
,可能会触发GetMonthIntent
。
我试过的
要求用户指定使用以下语句提供的条信息:
GetMonthIntent Month {month}
GetMovieIntent Movie {movie}
问题
让 Alexa 根据当前上下文等待单个术语答案的正确方法是什么?
很遗憾,没有解决办法。无法指定应在其中解释用户回复的 'context',因此您必须告诉用户 "what was your favorite movie? Please say 'my favorite movie is' and then the name of the movie".
以下是我认为可以解决您的问题的两个 ASK 功能请求:
https://forums.developer.amazon.com/content/idea/41062/creating-something-to-help-with-more-structured-qu.html
https://forums.developer.amazon.com/content/idea/55525/allow-a-response-to-specify-a-set-of-expected-inte.html
我个人认为这是相当重要的,所以我投了这些票,但它们还没有排在最前面。
我 运行 在创建 "Who's on First? Baseball Skit" 技能时遇到了同样的问题。我通过以下方式处理了这个问题:
- 为 Alexa 给出的每个响应创建一个序列号
- 将此数字写入响应中的 "session"。
- 然后 Alexa 在下一个请求中将会话传回给您的技能。
- 从请求中读取序列号以了解上一个问题是什么。
- 如果给定的意图可能是多个问题的答案(例如,在您的情况下是月份和电影),则使用序列号来确定它是哪个。
这应该会让您了解如何处理重复的答案。该会话非常易于使用。其他选项包括将用户 ID 和状态写入 DynamoDB 等数据库,但我发现会话在大多数情况下都有效。
与这里的其他答案一样,你应该看看这里最新的 Node.JS 库,它处理开箱即用的状态: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs#making-skill-state-management-simpler
您可以定义:
- State_Launch
- State_Month
- State_Movie
然后 return 如果在错误状态下调用了 GetMovieIntent 或 GetMonthIntent(等)意图之外的任何内容,则正确的错误响应。
您必须在服务器端进行数据验证以确保 "month" 是有效的,除非您有预期值列表,否则电影更难验证。也就是说,如果您愿意解析它们以供重复使用。