question

newuser-d4e35bf9-0b9f-4c5b-802a-ef99211bd029 avatar image
newuser-d4e35bf9-0b9f-4c5b-802a-ef99211bd029 asked ·

Error in Lambda : Alexa.SkillBuilders.standard is not a function

Hey

My skill is to make Alexa remember where I have stored personal belongings using DynamoDB. It's basically like an inventory.

I'm using the ask-sdk standard package and node js 8.10

I used .withTableName('PlaceandThing') and .withAutoCreateTable(true) to create the table. Is this the right method? I'm pasting my Lambda handler below

const skillBuilder = Alexa.SkillBuilders.standard();
exports.handler = skillBuilder
  .addRequestHandlers(LaunchRequestHandler,
                      AddThingsIntentHandler,
                      TellIntentHandler,
                      HelpIntentHandler,
                      CancelAndStopIntentHandler,
                      SessionEndedRequestHandler,
    )
    .addErrorHandlers(ErrorHandler)
    .withTableName('PlaceandThing')
    .withAutoCreateTable(true)
    .lambda();

I'm unable to even launch the skill. The error I get is as follows,

{
  "errorMessage": "Alexa.SkillBuilders.standard is not a function",
  "errorType": "TypeError",
  "stackTrace": [
    "Module._compile (module.js:652:30)",
    "Object.Module._extensions..js (module.js:663:10)",
    "Module.load (module.js:565:32)",
    "tryModuleLoad (module.js:505:12)",
    "Function.Module._load (module.js:497:3)",
    "Module.require (module.js:596:17)",
    "require (internal/module.js:11:18)"
  ]
}

I have configured two intents : AddThingsIntent which adds the values to the table and TellIntent which reminds the user where the items are stored. The intent handlers are as below,

const AddThingsIntentHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'IntentRequest'
            && handlerInput.requestEnvelope.request.intent.name === 'AddThingsIntent';
    },
    handle(handlerInput) {
        var ThingName = handlerInput.requestEnvelope.request.intent.slots.ThingName.value;
        var PlaceName = handlerInput.requestEnvelope.request.intent.slots.PlaceName.value;
        const attributes = handlerInput.attributesManager.getSessionAttributes();
        if(attributes.Place === undefined){
            attributes.Place = {};
        }
        attributes.Place[ThingName] = PlaceName;
        const speechText = "I will remember that your " + ThingName + "is/are in/on your " +PlaceName;
        return handlerInput.responseBuilder
            .speak(speechText)
            .reprompt(speechText)
            .withSimpleCard('Reminder Skill', speechText)
            .getResponse();
    }
};
const TellIntentHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'IntentRequest'
            && handlerInput.requestEnvelope.request.intent.name === 'TellIntent';
    },
    handle(handlerInput) {
        var speechText = "";
        var ThingName = handlerInput.requestEnvelope.request.intent.slot.ThingName.value;
        const attributes = handlerInput.attributesManager.getSessionAttributes();
        if(attributes.Place[ThingName]) {
            speechText = 'Your' + ThingName + 'is/are in/on ' +attributes.Place[ThingName];
        }
        else {
            speechText = "I don't know where your " +ThingName + "is/are";
        }
         return handlerInput.responseBuilder
            .speak(speechText)
            .reprompt(speechText)
            .withSimpleCard('Reminder Skill', speechText)
            .getResponse();
    }
};

I've added the table in DynamoDB manually and tried too. Should I use the DynamoDB Persistence Adapter? What should I do now? Any help is welcome.

alexa skills kitlambdaawsdynamodbsdk v2
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers