【问题标题】:Alexa Skill - QuizAlexa 技能 - 测验
【发布时间】: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


    【解决方案1】:

    您似乎正在使用 Alexa SDK v1。 V2 已经发布了一段时间,您应该使用更新的 API 开始一个新项目。

    此外,Alexa 团队有一个很好的测验教程/存储库可供技能构建者使用。我建议检查一下:https://github.com/alexa/skill-sample-nodejs-quiz-game

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-26
      • 2017-11-22
      • 2023-01-21
      • 1970-01-01
      • 2021-02-27
      相关资源
      最近更新 更多