botkit: conversation.say doesn't output until you end the convo

I’m not sure if this is a bug or expected behavior, but it makes conversations much less useful.

Could we add a conversation.flush() method to output queued messages without ending the conversation?

I guess I can use bot.say() in these cases, but the conversation methods don’t get a passed a reference to the bot (?) so I’d have to store/pass that around.


Use case: If I have a conversation and in the middle I want to add a response, eg to a ‘hint’ or clarification if the user doesn’t give an expected answer, there’s no way to use bot.say without ending the whole conversation.

consider the snippet below

in this case if the user enters hint I can try to convo.say("Rhymes with foo!"); but this will NOT output until I fire a convo.next() doing that will however end the conversation.

I also tried with convo.repeat() and silentRepeat() but these seem to not behave as expected.


ConvoTest.start = function (bot, message) {
    debug("message", message);
    bot.startConversation(message, function (err, convo) {
        if (err) {
            console.log("err", err);
            return;
        }
        convo.say("Start single player game");
        // convo.ask("What color is the sky?", ConvoTest.quizQuestion);
        convo.ask("What color is the sky?", ConvoTest.multiResponse);

        convo.on('end', function (convo) {
            bot.say({
                text: "Game Over",
                channel: message.user
            });
            // convo.say("Done!");
            // convo.next();
            if(convo.status === 'completed') {
                console.log("end convo");
            }
        });

    });

};


ConvoTest.multiResponse = [
    {
        pattern: /hint/,
        callback: function (response, convo) {
            convo.say("Rhymes with foo!");
            // FIXME - this will exit the conversation
            // but without it, nothing is output
            convo.next();
        }
    },

    {
        pattern: /what/,
        callback: function (response, convo) {
            convo.say("Say what?");
            convo.repeat();
            convo.next();
        }
    },
    {
        pattern: /blue/,
        callback: function (response, convo) {
            convo.say("yes, you win!");
            convo.next();
        }
    },
    {
        default: true,
        callback: function(response, convo) {
            convo.say("no, try again");
            // convo.repeat();
            convo.silentRepeat();
            convo.next();
        }
    }
];

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (6 by maintainers)

Most upvoted comments

happy anniversary, issue #318 🎉

Any news for that bug? Any idea for a fix (not the bot.reply workaround)? It’s a really annoying one, as @manojkumar1412 mentioned, bot.reply doesn’t fallow the normal order of a conversation 😕

@dcsan yeah it’s probably a bug What I do in case of wrong answer is (roughly, with bot passed in):

bot.reply(conv.source_message, 'Beeeep, try again.');
conv.silentRepeat();

and not calling next() after that. This seems to be working fine and resuming/ending/cleaning up conversation as expected.