bootbot icon indicating copy to clipboard operation
bootbot copied to clipboard

Conversation context gets lost when postback listener is set

Open rrsilaya opened this issue 3 years ago • 0 comments

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?

rrsilaya avatar Aug 16 '20 11:08 rrsilaya