【问题标题】:Im keep on getting an error trying to make a session variable我一直在尝试创建会话变量时出错
【发布时间】:2018-08-13 15:01:27
【问题描述】:

我正在研究 Alexa 技能。目前,我正在尝试获取用户名并将其作为会话变量。但是,每当我去测试它时,它都会给我这个错误:

"errorMessage": "RequestId: 98b4fce1-9699-11e7-a585-43e1799b56fe Process 
exited before completing request"

这是日志中的TypeError:

TypeError: Cannot read property 'slots' of undefined

这是我的代码:

exports.handler = function(event, context, callback) {
   var alexa = Alexa.handler(event, context);
   alexa.APP_ID = APP_ID;
   alexa.registerHandlers(handlers);
   alexa.dynamoDBTableName = 'usersName';
   alexa.execute();
};

var handlers = {

   'LaunchRequest': function () {
      this.emit('LaunchIntent');
   },

   'LaunchIntent': function () {
      this.atttributes['myName'] = this.event.request.intent.slots.myName.value
      this.emit(':ask', 'Hi! Welcome to Welcoming Alarm! What is your name?');
   },

   'RemebmberNameIntent': function () {
      this.emit(':tell,', 'Hi there!' + this.atttributes['myName']);
   },

【问题讨论】:

    标签: node.js amazon-web-services aws-lambda alexa alexa-skills-kit


    【解决方案1】:

    这是因为您正试图从 LaunchRequest 中访问插槽。
    LaunchRequest 没有意图映射,并且插槽是意图的一部分。这意味着LaunchRequest JSON 有效负载中不会有intent 对象。

    LaunchRequest 是一个对象,表示用户创建了一个 请求 Alexa 技能,但未提供特定意图。

    更多关于 Alexa 请求类型here

    为了完成这项工作,请创建另一个意图,让用户可以实际说出他们的名字。 (我希望你有一个)然后从那里将名称存储到会话属性中。

    'TellMyNameIntent': function () {
          this.atttributes['myName'] = this.event.request.intent.slots.myName.value
          this.emit(':ask', 'Okay, Got it, I will remember your name.');
    },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-03
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-04
      相关资源
      最近更新 更多