mathew-kurian / FacebookMessengerBot.js

:mailbox: Simple, light-weight Facebook Messenger Bot API for Node with ES6 support (via. Promises)
https://developers.facebook.com/docs/messenger-platform
117 stars 24 forks source link

Messaging echoes #1

Open theyinvincible opened 8 years ago

theyinvincible commented 8 years ago

Hi, I'm facing an issue when I subscribe my bot to messaging_echoes and the bot sends a message with quick replies to the user.

An error is thrown in Bot.js on postback.hasOwnProperty. The echo message of the bot's message with quick replies has the field message.quick_reply.payload = null, resulting in a Unhandled rejection TypeError: Cannot read property 'hasOwnProperty' of null. I have tried setting payload params to the Quick Reply objects but to no avail.

if (message.quick_reply) {
      let postback = {};

      try {
        postback = JSON.parse(message.quick_reply.payload);
      } catch (e) {
        // ignore
      }

      message.isQuickReply = true;

      if (postback.hasOwnProperty('data')) {

If you have any suggestions for this, I would really appreciate it. Thank you!:)