如何将 Dialog.Delegate 指令返回给 Alexa Skill 模型? [英] How to return Dialog.Delegate directive to Alexa Skill model?

查看:31
本文介绍了如何将 Dialog.Delegate 指令返回给 Alexa Skill 模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Alexa Skill 模型创建一个简单的多轮对话.我的意图由 3 个插槽组成,每个插槽都是实现意图所必需的.我提示每个槽并定义所有需要的话语.

I want to create a simple multi-turn dialog with the Alexa Skill model. My intent consists of 3 slots, each of which are required to fulfill the intent. I prompt every slot and defined all of the needed utterances.

现在我想用 Lambda 函数处理请求.这是我针对此特定 Intent 的功能:

Now I want to handle the request with a Lambda function. This is my function for this specific Intent:

function getData(intentRequest, session, callback) {
    if (intentRequest.dialogState != "COMPLETED"){
        // return a Dialog.Delegate directive with no updatedIntent property.
    } else {
        // do my thing
    }
}

那么我将如何继续使用 Dialog.Delegate 指令构建我的响应,如 Alexa 文档中所述?

So how would I go on to build my response with the Dialog.Delegate directive, as mentioned in the Alexa documentation?

https://developer.amazon.com/docs/custom-skills/dialog-interface-reference.html#scenario-delegate

提前致谢.

推荐答案

使用 Dialog.Delegate 指令时,您不能发送 outputSpeechreprompt你的代码.相反,将使用交互模型中定义的那些.

With Dialog.Delegate directive you cannot send outputSpeech or reprompt from your code. Instead those defined in interaction model will be used.

不要在 Dialog.Directive 中包含 outputSpeech 或 reprompt.Alexa 使用对话模型中定义的提示来询问用户槽值和确认.

Do not include outputSpeech or reprompt with the Dialog.Directive. Alexa uses the prompts defined in the dialog model to ask the user for the slot values and confirmations.

这意味着您不能委托并提供您自己的响应,而是您可以使用任何其他Dialog指令来提供您的outputSpeechreprompt.

What this means is that you cannot delegate and provide your own response, but instead you can use any other Dialog directive to provide your outputSpeech and reprompt.

例如:Dialog.ElicitSlotDialog.ConfirmSlotDialog.ConfirmIntent.

您可以随时接管对话,而不是继续委托给 Alexa.

At any point, you can take over the dialog rather than continuing to delegate to Alexa.

...
    const updatedIntent = handlerInput.requestEnvelope.request.intent;
    if (intentRequest.dialogState != "COMPLETED"){
       return handlerInput.responseBuilder
              .addDelegateDirective(updatedIntent)
              .getResponse();
    } else {
        // Once dialoState is completed, do your thing.
        return handlerInput.responseBuilder
              .speak(speechOutput)
              .reprompt(reprompt)
              .getResponse();
    }
...

addDelegateDirective() 中的 updatedIntent 参数是可选的.它是一个意图对象,表示发送到您的技能的意图.如有必要,您可以使用此属性集或更改槽值和确认状态.

The updatedIntent parameter in addDelegateDirective() is optional. It is an intent object representing the intent sent to your skill. You can use this property set or change slot values and confirmation status if necessary.

有关对话框指令的更多信息此处

More on Dialog directives here

这篇关于如何将 Dialog.Delegate 指令返回给 Alexa Skill 模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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