【发布时间】:2020-05-09 20:53:09
【问题描述】:
我想创建一个基于测验的 Alexa Skill。 当我尝试在开发者控制台中测试技能时,我得到以下“技能的答案有问题”。 我不知道是编码问题还是 AWS Lambda 端点的构造问题。 如果有人可以帮助我,我将不胜感激。
exports.handler = (event, context) => {
const alexa = Alexa.handler(event, context)
alexa.appId = APP_ID
alexa.registerHandlers(handlers, startHandlers, quizHandlers)
alexa.execute()
}
const handlers = {
'LaunchRequest': function() {
this.handler.state = states.START
this.emitWithState('Start')
},
'QuizIntent': function() {
this.handler.state = states.QUIZ
this.emitWithState('Quiz')
},
'AMAZON.HelpIntent': function() {
this.response.speak(HELP_MESSAGE).listen(HELP_MESSAGE)
this.emit(':responseReady')
},
'Unhandled': function() {
this.handler.state = states.START
this.emitWithState('Start')
}
},
'Start': function() {
this.response.speak(“Herzlich Willkommen zu Teach Me! Bist du bereit für das Quiz? ”).listen(“Bist du bereit für das Quiz? ”)
this.emit(':responseReady')
}
'AMAZON.YesIntent': function() {
this.handler.state = states.QUIZ
this.emitWithState('Quiz')
}
'Quiz': function() {
var data = < QUESTION LIST >
this.attributes['data'] = data
this.attributes['response'] = ''
this.attributes['counter'] = 0
this.attributes['quizscore'] = 0
this.emitWithState('AskQuestion')
}
let question = data[this.attributes['counter']]
function compareSlots(slots, item) {
var value = item.Answer
var requestSlotvalue = slots.Answer.value
var similarity = stringSimilarity.compareTwoStrings(requestSlotvalue.toString().toLowerCase(), value.toString().toLowerCase())
if (similarity1 >= 0.6) {
return true
} else {
return false
}
}
【问题讨论】:
标签: alexa alexa-skills-kit alexa-skill alexa-voice-service alexa-app