Alexa 正在反馈您需要发送帐户关联卡

Alexa is giving feedback that you need to send account linking card

我正在提交 Alexa 技能及其反馈,如果用户未链接,您需要 return 帐户链接卡。我正在使用此语法给用户响应

context.succeed(
                                              buildResponse({},
                                                buildSpeechletResponse("Welcome to Deft , here you can control all your home appliances from your voice for example say turn on the bed room light and it will repsond accordingly",false)
                                              )
                                            )

函数是:

function buildSpeechletResponse(outputText, shouldEndSession) {
    return {
        outputSpeech: {
            type: "PlainText",
            text: outputText
        },
        // card: {
        //     type: "Simple",
        //     title: title,
        //     content: output
        // },
        // reprompt: {
        //     outputSpeech: {
        //         type: "PlainText",
        //         text: repromptText
        //     }
        // },
        shouldEndSession: shouldEndSession
    };
}

function buildResponse(sessionAttributes, speechletResponse) {
    return {
        version: "1.0",
        sessionAttributes: sessionAttributes,
        response: speechletResponse
    };


}

我必须把这个作为输出来制作一张卡片:

{
  "version": "1.0",
  "response": {
    "outputSpeech": {"type":"PlainText","text":"Please go to your Alexa app and link your account."},
    "card": {
      "type": "LinkAccount"
    }
  }
}

需要帮助创建一张卡片。

要检查用户是否有帐户链接,您可以使用 event.session.user.accessToken == undefined。然后您需要使用卡类型 LinkAccount 构建您的帐户链接响应。您可以查看 this 了解详细信息。

function buildAccountLinkingResponse(outputText, shouldEndSession) {
   return {
       outputSpeech: {
           type: "PlainText",
           text: outputText
       },
        card: {
            type: "LinkAccount",
        },
        reprompt: {
            outputSpeech: {
                type: "PlainText",
                text: "TextHere"
            }
        },
        shouldEndSession: shouldEndSession
   };

}