mvaragnat / botkit-messenger-express-demo

Demo of running BotKit for Facebook Messenger on an Express server with MongoDB storage
42 stars 20 forks source link

Cannot send message #12

Open deathg0d opened 6 years ago

deathg0d commented 6 years ago

Trying to use this demo in my existing project with the latest Botkit. My 'facebook_optin' is working fine. But when I send any other message from facebook I get the following error:

TypeError: Cannot set property 'stage' of undefined at Object.Botkit.botkit.receiveMessage (... CoreBot.js:108:33)

Line 108 in CoreBot.js looks like the following:

botkit.receiveMessage = function(bot, message) {
        message._pipeline.stage = 'receive'; // <------------------- this is line 108
        botkit.middleware.receive.run(bot, message, function(err, bot, message) {
            if (err) {
davidvexel commented 6 years ago

Same issue here when updating from ^0.5.2 → ^0.6.4 and using interactive buttons.

deathg0d commented 6 years ago

@davidvexel I solved this by using controller.ingest(bot, facebook_message); instead of controller.receiveMessage(bot, message); Remember to use facebook_message and not facebook_message.message. Hope it works for you too.

davidvexel commented 6 years ago

thanks @deathg0d, I'm using it on Slack, wondering if it's the same work around.

mvaragnat commented 6 years ago

Hey folks,

Just to let you know that 1) I'm not actively maintaining that repo anymore 2) Since Botkit, Slack API, FB API evolve very quickly, there is a high probability of obsolescence of some parts of the code.

=> If you find a solution to your issue, please consider a PR! I'll happily merge it. This repo is aimed at helping beginners, so let's make it better