From cb3c750a4ff7e36ef3706eea58f22ea641a0d036 Mon Sep 17 00:00:00 2001 From: arunthampi Date: Thu, 1 Sep 2016 11:28:11 -0700 Subject: [PATCH 1/2] Set is_echo correctly if Facebook payload is echo --- lib/Facebook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index f495209a0..d70298777 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -135,13 +135,13 @@ function Facebookbot(configuration) { for (var m = 0; m < obj.entry[e].messaging.length; m++) { var facebook_message = obj.entry[e].messaging[m]; if (facebook_message.message) { - var message = { text: facebook_message.message.text, user: facebook_message.sender.id, channel: facebook_message.sender.id, timestamp: facebook_message.timestamp, seq: facebook_message.message.seq, + is_echo: facebook_message.message.is_echo, mid: facebook_message.message.mid, sticker_id: facebook_message.message.sticker_id, attachments: facebook_message.message.attachments, From 2c49a7f22bfbe70f25cf8dc8b3b1d800b78c2f88 Mon Sep 17 00:00:00 2001 From: arunthampi Date: Thu, 1 Sep 2016 11:35:52 -0700 Subject: [PATCH 2/2] Add support for read receipts on Facebook --- lib/Facebook.js | 9 +++++++++ readme-facebook.md | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index d70298777..0ab5fc598 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -192,7 +192,16 @@ function Facebookbot(configuration) { }; facebook_botkit.trigger('message_delivered', [bot, message]); + } else if (facebook_message.read) { + var message = { + optin: facebook_message.read, + user: facebook_message.sender.id, + channel: facebook_message.sender.id, + timestamp: facebook_message.timestamp, + }; + + facebook_botkit.trigger('message_read', [bot, message]); } else { facebook_botkit.log('Got an unexpected message from Facebook: ', facebook_message); } diff --git a/readme-facebook.md b/readme-facebook.md index 0ef11daeb..28298047b 100644 --- a/readme-facebook.md +++ b/readme-facebook.md @@ -62,6 +62,7 @@ Normal messages will be sent to your bot using the `message_received` event. In | message_received | a message was received by the bot | facebook_postback | user clicked a button in an attachment and triggered a webhook postback | message_delivered | a confirmation from Facebook that a message has been received +| message_read | a confirmation from Facebook that a message has been read | facebook_optin | a user has clicked the [Send-to-Messenger plugin](https://developers.facebook.com/docs/messenger-platform/implementation#send_to_messenger_plugin) All incoming events will contain the fields `user` and `channel`, both of which represent the Facebook user's ID, and a `timestamp` field.