Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #403 from arunthampi/facebook-echoes-and-read-rece…
Browse files Browse the repository at this point in the history
…ipts

Facebook echoes and read receipts
  • Loading branch information
Ben Brown authored Oct 7, 2016
2 parents e4fe9c7 + 2c49a7f commit 2f81a3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,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,
Expand Down Expand Up @@ -196,7 +196,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);
}
Expand Down
1 change: 1 addition & 0 deletions readme-facebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2f81a3f

Please sign in to comment.