ouadie-lahdioui/botkit-middleware-recastai

Doesn't Allow Bot Responses

rossedman opened this issue · 2 comments

The middleware does not allow a response on the hears controller action. I can see the response from Recast being dumped into the console.

Code

const recast = require('botkit-middleware-recastai')({
    request_token: process.env.RECAST_TOKEN
});

controller.middleware.receive.use(recast.receive);

controller.hears('(.*)', 'message_received', recast.hears, (bot, message) => {
  // cannot respond or perform logic here
  bot.reply(message, 'Hey')
})

Hello,

Using the recast hears middleware (recast.hears) tells Botkit to look for Recast intents information, and match using this information instead of the built in pattern matching function.

Based on your example code, Botkit will look for the intent called (.*) and i guess that's not what you trying to do.

By overwriting Botkit's hears function, you must specify some intents instead of putting regex:

controller.hears(['AM_AN_INTENT'], 'message_received', recast.hears, (bot, message) => {
  // cannot respond or perform logic here
  bot.reply(message, 'Hey')
})

Unless you want to catch all incoming messages with (.*), you can remove recast.hears from your code :

controller.hears('(.*)', 'message_received', (bot, message) => {
  // cannot respond or perform logic here
  bot.reply(message, 'Hey')
})

Hope this helps !

@ouadie-lahdioui I did not fully understand that I was supposed to pass in the name of the intent that I had on recast. That makes a lot more sense. Thanks so much. Originally I was trying to catch all and route based on the intent returned.