0
votes

I want to create a Quiz based Alexa Skill. When I am trying to test the skill in the developer console, I get the following "there is a problem with the answer of the skill". I don't know, if it is a coding problem or a construction problem with the AWS Lambda endpoint. I would appreciate, if someone could help me.

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
    }
}
1

1 Answers

1
votes

It looks like you are using Alexa SDK v1. V2 has been out for a while, you should start a new project using the newer API.

Also, the Alexa team has a good quiz tutorial/repository available for Skill Builders to build off of. I suggest checking it out: https://github.com/alexa/skill-sample-nodejs-quiz-game