Charca / bootbot

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

Webhook received unknown event #131

Closed libhide closed 6 years ago

libhide commented 6 years ago

Hey, I'm trying to follow the following example from the docs:

const question = {
  text: questions[convo.get('questionNumber', questionNumber)],
  quickReplies: [
    {
      "content_type": "text",
      "title": "",
      "payload": "YES",
      "image_url": "YES_IMAGE_URL"
    },
    {
      "content_type": "text",
      "title": "",
      "payload": "NO",
      "image_url": "NO_IMAGE_URL"
    }
  ]
};

const answer = (payload, convo) => {
  // Nothing here
};

const callbacks = [
  {
    event: 'quick_reply:YES',
    callback: (payload, convo) => {
      console.log("YES"); // this just doesn't get printed
    },
    event: 'quick_reply:NO',
    callback: (payload, convo) => {
      console.log("NO");  // this just doesn't get printed
    }
  }
];

const options = {
  typing: true // Send a typing indicator before asking the question
};

convo.ask(question, answer, callbacks, options);

and the console is throwing out a "Webhook received unknown event" at me.

the issue

What am I doing wrong here?

mraaroncruz commented 6 years ago

The error that is happening is that bootbot is expecting there to be a text key inside of your event.message object. Since it doesn't see this, it doesn't understand what is going on.

https://github.com/Charca/bootbot/blob/b3f2af3e421a15d0d376fcdb8136ec2e2343afc5/lib/BootBot.js#L655-L658

https://github.com/Charca/bootbot/blob/b3f2af3e421a15d0d376fcdb8136ec2e2343afc5/lib/BootBot.js#L672-L673

I have never heard of this happening so my guess is either:

You can see the text under "Webhook Event" here https://developers.facebook.com/docs/messenger-platform/send-messages/quick-replies#text

libhide commented 6 years ago

Yeah, it turns out that I do need to pass in something as text. Although, this is a BootBot restriction and not something Facebook caused since I've made quick replies work without sending text before.

Any idea on how I can achieve what I want to achieve (not sending text) and still continue using BootBot?

mraaroncruz commented 6 years ago

What do you mean by "sending text". I don't understand your use case. AFAIK facebook requires text with all quick replies. But this is maybe me just being in a bootbot echo chamber.

Also, according to the docs, text or attachment must be set.

quick_replies_-_messenger_platform
libhide commented 6 years ago

I think there is a confusion betweentext and title – my bad. I'm definitely sending a text with the quick-reply but want to try and avoid sending a title. According to the docs, this is possible.

title

Thoughts?

mraaroncruz commented 6 years ago

If you send a quickreply, you need to set text. You are not setting text. That is why you are receiving the error. If you set text everything else should be fine. Follow my link to the calling bootbot code above if you still aren't following what I'm talking about.