From cfe72bd799e1f4d167196cd255c1e030f20aa33a Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Fri, 3 Mar 2017 23:27:44 +0100 Subject: [PATCH 01/23] Rename threadSetting -> MessengerProfile --- facebook_bot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/facebook_bot.js b/facebook_bot.js index a73f120d9..72be465d3 100755 --- a/facebook_bot.js +++ b/facebook_bot.js @@ -131,9 +131,9 @@ controller.setupWebserver(process.env.port || 3000, function(err, webserver) { }); }); -controller.api.thread_settings.greeting('Hello! I\'m a Botkit bot!'); -controller.api.thread_settings.get_started('sample_get_started_payload'); -controller.api.thread_settings.menu([ +controller.api.messenger_profile.greeting('Hello! I\'m a Botkit bot!'); +controller.api.messenger_profile.get_started('sample_get_started_payload'); +controller.api.messenger_profile.menu([ { "type":"postback", "title":"Hello", From b3b38abafc561af06b008e5c9505b014e9eea96d Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Fri, 3 Mar 2017 23:28:20 +0100 Subject: [PATCH 02/23] Changer threadSetting to MessengerProfile in facebookBot --- lib/Facebook.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 211134379..5c15fd5c1 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -415,7 +415,8 @@ function Facebookbot(configuration) { }; facebook_botkit.api = { - 'thread_settings': { + 'thread_settings': facebook_botkit.api.messenger_profile, + 'messenger_profile': { greeting: function(greeting) { var message = { 'setting_type': 'greeting', @@ -423,13 +424,13 @@ function Facebookbot(configuration) { 'text': greeting } }; - facebook_botkit.api.thread_settings.postAPI(message); + facebook_botkit.api.messenger_profile.postAPI(message); }, delete_greeting: function() { var message = { 'setting_type': 'greeting', }; - facebook_botkit.api.thread_settings.deleteAPI(message); + facebook_botkit.api.messenger_profile.deleteAPI(message); }, get_started: function(payload) { var message = { @@ -442,14 +443,14 @@ function Facebookbot(configuration) { } ] }; - facebook_botkit.api.thread_settings.postAPI(message); + facebook_botkit.api.messenger_profile.postAPI(message); }, delete_get_started: function() { var message = { 'setting_type': 'call_to_actions', 'thread_state': 'new_thread', }; - facebook_botkit.api.thread_settings.deleteAPI(message); + facebook_botkit.api.messenger_profile.deleteAPI(message); }, menu: function(payload) { var message = { @@ -457,28 +458,28 @@ function Facebookbot(configuration) { 'thread_state': 'existing_thread', 'call_to_actions': payload }; - facebook_botkit.api.thread_settings.postAPI(message); + facebook_botkit.api.messenger_profile.postAPI(message); }, delete_menu: function() { var message = { 'setting_type': 'call_to_actions', 'thread_state': 'existing_thread', }; - facebook_botkit.api.thread_settings.deleteAPI(message); + facebook_botkit.api.messenger_profile.deleteAPI(message); }, account_linking: function(payload) { var message = { 'setting_type': 'account_linking', 'account_linking_url': payload }; - facebook_botkit.api.thread_settings.postAPI(message); + facebook_botkit.api.messenger_profile.postAPI(message); }, delete_account_linking: function() { var message = { 'setting_type': 'call_to_actions', 'thread_state': 'existing_thread' }; - facebook_botkit.api.thread_settings.deleteAPI(message); + facebook_botkit.api.messenger_profile.deleteAPI(message); }, postAPI: function(message) { request.post('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token, From e90acd884c284270db8260c0df2ec792be4961ad Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Fri, 3 Mar 2017 23:34:36 +0100 Subject: [PATCH 03/23] backwards compatible between threadSetting and mossengerProfile --- lib/Facebook.js | 204 ++++++++++++++++++++++++------------------------ 1 file changed, 103 insertions(+), 101 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 5c15fd5c1..4644cba31 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -414,112 +414,114 @@ function Facebookbot(configuration) { }; - facebook_botkit.api = { - 'thread_settings': facebook_botkit.api.messenger_profile, - 'messenger_profile': { - greeting: function(greeting) { - var message = { - 'setting_type': 'greeting', - 'greeting': { - 'text': greeting - } - }; - facebook_botkit.api.messenger_profile.postAPI(message); - }, - delete_greeting: function() { - var message = { - 'setting_type': 'greeting', - }; - facebook_botkit.api.messenger_profile.deleteAPI(message); - }, - get_started: function(payload) { - var message = { - 'setting_type': 'call_to_actions', - 'thread_state': 'new_thread', - 'call_to_actions': - [ - { - 'payload': payload - } - ] - }; - facebook_botkit.api.messenger_profile.postAPI(message); - }, - delete_get_started: function() { - var message = { - 'setting_type': 'call_to_actions', - 'thread_state': 'new_thread', - }; - facebook_botkit.api.messenger_profile.deleteAPI(message); - }, - menu: function(payload) { - var message = { - 'setting_type': 'call_to_actions', - 'thread_state': 'existing_thread', - 'call_to_actions': payload - }; - facebook_botkit.api.messenger_profile.postAPI(message); - }, - delete_menu: function() { - var message = { - 'setting_type': 'call_to_actions', - 'thread_state': 'existing_thread', - }; - facebook_botkit.api.messenger_profile.deleteAPI(message); - }, - account_linking: function(payload) { - var message = { - 'setting_type': 'account_linking', - 'account_linking_url': payload - }; - facebook_botkit.api.messenger_profile.postAPI(message); - }, - delete_account_linking: function() { - var message = { - 'setting_type': 'call_to_actions', - 'thread_state': 'existing_thread' - }; - facebook_botkit.api.messenger_profile.deleteAPI(message); - }, - postAPI: function(message) { - request.post('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token, - {form: message}, - function(err, res, body) { - if (err) { - facebook_botkit.log('Could not configure thread settings'); - } else { - - var results = null; - try { - results = JSON.parse(body); - } catch (err) { - facebook_botkit.log('ERROR in thread_settings API call: Could not parse JSON', err, body); - } + var messenger_profile_api = { + greeting: function(greeting) { + var message = { + 'setting_type': 'greeting', + 'greeting': { + 'text': greeting + } + }; + facebook_botkit.api.messenger_profile.postAPI(message); + }, + delete_greeting: function() { + var message = { + 'setting_type': 'greeting', + }; + facebook_botkit.api.messenger_profile.deleteAPI(message); + }, + get_started: function(payload) { + var message = { + 'setting_type': 'call_to_actions', + 'thread_state': 'new_thread', + 'call_to_actions': + [ + { + 'payload': payload + } + ] + }; + facebook_botkit.api.messenger_profile.postAPI(message); + }, + delete_get_started: function() { + var message = { + 'setting_type': 'call_to_actions', + 'thread_state': 'new_thread', + }; + facebook_botkit.api.messenger_profile.deleteAPI(message); + }, + menu: function(payload) { + var message = { + 'setting_type': 'call_to_actions', + 'thread_state': 'existing_thread', + 'call_to_actions': payload + }; + facebook_botkit.api.messenger_profile.postAPI(message); + }, + delete_menu: function() { + var message = { + 'setting_type': 'call_to_actions', + 'thread_state': 'existing_thread', + }; + facebook_botkit.api.messenger_profile.deleteAPI(message); + }, + account_linking: function(payload) { + var message = { + 'setting_type': 'account_linking', + 'account_linking_url': payload + }; + facebook_botkit.api.messenger_profile.postAPI(message); + }, + delete_account_linking: function() { + var message = { + 'setting_type': 'call_to_actions', + 'thread_state': 'existing_thread' + }; + facebook_botkit.api.messenger_profile.deleteAPI(message); + }, + postAPI: function(message) { + request.post('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token, + {form: message}, + function(err, res, body) { + if (err) { + facebook_botkit.log('Could not configure thread settings'); + } else { + + var results = null; + try { + results = JSON.parse(body); + } catch (err) { + facebook_botkit.log('ERROR in thread_settings API call: Could not parse JSON', err, body); + } - if (results) { - if (results.error) { - facebook_botkit.log('ERROR in thread_settings API call: ', results.error.message); - } else { - facebook_botkit.debug('Successfully configured thread settings', body); - } + if (results) { + if (results.error) { + facebook_botkit.log('ERROR in thread_settings API call: ', results.error.message); + } else { + facebook_botkit.debug('Successfully configured thread settings', body); } - } - }); - }, - deleteAPI: function(message) { - request.delete('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token, - {form: message}, - function(err, res, body) { - if (err) { - facebook_botkit.log('Could not configure thread settings'); - } else { - facebook_botkit.debug('Successfully configured thread settings', message); - } - }); - } + + } + }); + }, + deleteAPI: function(message) { + request.delete('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token, + {form: message}, + function(err, res, body) { + if (err) { + facebook_botkit.log('Could not configure thread settings'); + } else { + facebook_botkit.debug('Successfully configured thread settings', message); + } + }); } }; + + facebook_botkit.api = { + 'messenger_profile': messenger_profile_api, + 'thread_settings': messenger_profile_api + }; // Verifies the SHA1 signature of the raw request payload before bodyParser parses it // Will abort parsing if signature is invalid, and pass a generic error to response From ceed1d1a359b45e8238f31f03435b8175b2b2595 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Fri, 3 Mar 2017 23:34:59 +0100 Subject: [PATCH 04/23] backwards compatible between threadSetting and mossengerProfile --- lib/Facebook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 4644cba31..33cd070c2 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -517,7 +517,7 @@ function Facebookbot(configuration) { }); } }; - + facebook_botkit.api = { 'messenger_profile': messenger_profile_api, 'thread_settings': messenger_profile_api From 96f97fa2c1d449885fc17501d162902d16500028 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Fri, 3 Mar 2017 23:40:50 +0100 Subject: [PATCH 05/23] Add messenger profile API to doc --- readme-facebook.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/readme-facebook.md b/readme-facebook.md index 1cd73e05f..20a6b3454 100644 --- a/readme-facebook.md +++ b/readme-facebook.md @@ -294,48 +294,48 @@ reply_message = { bot.reply(message, reply_message) ``` -## Thread Settings API +## Messenger Profile API -Facebook offers a "Thread Settings" API to customize special bot features -such as a persistent menu and a welcome screen. We highly recommend you use all of these features, which will make your bot easier for users to work with. [Read Facebook's docs here](https://developers.facebook.com/docs/messenger-platform/thread-settings). +Facebook offers a Messenger Profile API to customize special bot features +such as a persistent menu and a welcome screen. We highly recommend you use all of these features, which will make your bot easier for users to work with. [Read Facebook's docs here](https://developers.facebook.com/docs/messenger-platform/messenger-profile). -#### controller.api.thread_settings.greeting() +#### controller.api.messenger_profile.greeting() | Argument | Description |--- |--- | message | greeting message to display on welcome screen -#### controller.api.thread_settings.delete_greeting() +#### controller.api.messenger_profile.delete_greeting() Remove the greeting message. -#### controller.api.thread_settings.get_started() +#### controller.api.messenger_profile.get_started() | Argument | Description |--- |--- | payload | value for the postback payload sent when the button is clicked Set the payload value of the 'Get Started' button -#### controller.api.thread_settings.delete_get_started() +#### controller.api.messenger_profile.delete_get_started() Clear the payload value of the 'Get Started' button and remove it. -#### controller.api.thread_settings.menu() +#### controller.api.messenger_profile.menu() | Argument | Description |--- |--- -| menu_items | an array of [menu_item objects](https://developers.facebook.com/docs/messenger-platform/thread-settings/persistent-menu#menu_item) +| menu_items | an array of menu_item objects -Create a [persistent menu](https://developers.facebook.com/docs/messenger-platform/thread-settings/persistent-menu) for your Bot +Create a [persistent menu](https://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu) for your Bot -#### controller.api.thread_settings.delete_menu() +#### controller.api.messenger_profile.delete_menu() Clear the persistent menu setting -#### Using the Thread Settings API +#### Using the The Messenger Profile API ```js -controller.api.thread_settings.greeting('Hello! I\'m a Botkit bot!'); -controller.api.thread_settings.get_started('sample_get_started_payload'); -controller.api.thread_settings.menu([ +controller.api.messenger_profile.greeting('Hello! I\'m a Botkit bot!'); +controller.api.messenger_profile.get_started('sample_get_started_payload'); +controller.api.messenger_profile.menu([ { "type":"postback", "title":"Hello", @@ -352,8 +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.api.thread_settings.delete_account_linking(); +controller.api.messenger_profile.account_linking('https://www.yourAwesomSite.com/oauth?response_type=code&client_id=1234567890&scope=basic'); +controller.api.messenger_profile.delete_account_linking(); controller.hears(['hello'],'facebook_postback', function(bot, message) { From 2cd610557d1494117df592a7cf1daa677215bf21 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Fri, 3 Mar 2017 23:47:39 +0100 Subject: [PATCH 06/23] Call Messenger profile api link instead of thread setting one --- lib/Facebook.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 33cd070c2..585d162a7 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -480,25 +480,25 @@ function Facebookbot(configuration) { facebook_botkit.api.messenger_profile.deleteAPI(message); }, postAPI: function(message) { - request.post('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token, + request.post('https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + configuration.access_token, {form: message}, function(err, res, body) { if (err) { - facebook_botkit.log('Could not configure thread settings'); + facebook_botkit.log('Could not configure messenger profile'); } else { var results = null; try { results = JSON.parse(body); } catch (err) { - facebook_botkit.log('ERROR in thread_settings API call: Could not parse JSON', err, body); + facebook_botkit.log('ERROR in messenger profile API call: Could not parse JSON', err, body); } if (results) { if (results.error) { - facebook_botkit.log('ERROR in thread_settings API call: ', results.error.message); + facebook_botkit.log('ERROR in messenger profile API call: ', results.error.message); } else { - facebook_botkit.debug('Successfully configured thread settings', body); + facebook_botkit.debug('Successfully configured messenger profile', body); } } @@ -506,13 +506,13 @@ function Facebookbot(configuration) { }); }, deleteAPI: function(message) { - request.delete('https://graph.facebook.com/v2.6/me/thread_settings?access_token=' + configuration.access_token, + request.delete('https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + configuration.access_token, {form: message}, function(err, res, body) { if (err) { - facebook_botkit.log('Could not configure thread settings'); + facebook_botkit.log('Could not configure messenger profile'); } else { - facebook_botkit.debug('Successfully configured thread settings', message); + facebook_botkit.debug('Successfully configured messenger profile', message); } }); } From 09f4bdce03eaf2a1e1f2af8620b093a5e4ef6ec7 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:09:58 +0100 Subject: [PATCH 07/23] Mograte menu to base on messenger profile --- lib/Facebook.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 585d162a7..562149856 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -451,12 +451,10 @@ function Facebookbot(configuration) { facebook_botkit.api.messenger_profile.deleteAPI(message); }, menu: function(payload) { - var message = { - 'setting_type': 'call_to_actions', - 'thread_state': 'existing_thread', - 'call_to_actions': payload + var messege = { + persistent_menu: payload }; - facebook_botkit.api.messenger_profile.postAPI(message); + facebook_botkit.api.messenger_profile.postAPI(messege); }, delete_menu: function() { var message = { From 97dddae4bd9d16018fc1410e3f8dd531a5013a63 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:12:20 +0100 Subject: [PATCH 08/23] delete menu --- lib/Facebook.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 562149856..085f4d06e 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -458,8 +458,9 @@ function Facebookbot(configuration) { }, delete_menu: function() { var message = { - 'setting_type': 'call_to_actions', - 'thread_state': 'existing_thread', + "fields":[ + "persistent_menu" + ] }; facebook_botkit.api.messenger_profile.deleteAPI(message); }, From 49d6c1345949960c91533c67814f2f5d79f35920 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:15:45 +0100 Subject: [PATCH 09/23] Add getstarted buuton --- lib/Facebook.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 085f4d06e..85974d4a0 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -432,14 +432,9 @@ function Facebookbot(configuration) { }, get_started: function(payload) { var message = { - 'setting_type': 'call_to_actions', - 'thread_state': 'new_thread', - 'call_to_actions': - [ - { - 'payload': payload - } - ] + 'get_started': { + 'payload': payload + } }; facebook_botkit.api.messenger_profile.postAPI(message); }, From 8d9f95b8e66d90a09ab6ca6b0de66f9f3d068480 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:18:44 +0100 Subject: [PATCH 10/23] Add delete get started button --- lib/Facebook.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 85974d4a0..253362898 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -440,8 +440,9 @@ function Facebookbot(configuration) { }, delete_get_started: function() { var message = { - 'setting_type': 'call_to_actions', - 'thread_state': 'new_thread', + "fields":[ + "get_started" + ] }; facebook_botkit.api.messenger_profile.deleteAPI(message); }, From c98c3c63d206d6385ae5f4ce8234a35b5aada67b Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:20:57 +0100 Subject: [PATCH 11/23] Add delete greating message --- lib/Facebook.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 253362898..d91bd38b6 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -426,7 +426,9 @@ function Facebookbot(configuration) { }, delete_greeting: function() { var message = { - 'setting_type': 'greeting', + "fields":[ + "greeting" + ] }; facebook_botkit.api.messenger_profile.deleteAPI(message); }, From a46047cabc2df7f7a5570dd2b1d0888ac987d846 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:28:35 +0100 Subject: [PATCH 12/23] Add messenger profile greeting message --- lib/Facebook.js | 115 +++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index d91bd38b6..c7860b124 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -11,7 +11,7 @@ function Facebookbot(configuration) { if (facebook_botkit.config.require_delivery) { - facebook_botkit.on('message_delivered', function(bot, message) { + facebook_botkit.on('message_delivered', function (bot, message) { // get list of mids in this message for (var m = 0; m < message.delivery.mids.length; m++) { @@ -19,7 +19,7 @@ function Facebookbot(configuration) { // loop through all active conversations this bot is having // and mark messages in conversations as delivered = true - bot.findConversation(message, function(convo) { + bot.findConversation(message, function (convo) { if (convo) { for (var s = 0; s < convo.sent.length; s++) { if (convo.sent[s].sent_timestamp <= message.delivery.watermark || @@ -36,11 +36,9 @@ function Facebookbot(configuration) { } - - // customize the bot definition, which will be used when new connections // spawn! - facebook_botkit.defineBot(function(botkit, config) { + facebook_botkit.defineBot(function (botkit, config) { var bot = { type: 'fb', @@ -49,16 +47,16 @@ function Facebookbot(configuration) { utterances: botkit.utterances, }; - bot.startConversation = function(message, cb) { + bot.startConversation = function (message, cb) { botkit.startConversation(this, message, cb); }; - bot.createConversation = function(message, cb) { + bot.createConversation = function (message, cb) { botkit.createConversation(this, message, cb); }; - bot.send = function(message, cb) { + bot.send = function (message, cb) { var facebook_message = { recipient: {}, @@ -87,7 +85,7 @@ function Facebookbot(configuration) { if (message.quick_replies) { // sanitize the length of the title to maximum of 20 chars - var titleLimit = function(title) { + var titleLimit = function (title) { if (title.length > 20) { var newTitle = title.substring(0, 16) + '...'; return newTitle; @@ -96,7 +94,7 @@ function Facebookbot(configuration) { } }; - facebook_message.message.quick_replies = message.quick_replies.map(function(item) { + facebook_message.message.quick_replies = message.quick_replies.map(function (item) { var quick_reply = {}; if (item.content_type === 'text' || !item.content_type) { quick_reply = { @@ -131,15 +129,15 @@ function Facebookbot(configuration) { facebook_message.access_token = configuration.access_token; request({ - method: 'POST', - json: true, - headers: { - 'content-type': 'application/json', + method: 'POST', + json: true, + headers: { + 'content-type': 'application/json', + }, + body: facebook_message, + uri: 'https://graph.facebook.com/v2.6/me/messages' }, - body: facebook_message, - uri: 'https://graph.facebook.com/v2.6/me/messages' - }, - function(err, res, body) { + function (err, res, body) { if (err) { @@ -157,21 +155,21 @@ function Facebookbot(configuration) { }); }; - bot.startTyping = function(src, cb) { + bot.startTyping = function (src, cb) { var msg = {}; msg.channel = src.channel; msg.sender_action = 'typing_on'; bot.say(msg, cb); }; - bot.stopTyping = function(src, cb) { + bot.stopTyping = function (src, cb) { var msg = {}; msg.channel = src.channel; msg.sender_action = 'typing_off'; bot.say(msg, cb); }; - bot.replyWithTyping = function(src, resp, cb) { + bot.replyWithTyping = function (src, resp, cb) { var textLength; if (typeof(resp) == 'string') { @@ -187,9 +185,9 @@ function Facebookbot(configuration) { var typingLength = Math.min(Math.floor(textLength / (avgCPM / 60)) * 1000, 5000); - bot.startTyping(src, function(err) { + bot.startTyping(src, function (err) { if (err) console.log(err); - setTimeout(function() { + setTimeout(function () { bot.reply(src, resp, cb); }, typingLength); }); @@ -197,7 +195,7 @@ function Facebookbot(configuration) { }; - bot.reply = function(src, resp, cb) { + bot.reply = function (src, resp, cb) { var msg = {}; if (typeof(resp) == 'string') { @@ -211,7 +209,7 @@ function Facebookbot(configuration) { bot.say(msg, cb); }; - bot.findConversation = function(message, cb) { + bot.findConversation = function (message, cb) { botkit.debug('CUSTOM FIND CONVO', message.user, message.channel); for (var t = 0; t < botkit.tasks.length; t++) { for (var c = 0; c < botkit.tasks[t].convos.length; c++) { @@ -232,17 +230,17 @@ function Facebookbot(configuration) { }); // set up a web route for receiving outgoing webhooks and/or slash commands - facebook_botkit.createWebhookEndpoints = function(webserver, bot, cb) { + facebook_botkit.createWebhookEndpoints = function (webserver, bot, cb) { facebook_botkit.log( '** Serving webhook endpoints for Messenger Platform at: ' + 'http://' + facebook_botkit.config.hostname + ':' + facebook_botkit.config.port + '/facebook/receive'); - webserver.post('/facebook/receive', function(req, res) { + webserver.post('/facebook/receive', function (req, res) { res.send('ok'); facebook_botkit.handleWebhookPayload(req, res, bot); }); - webserver.get('/facebook/receive', function(req, res) { + webserver.get('/facebook/receive', function (req, res) { if (req.query['hub.mode'] == 'subscribe') { if (req.query['hub.verify_token'] == configuration.verify_token) { res.send(req.query['hub.challenge']); @@ -259,7 +257,7 @@ function Facebookbot(configuration) { return facebook_botkit; }; - facebook_botkit.handleWebhookPayload = function(req, res, bot) { + facebook_botkit.handleWebhookPayload = function (req, res, bot) { var obj = req.body; if (obj.entry) { @@ -356,7 +354,7 @@ function Facebookbot(configuration) { }; facebook_botkit.trigger('facebook_referral', [bot, message]); - } else { + } else { facebook_botkit.log('Got an unexpected message from Facebook: ', facebook_message); } } @@ -364,13 +362,13 @@ function Facebookbot(configuration) { } }; - facebook_botkit.setupWebserver = function(port, cb) { + facebook_botkit.setupWebserver = function (port, cb) { if (!port) { throw new Error('Cannot start webserver without a port'); } - var static_dir = process.cwd() + '/public'; + var static_dir = process.cwd() + '/public'; if (facebook_botkit.config && facebook_botkit.config.webserver && facebook_botkit.config.webserver.static_dir) static_dir = facebook_botkit.config.webserver.static_dir; @@ -387,21 +385,23 @@ function Facebookbot(configuration) { } facebook_botkit.webserver.use(bodyParser.json()); - facebook_botkit.webserver.use(bodyParser.urlencoded({ extended: true })); + facebook_botkit.webserver.use(bodyParser.urlencoded({extended: true})); facebook_botkit.webserver.use(express.static(static_dir)); var server = facebook_botkit.webserver.listen( facebook_botkit.config.port, facebook_botkit.config.hostname, - function() { + function () { facebook_botkit.log('** Starting webserver on port ' + facebook_botkit.config.port); - if (cb) { cb(null, facebook_botkit.webserver); } + if (cb) { + cb(null, facebook_botkit.webserver); + } }); request.post('https://graph.facebook.com/me/subscribed_apps?access_token=' + configuration.access_token, - function(err, res, body) { + function (err, res, body) { if (err) { facebook_botkit.log('Could not subscribe to page messages'); } else { @@ -415,24 +415,29 @@ function Facebookbot(configuration) { }; var messenger_profile_api = { - greeting: function(greeting) { + greeting: function (payload) { var message = { - 'setting_type': 'greeting', - 'greeting': { - 'text': greeting - } + "greeting": [] }; + if (Array.isArray(payload)) { + message.greeting = payload; + } else { + message.greeting.push({ + 'locale': 'default', + 'text': payload + }); + } facebook_botkit.api.messenger_profile.postAPI(message); }, - delete_greeting: function() { + delete_greeting: function () { var message = { - "fields":[ + "fields": [ "greeting" ] }; facebook_botkit.api.messenger_profile.deleteAPI(message); }, - get_started: function(payload) { + get_started: function (payload) { var message = { 'get_started': { 'payload': payload @@ -440,46 +445,46 @@ function Facebookbot(configuration) { }; facebook_botkit.api.messenger_profile.postAPI(message); }, - delete_get_started: function() { + delete_get_started: function () { var message = { - "fields":[ + "fields": [ "get_started" ] }; facebook_botkit.api.messenger_profile.deleteAPI(message); }, - menu: function(payload) { + menu: function (payload) { var messege = { persistent_menu: payload }; facebook_botkit.api.messenger_profile.postAPI(messege); }, - delete_menu: function() { + delete_menu: function () { var message = { - "fields":[ + "fields": [ "persistent_menu" ] }; facebook_botkit.api.messenger_profile.deleteAPI(message); }, - account_linking: function(payload) { + account_linking: function (payload) { var message = { 'setting_type': 'account_linking', 'account_linking_url': payload }; facebook_botkit.api.messenger_profile.postAPI(message); }, - delete_account_linking: function() { + delete_account_linking: function () { var message = { 'setting_type': 'call_to_actions', 'thread_state': 'existing_thread' }; facebook_botkit.api.messenger_profile.deleteAPI(message); }, - postAPI: function(message) { + postAPI: function (message) { request.post('https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + configuration.access_token, {form: message}, - function(err, res, body) { + function (err, res, body) { if (err) { facebook_botkit.log('Could not configure messenger profile'); } else { @@ -502,10 +507,10 @@ function Facebookbot(configuration) { } }); }, - deleteAPI: function(message) { + deleteAPI: function (message) { request.delete('https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + configuration.access_token, {form: message}, - function(err, res, body) { + function (err, res, body) { if (err) { facebook_botkit.log('Could not configure messenger profile'); } else { From ec00b67bc181663a3f51da9aec0791664b82e6b3 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:31:32 +0100 Subject: [PATCH 13/23] Add messenger profile account linking --- lib/Facebook.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index c7860b124..1811bbb04 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -469,7 +469,6 @@ function Facebookbot(configuration) { }, account_linking: function (payload) { var message = { - 'setting_type': 'account_linking', 'account_linking_url': payload }; facebook_botkit.api.messenger_profile.postAPI(message); From 1bba728add1c32f72fa157b068ca61e0368f6ca5 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:32:21 +0100 Subject: [PATCH 14/23] Remove account linking --- lib/Facebook.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 1811bbb04..565f3eeb3 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -475,8 +475,9 @@ function Facebookbot(configuration) { }, delete_account_linking: function () { var message = { - 'setting_type': 'call_to_actions', - 'thread_state': 'existing_thread' + "fields": [ + "account_linking_url" + ] }; facebook_botkit.api.messenger_profile.deleteAPI(message); }, From acca34d4f6d90d1cf985eefbefd487d351584af7 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:37:05 +0100 Subject: [PATCH 15/23] Refactor delet from api --- lib/Facebook.js | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 565f3eeb3..87586f933 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -430,12 +430,7 @@ function Facebookbot(configuration) { facebook_botkit.api.messenger_profile.postAPI(message); }, delete_greeting: function () { - var message = { - "fields": [ - "greeting" - ] - }; - facebook_botkit.api.messenger_profile.deleteAPI(message); + facebook_botkit.api.messenger_profile.deleteAPI('greeting'); }, get_started: function (payload) { var message = { @@ -446,12 +441,7 @@ function Facebookbot(configuration) { facebook_botkit.api.messenger_profile.postAPI(message); }, delete_get_started: function () { - var message = { - "fields": [ - "get_started" - ] - }; - facebook_botkit.api.messenger_profile.deleteAPI(message); + facebook_botkit.api.messenger_profile.deleteAPI('get_started'); }, menu: function (payload) { var messege = { @@ -460,12 +450,7 @@ function Facebookbot(configuration) { facebook_botkit.api.messenger_profile.postAPI(messege); }, delete_menu: function () { - var message = { - "fields": [ - "persistent_menu" - ] - }; - facebook_botkit.api.messenger_profile.deleteAPI(message); + facebook_botkit.api.messenger_profile.deleteAPI('persistent_menu'); }, account_linking: function (payload) { var message = { @@ -474,12 +459,7 @@ function Facebookbot(configuration) { facebook_botkit.api.messenger_profile.postAPI(message); }, delete_account_linking: function () { - var message = { - "fields": [ - "account_linking_url" - ] - }; - facebook_botkit.api.messenger_profile.deleteAPI(message); + facebook_botkit.api.messenger_profile.deleteAPI('account_linking_url'); }, postAPI: function (message) { request.post('https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + configuration.access_token, @@ -507,7 +487,10 @@ function Facebookbot(configuration) { } }); }, - deleteAPI: function (message) { + deleteAPI: function (type) { + var message = { + "fields": [type] + }; request.delete('https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + configuration.access_token, {form: message}, function (err, res, body) { From 8862b52dcf5e5af2efb773fc637033471c3421b1 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:40:32 +0100 Subject: [PATCH 16/23] Add a new menu example --- facebook_bot.js | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/facebook_bot.js b/facebook_bot.js index 72be465d3..3d883f1e1 100755 --- a/facebook_bot.js +++ b/facebook_bot.js @@ -135,20 +135,37 @@ controller.api.messenger_profile.greeting('Hello! I\'m a Botkit bot!'); controller.api.messenger_profile.get_started('sample_get_started_payload'); controller.api.messenger_profile.menu([ { - "type":"postback", - "title":"Hello", - "payload":"hello" - }, - { - "type":"postback", - "title":"Help", - "payload":"help" + "locale":"default", + "composer_input_disabled":true, + "call_to_actions":[ + { + "title":"My Skills", + "type":"nested", + "call_to_actions":[ + { + "title":"Hello", + "type":"postback", + "payload":"Hello" + }, + { + "title":"Hi", + "type":"postback", + "payload":"Hi" + } + ] + }, + { + "type":"web_url", + "title":"Botkit Docs", + "url":"https://github.com/howdyai/botkit/blob/master/readme-facebook.md", + "webview_height_ratio":"full" + } + ] }, { - "type":"web_url", - "title":"Botkit Docs", - "url":"https://github.com/howdyai/botkit/blob/master/readme-facebook.md" - }, + "locale":"zh_CN", + "composer_input_disabled":false + } ]); controller.hears(['quick'], 'message_received', function(bot, message) { From 586da99573b80e966309492ef627631d4b72641b Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:46:37 +0100 Subject: [PATCH 17/23] Add a not to say that thread setting still available --- readme-facebook.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/readme-facebook.md b/readme-facebook.md index 20a6b3454..69691009f 100644 --- a/readme-facebook.md +++ b/readme-facebook.md @@ -294,6 +294,18 @@ reply_message = { bot.reply(message, reply_message) ``` +## Thread Setting API + +Thread setting API is now messenger profile API, it's highly recommended to use profile API instead of thread setting one, however, Botkit thread setting interface still available : + + +```js +controller.api.messenger_profile.YOUR_METHOD_NAME(); +controller.api.thread_settings.YOUR_METHOD_NAME(); + +``` + + ## Messenger Profile API Facebook offers a Messenger Profile API to customize special bot features From b3372f7b75cf9e5820d7a6977cc575c59ad36bc5 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 00:58:50 +0100 Subject: [PATCH 18/23] Remove my intellij ide formatting to not make noise --- lib/Facebook.js | 72 ++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/lib/Facebook.js b/lib/Facebook.js index 87586f933..5a23bdec2 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -11,7 +11,7 @@ function Facebookbot(configuration) { if (facebook_botkit.config.require_delivery) { - facebook_botkit.on('message_delivered', function (bot, message) { + facebook_botkit.on('message_delivered', function(bot, message) { // get list of mids in this message for (var m = 0; m < message.delivery.mids.length; m++) { @@ -19,7 +19,7 @@ function Facebookbot(configuration) { // loop through all active conversations this bot is having // and mark messages in conversations as delivered = true - bot.findConversation(message, function (convo) { + bot.findConversation(message, function(convo) { if (convo) { for (var s = 0; s < convo.sent.length; s++) { if (convo.sent[s].sent_timestamp <= message.delivery.watermark || @@ -36,9 +36,11 @@ function Facebookbot(configuration) { } + + // customize the bot definition, which will be used when new connections // spawn! - facebook_botkit.defineBot(function (botkit, config) { + facebook_botkit.defineBot(function(botkit, config) { var bot = { type: 'fb', @@ -47,16 +49,16 @@ function Facebookbot(configuration) { utterances: botkit.utterances, }; - bot.startConversation = function (message, cb) { + bot.startConversation = function(message, cb) { botkit.startConversation(this, message, cb); }; - bot.createConversation = function (message, cb) { + bot.createConversation = function(message, cb) { botkit.createConversation(this, message, cb); }; - bot.send = function (message, cb) { + bot.send = function(message, cb) { var facebook_message = { recipient: {}, @@ -85,7 +87,7 @@ function Facebookbot(configuration) { if (message.quick_replies) { // sanitize the length of the title to maximum of 20 chars - var titleLimit = function (title) { + var titleLimit = function(title) { if (title.length > 20) { var newTitle = title.substring(0, 16) + '...'; return newTitle; @@ -94,7 +96,7 @@ function Facebookbot(configuration) { } }; - facebook_message.message.quick_replies = message.quick_replies.map(function (item) { + facebook_message.message.quick_replies = message.quick_replies.map(function(item) { var quick_reply = {}; if (item.content_type === 'text' || !item.content_type) { quick_reply = { @@ -129,15 +131,15 @@ function Facebookbot(configuration) { facebook_message.access_token = configuration.access_token; request({ - method: 'POST', - json: true, - headers: { - 'content-type': 'application/json', - }, - body: facebook_message, - uri: 'https://graph.facebook.com/v2.6/me/messages' + method: 'POST', + json: true, + headers: { + 'content-type': 'application/json', }, - function (err, res, body) { + body: facebook_message, + uri: 'https://graph.facebook.com/v2.6/me/messages' + }, + function(err, res, body) { if (err) { @@ -155,21 +157,21 @@ function Facebookbot(configuration) { }); }; - bot.startTyping = function (src, cb) { + bot.startTyping = function(src, cb) { var msg = {}; msg.channel = src.channel; msg.sender_action = 'typing_on'; bot.say(msg, cb); }; - bot.stopTyping = function (src, cb) { + bot.stopTyping = function(src, cb) { var msg = {}; msg.channel = src.channel; msg.sender_action = 'typing_off'; bot.say(msg, cb); }; - bot.replyWithTyping = function (src, resp, cb) { + bot.replyWithTyping = function(src, resp, cb) { var textLength; if (typeof(resp) == 'string') { @@ -185,9 +187,9 @@ function Facebookbot(configuration) { var typingLength = Math.min(Math.floor(textLength / (avgCPM / 60)) * 1000, 5000); - bot.startTyping(src, function (err) { + bot.startTyping(src, function(err) { if (err) console.log(err); - setTimeout(function () { + setTimeout(function() { bot.reply(src, resp, cb); }, typingLength); }); @@ -195,7 +197,7 @@ function Facebookbot(configuration) { }; - bot.reply = function (src, resp, cb) { + bot.reply = function(src, resp, cb) { var msg = {}; if (typeof(resp) == 'string') { @@ -209,7 +211,7 @@ function Facebookbot(configuration) { bot.say(msg, cb); }; - bot.findConversation = function (message, cb) { + bot.findConversation = function(message, cb) { botkit.debug('CUSTOM FIND CONVO', message.user, message.channel); for (var t = 0; t < botkit.tasks.length; t++) { for (var c = 0; c < botkit.tasks[t].convos.length; c++) { @@ -230,17 +232,17 @@ function Facebookbot(configuration) { }); // set up a web route for receiving outgoing webhooks and/or slash commands - facebook_botkit.createWebhookEndpoints = function (webserver, bot, cb) { + facebook_botkit.createWebhookEndpoints = function(webserver, bot, cb) { facebook_botkit.log( '** Serving webhook endpoints for Messenger Platform at: ' + 'http://' + facebook_botkit.config.hostname + ':' + facebook_botkit.config.port + '/facebook/receive'); - webserver.post('/facebook/receive', function (req, res) { + webserver.post('/facebook/receive', function(req, res) { res.send('ok'); facebook_botkit.handleWebhookPayload(req, res, bot); }); - webserver.get('/facebook/receive', function (req, res) { + webserver.get('/facebook/receive', function(req, res) { if (req.query['hub.mode'] == 'subscribe') { if (req.query['hub.verify_token'] == configuration.verify_token) { res.send(req.query['hub.challenge']); @@ -257,7 +259,7 @@ function Facebookbot(configuration) { return facebook_botkit; }; - facebook_botkit.handleWebhookPayload = function (req, res, bot) { + facebook_botkit.handleWebhookPayload = function(req, res, bot) { var obj = req.body; if (obj.entry) { @@ -354,7 +356,7 @@ function Facebookbot(configuration) { }; facebook_botkit.trigger('facebook_referral', [bot, message]); - } else { + } else { facebook_botkit.log('Got an unexpected message from Facebook: ', facebook_message); } } @@ -362,13 +364,13 @@ function Facebookbot(configuration) { } }; - facebook_botkit.setupWebserver = function (port, cb) { + facebook_botkit.setupWebserver = function(port, cb) { if (!port) { throw new Error('Cannot start webserver without a port'); } - var static_dir = process.cwd() + '/public'; + var static_dir = process.cwd() + '/public'; if (facebook_botkit.config && facebook_botkit.config.webserver && facebook_botkit.config.webserver.static_dir) static_dir = facebook_botkit.config.webserver.static_dir; @@ -385,23 +387,21 @@ function Facebookbot(configuration) { } facebook_botkit.webserver.use(bodyParser.json()); - facebook_botkit.webserver.use(bodyParser.urlencoded({extended: true})); + facebook_botkit.webserver.use(bodyParser.urlencoded({ extended: true })); facebook_botkit.webserver.use(express.static(static_dir)); var server = facebook_botkit.webserver.listen( facebook_botkit.config.port, facebook_botkit.config.hostname, - function () { + function() { facebook_botkit.log('** Starting webserver on port ' + facebook_botkit.config.port); - if (cb) { - cb(null, facebook_botkit.webserver); - } + if (cb) { cb(null, facebook_botkit.webserver); } }); request.post('https://graph.facebook.com/me/subscribed_apps?access_token=' + configuration.access_token, - function (err, res, body) { + function(err, res, body) { if (err) { facebook_botkit.log('Could not subscribe to page messages'); } else { From f15b451ba346b3ce12ca17869b8bd0bddb7870b0 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 09:00:08 +0100 Subject: [PATCH 19/23] Read messenger profile API settings --- lib/Facebook.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index 5a23bdec2..e3e13ce75 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -500,6 +500,18 @@ function Facebookbot(configuration) { facebook_botkit.debug('Successfully configured messenger profile', message); } }); + }, + getAPI: function (fields, cb) { + request.get('https://graph.facebook.com/v2.6/me/messenger_profile?fields=' + fields + '&access_token=' + configuration.access_token, + function (err, res, body) { + if (err) { + facebook_botkit.log('Could not get messenger profile'); + cb(err); + } else { + facebook_botkit.debug('Successfully got messenger profile ', body); + cb(null, body); + } + }); } }; From 8b81e3690cf39ba3df459239aeab2508d7ef4c87 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 09:01:27 +0100 Subject: [PATCH 20/23] Add get_menu --- lib/Facebook.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index e3e13ce75..bab219c28 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -452,6 +452,9 @@ function Facebookbot(configuration) { delete_menu: function () { facebook_botkit.api.messenger_profile.deleteAPI('persistent_menu'); }, + get_menu: function (cb) { + facebook_botkit.api.messenger_profile.getAPI('persistent_menu', cb); + }, account_linking: function (payload) { var message = { 'account_linking_url': payload From 7fe7cae55f6677651b430ece53b89e1acb359b10 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 09:03:25 +0100 Subject: [PATCH 21/23] Add get_get_started --- lib/Facebook.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index bab219c28..a76923c33 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -443,6 +443,9 @@ function Facebookbot(configuration) { delete_get_started: function () { facebook_botkit.api.messenger_profile.deleteAPI('get_started'); }, + get_get_started: function () { + facebook_botkit.api.messenger_profile.getAPI('get_started'); + }, menu: function (payload) { var messege = { persistent_menu: payload From 074d8b3958e32ea438615b5ffedae7b1cb894962 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 09:04:22 +0100 Subject: [PATCH 22/23] Add get_greeting --- lib/Facebook.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index a76923c33..74f9f2bcb 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -432,6 +432,9 @@ function Facebookbot(configuration) { delete_greeting: function () { facebook_botkit.api.messenger_profile.deleteAPI('greeting'); }, + get_greeting: function () { + facebook_botkit.api.messenger_profile.getAPI('greeting'); + }, get_started: function (payload) { var message = { 'get_started': { From c46e750ce8bd8210201644036a618969c21c176a Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Sat, 4 Mar 2017 09:07:07 +0100 Subject: [PATCH 23/23] add get_account_linking --- lib/Facebook.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index 74f9f2bcb..41a73bf3a 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -470,6 +470,9 @@ function Facebookbot(configuration) { delete_account_linking: function () { facebook_botkit.api.messenger_profile.deleteAPI('account_linking_url'); }, + get_account_linking: function () { + facebook_botkit.api.messenger_profile.getAPI('account_linking_url'); + }, postAPI: function (message) { request.post('https://graph.facebook.com/v2.6/me/messenger_profile?access_token=' + configuration.access_token, {form: message},