【问题标题】:Amazon Skill Flow Builder timeout and fallback for reprompts and recapsAmazon Skill Flow Builder 超时和重新提示和回顾的回退
【发布时间】:2020-02-27 14:31:44
【问题描述】:
我在 Skill Flow Builder 中找不到解决方案,用于检测 reprompt 或 recap 的返回频率,以便在 2-3 次尝试提示用户后强制回退路由。
有人有解决办法吗?
这是一个典型的例子:
@welcome
*say
Hello. Where do you want to go?
*reprompt
Where to go?
*recap
Where to go?
*then
hear route A {
-> route_a
}
hear route B {
-> route_b
}
问题在于,除非您说“路线 A”或“路线 B”,否则您将永远收到重新提示。
它需要一个fallback,您可以定义它以在多次尝试获得正确响应后触发。
【问题讨论】:
标签:
aws-lambda
alexa
alexa-skills-kit
alexa-skill
【解决方案1】:
如果您定义hear *,SFB 驱动程序会将行为路由到它,而不是仅仅重复*recap 消息。
时间变化回顾的示例如下所示:
@start
*say
hello.
Do you go to left or right?
*reprompt
Do you want to go left, or right?
*recap
This is a recap message.
*then
hear left {
set repromptCount as 0
-> left room
}
hear right {
set repromptCount as 0
-> right room
}
hear * {
increase repromptCount by 1
set limit as 3
if repromptCount < limit {
-> start *recap
}
set repromptingDestination as 'reprompting destination'
-> too many reprompts scene
}
@left room
*say
left room
@right room
*say
right room
@too many reprompts scene
*say
You didn't know what to do too much.
*then
-> {repromptingDestination}
@reprompting destination
*say
Reprompt destination
【解决方案2】:
感谢 Ezra 提供的解决方案。我要添加一些内容,以使其更易于在全球范围内实施:
@global prepend
*then
hear * {
-> recapHandler
}
@recapHandler
// *say
// DEBUG Recap count is {recapCount} [pause] Recap limit is {recapLimit}
*then
increase recapCount by 1
if recapCount <= recapLimit {
-> {recapScene} *recap
}
set recapCount as 0
-> {fallbackScene}
请注意您必须在每个场景中设置的变量名称。在您所在的当前场景有一个全局变量之前,您必须手动设置它。
@aScene
*say
blah blah
*recap
recap message
*then
set recapScene as 'aScene'
set fallbackScene as 'aFallbackScene'
hear * {
-> recapHandler
}