0
votes

I am developing an alexa skill using nodejs ask sdk v2. I am following planMyTrip skill to understand multiturn dialogs. But the dialog state is undefined. Please find the code below:

'use strict';
const Alexa = require('ask-sdk-core');

const { HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler, ErrorHandler } = require('./commonHandlers');

const LaunchRequestHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'LaunchRequest';
    },
    handle(handlerInput) {
        const speechText = "Welcome to IFSC Code Finder, let me know ifsc code for which bank are you looking for ?";
        return handlerInput.responseBuilder
            .speak(speechText)
            .reprompt(speechText)
            .withShouldEndSession(false)
            .getResponse();
    }
};

const InProgressIfscCodeIntentHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'IntentRequest' &&
            handlerInput.requestEnvelope.request.intent.name === 'ifscCode' &&
            handlerInput.requestEnvelope.request.dialogState !== 'COMPLETED' &&
            handlerInput.requestEnvelope.request.dialogState !== 'IN_PROGRESS';            
    },
    handle(handlerInput) {
        console.log('in progress intent handler', handlerInput.requestEnvelope.request.dialogState);
        const currentIntent = handlerInput.requestEnvelope.request.intent;
        return handlerInput.responseBuilder
            .addDelegateDirective(currentIntent)
            .getResponse();
    }
};

const CompletedIfscCodeIntentHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'IntentRequest' &&
            handlerInput.requestEnvelope.request.intent.name === 'ifscCode'           
    },
    handle(handlerInput) {
        console.log("in completed intent handler");
        const speechText = "TEST TEST TEST";
        return handlerInput.responseBuilder
            .speak(speechText)
            .reprompt(speechText)
            .withShouldEndSession(false)
            .getResponse();        
    }
};

// register handlers
exports.handler = Alexa.SkillBuilders
    .custom()
    .addRequestHandlers(
        LaunchRequestHandler,
        InProgressIfscCodeIntentHandler,
        CompletedIfscCodeIntentHandler,
        HelpIntentHandler,
        CancelAndStopIntentHandler,
        SessionEndedRequestHandler
    )
    .addErrorHandlers(ErrorHandler)
    .lambda();

The execution flow reaches the InProgress handler, but after that it exits saying "There's a problem with requested skills response". The flow never reaches the completed intent handler. What changes are we suppose to make to start the dialog state ? Please note that none of the slots that I am using have confirmation required set to true. am I doing something wrong ? Please let me know.

Thanks

1

1 Answers

1
votes

There isn't any issue with the lambda code above. The problem was with the interaction model of the skill. To enable dialogs we need to update "is this slot required" property of atleast one of the slots to true.