From 291b8e730b4c5d9cc3b5d23eb209393f0b2960c7 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Tue, 7 Feb 2017 11:39:49 +0100 Subject: [PATCH 1/5] Add .idea foldder to idgnored files & create account_linking --- .gitignore | 1 + lib/Facebook.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index c3c36444b..41205213a 100755 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ examples/db_team_bot/ .DS_Store */.DS_Store .env +.idea diff --git a/lib/Facebook.js b/lib/Facebook.js index 0665b1b6d..29bec3bf2 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -457,6 +457,9 @@ function Facebookbot(configuration) { 'thread_state': 'existing_thread', }; facebook_botkit.api.thread_settings.deleteAPI(message); + }, + account_linking: function() { + }, postAPI: function(message) { request.post('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token, From 4fbd0f1fc7f3bd3106501321552f513574dc7ed2 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Tue, 7 Feb 2017 12:01:01 +0100 Subject: [PATCH 2/5] Impliment account-linking --- lib/Facebook.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 29bec3bf2..cd3e3d76f 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -458,8 +458,12 @@ function Facebookbot(configuration) { }; facebook_botkit.api.thread_settings.deleteAPI(message); }, - account_linking: function() { - + account_linking: function(payload) { + var message = { + 'setting_type': 'account_linking', + 'account_linking_url': payload + }; + facebook_botkit.api.thread_settings.postAPI(message); }, postAPI: function(message) { request.post('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token, From 9b149f6e23deaf7ea6f96083912296ebe8c2023d Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Tue, 7 Feb 2017 12:24:58 +0100 Subject: [PATCH 3/5] Impliment delete_account_linking --- lib/Facebook.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index cd3e3d76f..c5917c76f 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -465,6 +465,13 @@ function Facebookbot(configuration) { }; facebook_botkit.api.thread_settings.postAPI(message); }, + delete_account_linking: function() { + var message = { + 'setting_type': 'call_to_actions', + 'thread_state': 'existing_thread' + }; + facebook_botkit.api.thread_settings.deleteAPI(message); + }, postAPI: function(message) { request.post('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token, {form: message}, From 52c9df492ec643159aa85c88da48937958b72314 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Tue, 7 Feb 2017 12:30:58 +0100 Subject: [PATCH 4/5] Add account_linking exemple --- readme-facebook.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme-facebook.md b/readme-facebook.md index e02207215..0016dcaff 100644 --- a/readme-facebook.md +++ b/readme-facebook.md @@ -352,6 +352,8 @@ controller.api.thread_settings.menu([ "url":"https://github.com/howdyai/botkit/blob/master/readme-facebook.md" }, ]); +controller.api.thread_settings.account_linking('https://www.yourAwesomSite.com/oauth?response_type=code&client_id=1234567890&scope=basic'); + controller.hears(['hello'],'facebook_postback', function(bot, message) { //... From 71e3bd29a0dcb80a3b44ab0a28365d36307f52ac Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Tue, 7 Feb 2017 12:31:26 +0100 Subject: [PATCH 5/5] delete_account_linking --- readme-facebook.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme-facebook.md b/readme-facebook.md index 0016dcaff..153d83d60 100644 --- a/readme-facebook.md +++ b/readme-facebook.md @@ -353,6 +353,7 @@ controller.api.thread_settings.menu([ }, ]); controller.api.thread_settings.account_linking('https://www.yourAwesomSite.com/oauth?response_type=code&client_id=1234567890&scope=basic'); +controller.api.thread_settings.delete_account_linking(); controller.hears(['hello'],'facebook_postback', function(bot, message) {