[尝试在AWS托管的自定义Lambda函数中使用Alexa演示语言功能。意图处理程序正在触发,但是当我添加Alexa.getSupportedInterfaces失败。消息为“错误处理:Alexa.getSupportedInterfaces不是函数”
// 1. Intent Handlers =============================================
const LaunchRequest_Handler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'LaunchRequest';
},
handle(handlerInput) {
let responseBuilder = handlerInput.responseBuilder;
let speakOutput = 'Welcome to test Bot. ';
// let skillTitle = capitalize(invocationName);
// Add APL directive to response
if (Alexa1.getSupportedInterfaces(handlerInput.requestEnvelope)['Alexa.Presentation.APL']) {
// Add the RenderDocument directive to the responseBuilder
responseBuilder.addDirective({
type: 'Alexa.Presentation.APL.RenderDocument',
token: Echo_Token,
document: Customer
});
// Tailor the speech for a device with a screen.
speakOutput += " You should now also see my greeting on the screen."
} else {
// User's device does not support APL, so tailor the speech to this situation
speakOutput += " This example would be more interesting on a device with a screen, such as an Echo Show or Fire TV.";
}
return responseBuilder
.speak(speakOutput)
.withShouldEndSession(false)
.reprompt('try again, ' + speakOutput)
.withSimpleCard("CustomerSupport!", "CustomerSupport)")
// .reprompt('add a reprompt if you want to keep the session open for the user to respond')
//.withStandardCard('Welcome!',
// 'Hello!\nThis is a card for your skill, ' + skillTitle,
// welcomeCardImg.smallImageUrl, welcomeCardImg.largeImageUrl)
.getResponse();
},
};
而不是使用以下条件:Alexa1.getSupportedInterfaces(handlerInput.requestEnvelope ['Alexa.Presentation.APL]
您可以使用以下条件检查设备是否支持APL:if(supportsAPL(handlerInput))
确保在索引文件中包含以下函数定义:
功能supportsAPL(handlerInput){常量supportedInterfaces = handlerInput.requestEnvelope.context.System.device.supportedInterfaces; const aplInterface = supportedInterfaces ['Alexa.Presentation.APL'];返回aplInterface!= null && aplInterface!= undefined; }
功能supportsAPLT(handlerInput){常量supportedInterfaces = handlerInput.requestEnvelope.context.System.device.supportedInterfaces; const aplInterface = supportedInterfaces ['Alexa.Presentation.APLT'];返回aplInterface!= null && aplInterface!= undefined; }
希望它对我的工作有所帮助。