broidHQ / broid-kit-botpress

Broid Kit Middleware for Botpress.
Other
6 stars 2 forks source link

Something went wrong: event.reply is not a function #5

Open lesyk opened 6 years ago

lesyk commented 6 years ago

In nutshell, reply function is not part of event variable. If you run botpress as standalone solution, reply will exist as a function, but if you run it through broad setup, reply will not be in a list of functions.

brood-kit-botpress index.ts:

...
const bot = new Bot({
  logLevel: "info"
});

bot.use(slack);
const path = require("path");
const BroidKitBotpress = require("@broid/kit-botpress");
bot.use(new BroidKitBotpress({
  botpressPath: path.join(__dirname, 'botpress')
}));
const app = express();
app.use("/", bot.getRouter());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.listen(8080);
bot.hear(".*", "Person").subscribe({
    next: (data) => {
      console.log(`Received message: ${data}`);
...

botpress index.js:

module.exports = function(bp) {

  // Listens for a first message (this is a Regex)
  // GET_STARTED is the first message you get on Facebook Messenger
  bp.hear(/GET_STARTED|hello|hi|test|hey|holla/i, (event, next, x) => {
    console.log("event:",event);
    console.log("next:",next);
    console.log("bp:",bp);
    event.reply('#welcome') // See the file `content.yml` to see the block
  })

  // You can also pass a matcher object to better filter events
  bp.hear({
    type: /message|text/i,
    text: /exit|bye|goodbye|quit|done|leave|stop/i
  }, (event, next) => {
    event.reply('#goodbye', {
      // You can pass data to the UMM bloc!
      reason: 'unknown'
    })
  })
}
lesyk commented 6 years ago

Comment from botpress:

it is highly probably that they haven't aded support for UMM (event.reply)...

killix commented 6 years ago

still investigating...