amazon-dynamodbalexa-skills-kitvoicejovo-framework

this.user().context is undefined - Jovo Framework - Alexa


I'm currently using Jovo for cross platform developing Alexa and Google Assistant's skills/actions.

I currently hit a roadblock in which I'm trying to get the previous intent by doing either: this.user().context.prev[0].request.intent or this.user().getPrevIntent(0).

But it hasn't worked. I get context is undefined and getPrevIntent doesn't exist. According to the Docs, I need to set up a table with DynamoDB (I did, and verified that it's working since Jovo is able to store the user object), and passed in the default configuration to App. But still can't seem to get it work. Any ideas?

const config = {
  logging: false,
  // Log incoming JSON requests.
  // requestLogging: true,
  /**
   * You don't want AMAZON.YesIntent on Dialogflow, right?
   * This will map it for you!
   */
  intentMap: {
    'AMAZON.YesIntent': 'YesIntent',
    'AMAZON.NoIntent': 'NoIntent',
    'AMAZON.HelpIntent': 'HelpIntent',
    'AMAZON.RepeatIntent': 'RepeatIntent',
    'AMAZON.NextIntent': 'NextIntent',
    'AMAZON.StartOverIntent': 'StartOverIntent',
    'AMAZON.ResumeIntent': 'ContinueIntent',
    'AMAZON.CancelIntent': 'CancelIntent',
  },
  // Configures DynamoDB to persist data
  db: {
    awsConfig,
    type: 'dynamodb',
    tableName: 'user-data',
  },
  userContext: {
    prev: {
      size: 1,
      request: {
        intent: true,
        state: true,
        inputs: true,
        timestamp: true,
      },
      response: {
        speech: true,
        reprompt: true,
        state: true,
      },
    },
  },
};

const app = new App(config);

Thanks 😊


Solution

  • To make use of the User Context Object of the Jovo Framework, you need to have at least v1.2.0 of the jovo-framework.

    You can update the package to the latest version like this: npm install jovo-framework --save

    (This used to be a comment. Just adding this as an answer so other people see it as well)