Using LUIS with botkit conversations

95 views Asked by At

I am working on a bot and I am trying to use intents instead of patterns here

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'});

Is there a way to do that?

1

There are 1 answers

2
Steven Kanberg On

Check out this botkit-middleware-luis package. As the doc says, it replaces the pattern matching function with the returned intents from the LUIS call.

As demonstrated on the above link, you implementation would look something like this:

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.");
});

Hope of help!