Я пытаюсь создать простое приложение для Alexa, в котором пользователь произносит имя вызова (единица голосового управления), а затем произносит высказывание (временный мир), описанное в настраиваемом намерении (TempIntent), чтобы получить выходные данные, используя buildSpeechletResponse, т.е.запрос).Но я получаю сообщение об ошибке «Возникла проблема с ответом на запрошенный навык» на вкладке «Тест» в консоли разработчика Alexa.
Я уже пытался изменить имя намерения, имя вызова, имя функции, но ничего не работает.
//This is index.js file lambda function
function onLaunch(launchRequest, session, response)
{
var output = 'Welcome to Temp World';
var reprompt = 'Type temp world';
response(session.attributes,
buildSpeechletResponseWithoutCard(output, reprompt,false));
console.log("onLaunch requestId=" + launchRequest.requestId
+ ", sessionId=" + session.sessionId);
}
function onIntent(intent, session, response) {
console.log("onIntent requestId=" + intent.requestId
+ ", sessionId=" + session.sessionId);
var intent = intentRequest.intent,
intentName = intentRequest.intent.name;
if(intentName == 'TempIntent') {
handleTempRequest();
}
else {
throw "Invalid intent";
}
}
function handleTempRequest()
{
buildSpeechletResponse("", "welcome to temp world", "", true);
}
function buildSpeechletResponse(title, output, repromptText,
shouldEndSession) {
return {
outputSpeech: {
type: "PlainText",
text: output
},
card: {
type: "Simple",
title: title,
content: output
},
reprompt: {
outputSpeech: {
type: "PlainText",
text: repromptText
}
},
shouldEndSession: shouldEndSession
};
}
Я ожидал, что вывод будет "welcome to temp world", но вывод JSON будет нулевым.
Вход JSON
"request": {
"type": "SessionEndedRequest",
"requestId": "amzn1.echo-api.request.c78c093c-eb05-4eaa-8f23-16037059e61f",
"timestamp": "2019-05-09T12:23:34Z",
"locale": "en-US",
"reason": "ERROR",
"error": {
"type": "INVALID_RESPONSE",
"message": "An exception occurred while dispatching the request to the skill."
}
}
Изображение показывает разговор Алекса