首页 > 解决方案 > addDelegateDirective 和意图的问题

问题描述

所以我在构建我的 alexa 技能时遇到了问题,我需要将 Intent 链接到我的 Launchrequest,它适用于此

  return handlerInput.responseBuilder
      .addDelegateDirective({
          name: 'UserLogin',
          confirmationStatus: 'NONE',
          slots: {}
      })
      .speak("You need to login!")
      .withShouldEndSession(false)
      .getResponse();

但是在我的链式意图中,我需要填充 2 个插槽,但是 alexa 只要求一个意图两次,然后什么也没有,它不要求第二个意图?

这是我在 lambda 中的意图

const LoginUserIntent= {
   canHandle(handlerInput) {
   const request = handlerInput.requestEnvelope.request;
   return request.type === 'IntentRequest' &&
   request.intent.name === 'UserLogin' &&
   request.dialogState !== 'COMPLETED';
      },
     handle(handlerInput) {
     return handlerInput.responseBuilder
     .getResponse()
  },
}

知道我怎样才能完成这项工作吗?

标签: alexaaws-sdk-nodejs

解决方案


我知道这已经很长时间了,但在这种情况下,发生的事情是您必须在 addDelegateDirective() 的插槽参数中设置所有插槽。

这是一个示例代码:

.addDelegateDirective({
          name: 'UserLogin',
          confirmationStatus: 'NONE',
          slots: {
              slot01: {
                         name: 'slot01',
                         confirmationStatus: 'NONE',
                         type: 'AMAZON.NUMBER',
                         source: 'USER'
                      }
          }
      })

您还必须设置插槽类型。周围有很多样本缺少这个属性,至少在我的情况下,它不起作用。

如果有帮助,请告诉我。


推荐阅读