Botkit: Facebook Messenger `addMessage` and `ask` no longer block

Created on 8 Nov 2017  路  2Comments  路  Source: howdyai/botkit

The problem is that convo.addQuestion and convo.ask don't block and wait for a response.
I am not sure whether this is limited only to Facebook or these two function but that is what I have ran into.

Using the example Facebook bot to keep things simple.

var Botkit = require('botkit');
var controller = Botkit.facebookbot({
  access_token: process.env.access_token,
  verify_token: process.env.verify_token,
  debug: true,
})
controller.startTicking();
var bot = controller.spawn({
});

controller.setupWebserver(3000,function(err,webserver) {
  controller.createWebhookEndpoints(controller.webserver, bot, function() {
      console.log('This bot is online!!!');
  });
});

controller.hears(['talk'],
                 'message_received',
                 (bot, message) => {
                   bot.startConversation(message, (err, convo) => {
                     convo.addQuestion('Say oi', [
                       {
                         pattern: 'oi',
                         callback: (res, con) => {
                           con.gotoThread('you done');
                           con.next();
                         }
                       }, {
                         default: true,
                         callback: (res, con) => con.next()
                       }
                     ]);
                     convo.ask('pi', (res, con) => con.next());
                     convo.addQuestion('Are you done?', [
                       {
                         pattern: bot.utterances.yes,
                         callback: (res, con) => {
                           con.gotoThread('default');
                           con.next();
                         }
                       }, {
                         default: true,
                         callback:  (res, con) => {
                           con.repeat();
                           con.next();
                         }
                       }
                     ],
                               {},
                               'you done');
                     convo.addMessage('DONE!');
                   });
                 });

And here's the kind of output I get
screen shot 2017-11-08 at 12 39 46 pm


Seeking clarification:

What in addQuestion says to block and wait for a response? I can鈥檛 see anything here https://github.com/howdyai/botkit/blob/master/lib/CoreBot.js#L331
To me it looks like messages just get pushed to the messages queue

Facebook-related help wanted

Most helpful comment

@MMayla This is caused by the new Facebook events that Botkit isn't up to date with.
The solution is to subscribe to the below events:

screen shot 2017-11-19 at 8 50 04 pm

All 2 comments

I have the same issue, it didn't wait for response
botkit-conv-bug

To produce
1- clone Facebook starter project
2- install packages (botkit v0.6.7)
3- deploy
4- send the text 'color' to the bot

It should wait till you write any text but it didn't and replied

tested on botkit v0.6.7 & v0.6.6

@MMayla This is caused by the new Facebook events that Botkit isn't up to date with.
The solution is to subscribe to the below events:

screen shot 2017-11-19 at 8 50 04 pm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matueranet picture matueranet  路  4Comments

fieldcorbett picture fieldcorbett  路  4Comments

iworkforthem picture iworkforthem  路  3Comments

abinashmohanty picture abinashmohanty  路  4Comments

imjul1an picture imjul1an  路  3Comments