Charca / bootbot

Facebook Messenger Bot Framework for Node.js
MIT License
974 stars 252 forks source link

Conversation context gets lost when postback listener is set #193

Open rrsilaya opened 4 years ago

rrsilaya commented 4 years ago

Hi. I have code like this:

chat.conversation((convo) => {
  function handlePaginatedMessage(convo) {
    // ...
    const chunk = 'long message';
    const dialog = {
      text: chunk,
      buttons: [{
        type: 'postback',
        title: 'Read More',
        payload: 'READ_MORE',
      }]
    };

    const callbacks = [{
      event: 'postback:READ_MORE',
      callback: () => {
        // code here
      },
    }];

    convo.ask(dialog, () => {}, callbacks);
  }

  handlePaginatedMessage(convo);
});

I also have a listener to postback events i.e.:

bot.on('postback', callback);

However, after the bot asks the user, the context gets lost and the postback goes with the global postback listener instead of the conversation callbacks.

Am I doing something wrong?