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

Bring the domain whitelisting to Facebook Botkit #573

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3373032
Add domain_whitelist
ouadie-lahdioui Dec 27, 2016
2eddbd0
Impliment domain_whitelist
ouadie-lahdioui Dec 27, 2016
459edc9
Add delete_domain_whitelist
ouadie-lahdioui Dec 27, 2016
df16705
Impliment delete_domain_whitelist
ouadie-lahdioui Dec 27, 2016
62980dc
Add get_domain_whitelist
ouadie-lahdioui Dec 27, 2016
b8c3f8e
Impliment get_whitelist_domain
ouadie-lahdioui Dec 27, 2016
9b8405a
Add an example of get_whitelist_domain to facebook_bot
ouadie-lahdioui Dec 27, 2016
e04601b
Add payload to delete_domain_whitelist
ouadie-lahdioui Dec 27, 2016
f6034d6
Remove body from message log, it's look prety whithout logging it
ouadie-lahdioui Dec 27, 2016
1f4fc7d
Add an example of how to add a singe domain to the whitelist
ouadie-lahdioui Dec 27, 2016
7800bf5
Add an example of how to add a multiple domains to the whitelist
ouadie-lahdioui Dec 27, 2016
d8ba588
Add an example of how to remove a single domain from the whitelist
ouadie-lahdioui Dec 27, 2016
c97994e
Add an example of how to remove a multiple domains from the whitelist
ouadie-lahdioui Dec 27, 2016
0434841
Add a doc to the method domain_whitelist
ouadie-lahdioui Dec 27, 2016
a7bf61f
Add a doc to the method delete_delete_domain_whitelist
ouadie-lahdioui Dec 27, 2016
04617a2
Add a doc to the method get_domain_whitelist
ouadie-lahdioui Dec 27, 2016
124b073
Ad some examples to the doc
ouadie-lahdioui Dec 27, 2016
9c50324
Revert my idea folder, i already forget and commit it :D
ouadie-lahdioui Dec 27, 2016
96c063e
Migrate to messenger profile API
ouadie-lahdioui Mar 4, 2017
81f329a
update domain whitelist examples
ouadie-lahdioui Mar 4, 2017
991c7db
Add get domain whitelist
ouadie-lahdioui Mar 4, 2017
e6fa700
threadsetting -> messenger_profile
ouadie-lahdioui Mar 7, 2017
b1affc2
Remove my idea folder
ouadie-lahdioui Mar 7, 2017
e105618
threadsetting -> messenger_profile
ouadie-lahdioui Mar 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions facebook_bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ controller.api.thread_settings.menu([
"url":"https://github.com/howdyai/botkit/blob/master/readme-facebook.md"
},
]);
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.hears(['quick'], 'message_received', function(bot, message) {

Expand Down
12 changes: 12 additions & 0 deletions lib/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,18 @@ function Facebookbot(configuration) {
};
facebook_botkit.api.thread_settings.deleteAPI(message);
},
domain_whitelist: function(payload) {
var message = {
"whitelisted_domains": Array.isArray(payload) ? payload : [payload]
};
facebook_botkit.api.thread_settings.postAPI(message);
},
delete_domain_whitelist: function(payload) {
facebook_botkit.api.thread_settings.deleteAPI('whitelisted_domains');
},
get_domain_whitelist: function(cb) {
facebook_botkit.api.thread_settings.getAPI('whitelisted_domains', cb);
},
postAPI: function(message) {
request.post('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token,
{form: message},
Expand Down
21 changes: 21 additions & 0 deletions readme-facebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,20 @@ Create a [persistent menu](https://developers.facebook.com/docs/messenger-platfo

Clear the persistent menu setting

#### controller.api.messenger_profile.domain_whitelist()
| Argument | Description
|--- |---
| payload | A single or a list of domains to add to the whitelist, All domains must be valid and use https. Up to 10 domains allowed.

#### controller.api.messenger_profile.delete_delete_domain_whitelist()
| Argument | Description
|--- |---
| payload | A single or a list of domains to remove from whitelist, All domains must be valid and use https. Up to 10 domains allowed.

#### controller.api.messenger_profile.get_domain_whitelist()

Get a list of the whitelisted domains.

#### Using the Thread Settings API

```js
Expand All @@ -352,6 +366,13 @@ controller.api.thread_settings.menu([
"url":"https://github.com/howdyai/botkit/blob/master/readme-facebook.md"
},
]);
controller.api.messenger_api.domain_whitelist('https://localhost');
controller.api.messenger_api.domain_whitelist(['https://127.0.0.1', 'https://0.0.0.0']);
controller.api.messenger_api.delete_domain_whitelist('https://localhost');
controller.api.messenger_api.delete_domain_whitelist(['https://127.0.0.1', 'https://0.0.0.0']);
controller.api.messenger_api.get_domain_whitelist(function (err, data) {
console.log('****** Whitelisted domains :', data);
});

controller.hears(['hello'],'facebook_postback', function(bot, message) {
//...
Expand Down