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

查看:84
本文介绍了如何将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
    }
}

那么我将如何继续使用Alexa文档中提到的 Dialog.Delegate 指令来建立响应?

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 指令无法发送 outputSpeech reprompt 。而是使用交互模型中定义的那些。

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


请勿在对话框中包含outputSpeech或重新提示。
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 指令提供 outputSpeech reprompt

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.ElicitSlot Dialog.ConfirmSlot Dialog.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();
    }
...

updatedIntent < addDelegateDirective()中的/ code>参数是可选的。
这是一个意图对象,代表发送给您的技能的意图。您可以使用此属性集,也可以根据需要更改插槽值和确认状态。

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.

有关Dialog指令的更多信息此处

More on Dialog directives here

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

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