From de463989f6a3b25b6e2c5ad4b7d5177e3b29c98c Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Fri, 30 Dec 2016 19:21:45 -0200 Subject: [PATCH 1/3] Add Facebook account linking support --- lib/Facebook.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 28db07c71..0513f5149 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -338,7 +338,16 @@ function Facebookbot(configuration) { }; facebook_botkit.trigger('facebook_referral', [bot, message]); - } else { + } else if (facebook_message.account_linking) { + var message = { + user: facebook_message.sender.id, + channel: facebook_message.sender.id, + timestamp: facebook_message.timestamp, + account_linking: facebook_message.account_linking, + }; + + controller.trigger('facebook_account_linking', [bot, message]); + } else { facebook_botkit.log('Got an unexpected message from Facebook: ', facebook_message); } } From 479115e3a8a87245e410528589a7ec8497d4850a Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Fri, 30 Dec 2016 19:25:52 -0200 Subject: [PATCH 2/3] Fixing error in Facebook account linking --- lib/Facebook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 0513f5149..3458e6ed7 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -346,7 +346,7 @@ function Facebookbot(configuration) { account_linking: facebook_message.account_linking, }; - controller.trigger('facebook_account_linking', [bot, message]); + facebook_botkit.trigger('facebook_account_linking', [bot, message]); } else { facebook_botkit.log('Got an unexpected message from Facebook: ', facebook_message); } From 58a1b26b5c37ddcd657c70dddb49f41b71651804 Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Sat, 31 Dec 2016 16:28:06 -0200 Subject: [PATCH 3/3] Update readme with Facebook account linking --- readme-facebook.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme-facebook.md b/readme-facebook.md index e02207215..7fba0903b 100644 --- a/readme-facebook.md +++ b/readme-facebook.md @@ -75,6 +75,7 @@ Normal messages will be sent to your bot using the `message_received` event. In | 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_account_linking | a user has started the account linking | facebook_optin | a user has clicked the [Send-to-Messenger plugin](https://developers.facebook.com/docs/messenger-platform/implementation#send_to_messenger_plugin) | facebook_referral | a user has clicked on a [m.me URL with a referral param](https://developers.facebook.com/docs/messenger-platform/referral-params)