将LUIS与botkit对话一起使用

时间:2019-12-04 15:18:28

标签: luis botkit botkit-4 botkit-middleware

我正在开发一个机器人,并且试图在这里使用意图而不是模式

convo.ask('Do you want to eat a taco?', [
 {
     pattern: 'yes',
     type: 'string',
     handler: async(response, convo, bot) => {
         return await convo.gotoThread('yes_taco');
     }
 },
 {
     pattern: 'no',
     type: 'string',
     handler: async(response, convo, bot) => {
         return await convo.gotoThread('no_taco');
     }
  },
  {
      default: true,
      handler: async(response, convo, bot) => {
          await bot.say('I do not understand your response!');
          // start over!
          return await convo.repeat();
      }
  }
], {key: 'tacos'});

有办法吗?

1 个答案:

答案 0 :(得分:0)

检出此botkit-middleware-luis软件包。如文档所述,它将LUIS调用返回的意图替换为模式匹配功能。

如以上链接所示,您的实现应如下所示:

var luis = require('./lib/luis-middleware.js');

var luisOptions = {serviceUri: process.env.serviceUri};

controller.middleware.receive.use(luis.middleware.receive(luisOptions));

controller.hears(['hello','hi'],['direct_message','direct_mention','mention'], luis.middleware.hereIntent, function(bot,message) {
    bot.reply(message,"Hello.");
});

希望有帮助!