diff --git a/lib/Facebook.js b/lib/Facebook.js index bd28f3ae3..f64735828 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -196,7 +196,8 @@ function Facebookbot(configuration) { mid: facebook_message.message.mid, sticker_id: facebook_message.message.sticker_id, attachments: facebook_message.message.attachments, - quick_reply: facebook_message.message.quick_reply + quick_reply: facebook_message.message.quick_reply, + type: "user_message", }; facebook_botkit.receiveMessage(bot, message); @@ -219,6 +220,7 @@ function Facebookbot(configuration) { user: facebook_message.sender.id, channel: facebook_message.sender.id, timestamp: facebook_message.timestamp, + type: "facebook_postback", }; facebook_botkit.receiveMessage(bot, message); diff --git a/readme-facebook.md b/readme-facebook.md index f39157b53..b80fbb143 100644 --- a/readme-facebook.md +++ b/readme-facebook.md @@ -70,7 +70,9 @@ All incoming events will contain the fields `user` and `channel`, both of which `message_received` events will also contain either a `text` field or an `attachment` field. -`facebook_postback` events will contain a `payload` field. +`facebook_postback` events will contain a `payload` field. + +Notice also that `facebook_postback` events trigger the `message_received` event as well. That is why messages will have the `type` field as well. When the message is directly from the user (i.e. onlye `message_received` event) `type` will be set to `"user_message"` and when the message is originated in a `facebook_postback` then `type` will be set to `facebook_postback`. More information about the data found in these fields can be found [here](https://developers.facebook.com/docs/messenger-platform/webhook-reference).