From dba3aa305dc09355446665d9f8e70bda9f4f4c77 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sun, 23 Apr 2017 03:49:47 +0200 Subject: [PATCH 1/6] Add target_audience --- lib/Facebook.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index b7e5184f2..d1dffd74b 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -493,6 +493,12 @@ function Facebookbot(configuration) { get_domain_whitelist: function(cb) { facebook_botkit.api.messenger_profile.getAPI('whitelisted_domains', cb); }, + target_audience: function(payload) { + var message = { + 'target_audience': payload + }; + facebook_botkit.api.messenger_profile.postAPI(message); + }, postAPI: function(message) { request.post('https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + configuration.access_token, {form: message}, From 392ce1ba7f2e74a26e78b5ed9130a4dde3e2d439 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sun, 23 Apr 2017 03:50:11 +0200 Subject: [PATCH 2/6] Add delete_target_audience --- lib/Facebook.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index d1dffd74b..a6ce8d3f1 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -499,6 +499,9 @@ function Facebookbot(configuration) { }; facebook_botkit.api.messenger_profile.postAPI(message); }, + delete_target_audience: function() { + facebook_botkit.api.messenger_profile.deleteAPI('target_audience'); + }, postAPI: function(message) { request.post('https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + configuration.access_token, {form: message}, From 5bc95a2a1471b0243f0f14d1c9c430e6074ce4e0 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sun, 23 Apr 2017 03:50:48 +0200 Subject: [PATCH 3/6] Add get_target_audience --- lib/Facebook.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index a6ce8d3f1..ec5aeaec4 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -502,6 +502,9 @@ function Facebookbot(configuration) { delete_target_audience: function() { facebook_botkit.api.messenger_profile.deleteAPI('target_audience'); }, + get_target_audience: function(cb) { + facebook_botkit.api.messenger_profile.getAPI('target_audience', cb); + }, postAPI: function(message) { request.post('https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + configuration.access_token, {form: message}, From b7a808de094644999f97550928f7ed8b201c3294 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sun, 23 Apr 2017 03:53:40 +0200 Subject: [PATCH 4/6] Remove hello and helo example from messanger profile section --- docs/readme-facebook.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/readme-facebook.md b/docs/readme-facebook.md index 8d0e9dbeb..b7590967a 100644 --- a/docs/readme-facebook.md +++ b/docs/readme-facebook.md @@ -452,13 +452,7 @@ controller.api.messenger_profile.get_domain_whitelist(function (err, data) { }); -controller.hears(['hello'],'facebook_postback', function(bot, message) { - //... -}); -controller.hears(['help'],'facebook_postback', function(bot, message) { - //... -}); ``` From 4e11267963a1b6b474607bbe4db35714129f6f67 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sun, 23 Apr 2017 04:11:09 +0200 Subject: [PATCH 5/6] Add some target audience examples --- docs/readme-facebook.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/readme-facebook.md b/docs/readme-facebook.md index b7590967a..f55afd4ce 100644 --- a/docs/readme-facebook.md +++ b/docs/readme-facebook.md @@ -452,6 +452,17 @@ controller.api.messenger_profile.get_domain_whitelist(function (err, data) { }); +// Target Audience +controller.api.messenger_profile.target_audience({ + "audience_type":"custom", + "countries":{ + "whitelist":["US", "CA"] + } +}); +controller.api.messenger_profile.delete_target_audience(); +controller.api.messenger_profile.get_target_audience(function (err, data) { + console.log('****** Target Audience :', data); +}); ``` From 69fffc96ab1087cd18a9999787bba03eaeddd873 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sun, 23 Apr 2017 04:14:29 +0200 Subject: [PATCH 6/6] Update delete domain whitelist example$ --- docs/readme-facebook.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/readme-facebook.md b/docs/readme-facebook.md index f55afd4ce..a3683c146 100644 --- a/docs/readme-facebook.md +++ b/docs/readme-facebook.md @@ -445,8 +445,7 @@ controller.api.messenger_profile.get_account_linking(function (err, accountLinki controller.api.messenger_profile.delete_account_linking(); controller.api.messenger_profile.domain_whitelist('https://localhost'); controller.api.messenger_profile.domain_whitelist(['https://127.0.0.1', 'https://0.0.0.0']); -controller.api.messenger_profile.delete_domain_whitelist('https://localhost'); -controller.api.messenger_profile.delete_domain_whitelist(['https://127.0.0.1', 'https://0.0.0.0']); +controller.api.messenger_profile.delete_domain_whitelist(); controller.api.messenger_profile.get_domain_whitelist(function (err, data) { console.log('****** Whitelisted domains :', data); });