【问题标题】:Alexa Node JS how to handle cancel event for multiple eventsAlexa Node JS如何处理多个事件的取消事件
【发布时间】:2017-11-08 22:54:01
【问题描述】:

我有多个自定义技能意图。我想为所有自定义意图处理取消事件。我怎样才能得到取消被调用的那个。

const Alexa = require('alexa-sdk');
exports.handler = (event, context) => {
  const alexa = Alexa.handler(event, context);
  var APP_ID = "amzn1.ask.skill.[ssdad-5c61-4d4e-b2bf-7eea8a491816]";
  alexa.APP_ID = APP_ID;
  alexa.registerHandlers(handlers);
  alexa.execute();
};
const handlers = {
  'ConfirmChangeEvent': function() {
    this.emit(':ask', "Do u want commit for change? ");
  },
  'ConfirmLastAction': function() {
    this.emit(':ask', "Do u want confirm for last Action?");
  },

  'LaunchRequest': function() {
    this.emit(':tell', "Hi Damodar, I'm Dialogue manager");
  },
  'Amazon.CancelIntent' : function() {
    // i want handle cancel on both intents here  ConfirmLastAction and Conf irmChangeEvent

    //if ConfirmChangeEvent  should give output like "Okay cancelling changeEvent "

    // ConfirmChangeEvent  should give output like "Okay cancelling the Last Action " 

  }

  'Unhandled': function() {
    this.emit(':tell', "I'm not able to respond at this time");
  }
};

我们如何在 node JS Alexa 中处理这个问题

【问题讨论】:

  • “取消所有自定义意图的事件”是什么意思?只有一个会话包含所有内容。取消的话会整体取消

标签: alexa alexa-skills-kit alexa-app


【解决方案1】:

您需要使用状态管理。这是文档的链接https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs#making-skill-state-management-simpler

通过使用状态处理程序,您可以根据用户的当前状态获得不同的取消响应。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2018-08-25
  • 1970-01-01
  • 2010-10-13
  • 1970-01-01
  • 1970-01-01
  • 2021-08-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多