如何将Dialog.Delegate指令返回给Alexa Skill模型?

Ips*_*der 5 alexa node.js aws-lambda alexa-skills-kit alexa-slot

我想用Alexa Skill模型创建一个简单的多转对话框.我的意图包括3个插槽,每个插槽都需要满足意图.我提示每个插槽并定义所有需要的话语.

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

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

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

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

先感谢您.

Cic*_*mas 11

使用Dialog.Delegate指令,您无法发送outputSpeechreprompt从您的代码.而是将使用在交互模型中定义的那些.

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

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

例如:Dialog.ElicitSlot,Dialog.ConfirmSlotDialog.ConfirmIntent.

在任何时候,您都可以接管对话而不是继续委托给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();
    }
...
Run Code Online (Sandbox Code Playgroud)

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

更多关于Dialog指令的信息


小智 5

在nodejs中,您可以使用

if (this.event.request.dialogState != 'COMPLETED'){
    //your logic
    this.emit(':delegate');
} else {
     this.response.speak(message);
     this.emit(':responseReady');
}
Run Code Online (Sandbox Code Playgroud)

  • 谢谢您,这有助于您掌握工作原理。 (2认同)