messaging-api-messenger
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -1,2 +0,4 @@ | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};var _axios = require('axios');var _axios2 = _interopRequireDefault(_axios); | ||
'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};var _querystring = require('querystring');var _querystring2 = _interopRequireDefault(_querystring); | ||
var _axios = require('axios');var _axios2 = _interopRequireDefault(_axios); | ||
var _invariant = require('invariant');var _invariant2 = _interopRequireDefault(_invariant);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
@@ -378,3 +380,2 @@ | ||
// TODO: support formdata fileupload? | ||
// FIXME: prettier bug? | ||
@@ -769,9 +770,53 @@ | ||
* https://developers.facebook.com/docs/messenger-platform/secondary-receivers | ||
*/}exports.default = MessengerClient;MessengerClient.connect = (accessToken, version = 'v2.10') => new MessengerClient(accessToken, version);var _initialiseProps = function _initialiseProps() {this.getHTTPClient = () => this._http;this.getUserProfile = userId => this._http.get(`/${userId}?access_token=${this._accessToken}`).then(res => res.data);this.getMessengerProfile = fields => this._http.get(`/me/messenger_profile?fields=${fields.join(',')}&access_token=${this._accessToken}`).then(res => res.data.data);this.setMessengerProfile = profile => this._http.post(`/me/messenger_profile?access_token=${this._accessToken}`, profile).then(res => res.data);this.deleteMessengerProfile = fields => this._http.delete(`/me/messenger_profile?access_token=${this._accessToken}`, { data: { fields } }).then(res => res.data);this.getGetStartedButton = () => this.getMessengerProfile(['get_started']).then(res => res[0].get_started);this.setGetStartedButton = payload => this.setMessengerProfile({ get_started: { payload } });this.deleteGetStartedButton = () => this.deleteMessengerProfile(['get_started']);this.getPersistentMenu = () => this.getMessengerProfile(['persistent_menu']).then(res => res[0].persistent_menu);this.setPersistentMenu = (menuItems, { composerInputDisabled = false } = {}) => {// menuItems is in type PersistentMenu | ||
*/ | ||
/** | ||
* Page Messaging Insights API | ||
* | ||
* https://developers.facebook.com/docs/messenger-platform/insights/page-messaging | ||
*/ | ||
/** | ||
* Built-in NLP API | ||
* | ||
* https://developers.facebook.com/docs/messenger-platform/built-in-nlp | ||
*/}exports.default = MessengerClient;MessengerClient.connect = (accessToken, version = 'v2.10') => new MessengerClient(accessToken, version);var _initialiseProps = function _initialiseProps() {this.getHTTPClient = () => this._http;this.getUserProfile = userId => this._http.get(`/${userId}?access_token=${this._accessToken}`).then(res => res.data);this.getMessengerProfile = fields => this._http.get(`/me/messenger_profile?fields=${fields.join(',')}&access_token=${this._accessToken}`).then(res => res.data.data);this.setMessengerProfile = profile => this._http.post(`/me/messenger_profile?access_token=${this._accessToken}`, profile).then(res => res.data);this.deleteMessengerProfile = fields => this._http.delete(`/me/messenger_profile?access_token=${this._accessToken}`, { data: { fields } }).then(res => res.data);this.getGetStartedButton = () => this.getMessengerProfile(['get_started']).then(res => res[0].get_started);this.setGetStartedButton = payload => this.setMessengerProfile({ get_started: { payload } });this.deleteGetStartedButton = () => this.deleteMessengerProfile(['get_started']);this.getPersistentMenu = () => this.getMessengerProfile(['persistent_menu']).then(res => res[0].persistent_menu);this.setPersistentMenu = (menuItems, { composerInputDisabled = false } = {}) => {// menuItems is in type PersistentMenu | ||
if (menuItems.some(item => item.locale === 'default')) {return this.setMessengerProfile({ persistent_menu: menuItems });} // menuItems is in type Array<MenuItem> | ||
return this.setMessengerProfile({ persistent_menu: [{ locale: 'default', composer_input_disabled: composerInputDisabled, call_to_actions: menuItems }] });};this.deletePersistentMenu = () => this.deleteMessengerProfile(['persistent_menu']);this.getGreetingText = () => this.getMessengerProfile(['greeting']).then(res => res[0].greeting);this.setGreetingText = greeting => {if (typeof greeting === 'string') {return this.setMessengerProfile({ greeting: [{ locale: 'default', text: greeting }] });}return this.setMessengerProfile({ greeting });};this.deleteGreetingText = () => this.deleteMessengerProfile(['greeting']);this.getDomainWhitelist = () => this.getMessengerProfile(['whitelisted_domains']).then(res => res[0].whitelisted_domains);this.setDomainWhitelist = domains => this.setMessengerProfile({ whitelisted_domains: domains });this.deleteDomainWhitelist = () => this.deleteMessengerProfile(['whitelisted_domains']);this.getAccountLinkingURL = () => this.getMessengerProfile(['account_linking_url']).then(res => res[0]);this.setAccountLinkingURL = url => this.setMessengerProfile({ account_linking_url: url });this.deleteAccountLinkingURL = () => this.deleteMessengerProfile(['account_linking_url']);this.getPaymentSettings = () => this.getMessengerProfile(['payment_settings']).then(res => res[0]);this.setPaymentPrivacyPolicyURL = url => this.setMessengerProfile({ payment_settings: { privacy_url: url } });this.setPaymentPublicKey = key => this.setMessengerProfile({ payment_settings: { public_key: key } });this.setPaymentTestUsers = users => this.setMessengerProfile({ payment_settings: { test_users: users } });this.deletePaymentSettings = () => this.deleteMessengerProfile(['payment_settings']);this.getTargetAudience = () => this.getMessengerProfile(['target_audience']).then(res => res[0]);this.setTargetAudience = (type, whitelist = [], blacklist = []) => this.setMessengerProfile({ target_audience: { audience_type: type, countries: { whitelist, blacklist } } });this.deleteTargetAudience = () => this.deleteMessengerProfile(['target_audience']);this.getChatExtensionHomeURL = () => this.getMessengerProfile(['home_url']).then(res => res[0]);this.setChatExtensionHomeURL = (url, { webview_height_ratio, webview_share_button, in_test }) => this.setMessengerProfile({ home_url: { url, webview_height_ratio, in_test, webview_share_button } });this.deleteChatExtensionHomeURL = () => this.deleteMessengerProfile(['home_url']);this.getMessageTags = () => this._http.get(`/page_message_tags?access_token=${this._accessToken}`).then(res => res.data.data);this.sendRawBody = body => this._http.post(`/me/messages?access_token=${this._accessToken}`, body).then(res => res.data);this.send = (recipientId, message, options) => this.sendRawBody(_extends({ recipient: { id: recipientId }, message }, options));this.sendAttachment = (recipientId, attachment, options) => this.send(recipientId, { attachment }, options);this.sendText = (recipientId, text, options) => this.send(recipientId, { text }, options);this.sendIssueResolutionText = (recipientId, text) => this.sendText(recipientId, text, { tag: 'ISSUE_RESOLUTION' });this.sendAudio = (recipientId, url) => this.sendAttachment(recipientId, { type: 'audio', // eslint-disable-line | ||
payload: { url } });this.sendImage = (recipientId, url) => this.sendAttachment(recipientId, { type: 'image', payload: { url } });this.sendVideo = (recipientId, url) => this.sendAttachment(recipientId, { type: 'video', payload: { url } });this.sendFile = (recipientId, url) => this.sendAttachment(recipientId, { type: 'file', payload: { url } });this.sendTemplate = (recipientId, payload, options) => this.sendAttachment(recipientId, { type: 'template', payload }, options);this.sendButtonTemplate = (recipientId, text, buttons) => this.sendTemplate(recipientId, { template_type: 'button', text, buttons });this.sendGenericTemplate = (recipientId, elements, ratio = 'horizontal', options) => this.sendTemplate(recipientId, { template_type: 'generic', elements, image_aspect_ratio: ratio // FIXME rename to image_aspect_ratio? | ||
return this.setMessengerProfile({ persistent_menu: [{ locale: 'default', composer_input_disabled: composerInputDisabled, call_to_actions: menuItems }] });};this.deletePersistentMenu = () => this.deleteMessengerProfile(['persistent_menu']);this.getGreetingText = () => this.getMessengerProfile(['greeting']).then(res => res[0].greeting);this.setGreetingText = greeting => {if (typeof greeting === 'string') {return this.setMessengerProfile({ greeting: [{ locale: 'default', text: greeting }] });}return this.setMessengerProfile({ greeting });};this.deleteGreetingText = () => this.deleteMessengerProfile(['greeting']);this.getDomainWhitelist = () => this.getMessengerProfile(['whitelisted_domains']).then(res => res[0].whitelisted_domains);this.setDomainWhitelist = domains => this.setMessengerProfile({ whitelisted_domains: domains });this.deleteDomainWhitelist = () => this.deleteMessengerProfile(['whitelisted_domains']);this.getAccountLinkingURL = () => this.getMessengerProfile(['account_linking_url']).then(res => res[0]);this.setAccountLinkingURL = url => this.setMessengerProfile({ account_linking_url: url });this.deleteAccountLinkingURL = () => this.deleteMessengerProfile(['account_linking_url']);this.getPaymentSettings = () => this.getMessengerProfile(['payment_settings']).then(res => res[0]);this.setPaymentPrivacyPolicyURL = url => this.setMessengerProfile({ payment_settings: { privacy_url: url } });this.setPaymentPublicKey = key => this.setMessengerProfile({ payment_settings: { public_key: key } });this.setPaymentTestUsers = users => this.setMessengerProfile({ payment_settings: { test_users: users } });this.deletePaymentSettings = () => this.deleteMessengerProfile(['payment_settings']);this.getTargetAudience = () => this.getMessengerProfile(['target_audience']).then(res => res[0]);this.setTargetAudience = (type, whitelist = [], blacklist = []) => this.setMessengerProfile({ target_audience: { audience_type: type, countries: { whitelist, blacklist } } });this.deleteTargetAudience = () => this.deleteMessengerProfile(['target_audience']);this.getChatExtensionHomeURL = () => this.getMessengerProfile(['home_url']).then(res => res[0]);this.setChatExtensionHomeURL = (url, { webview_height_ratio, webview_share_button, in_test }) => this.setMessengerProfile({ home_url: { url, webview_height_ratio, in_test, webview_share_button } });this.deleteChatExtensionHomeURL = () => this.deleteMessengerProfile(['home_url']);this.getMessageTags = () => this._http.get(`/page_message_tags?access_token=${this._accessToken}`).then(res => res.data.data);this.sendRawBody = body => this._http.post(`/me/messages?access_token=${this._accessToken}`, body).then(res => res.data);this.send = (recipientId, message, options) => this.sendRawBody(_extends({ recipient: { id: recipientId }, message }, options));this.sendAttachment = (recipientId, attachment, options) => this.send(recipientId, { attachment }, options);this.sendText = (recipientId, text, options) => this.send(recipientId, { text }, options);this.sendIssueResolutionText = (recipientId, text) => this.sendText(recipientId, text, { tag: 'ISSUE_RESOLUTION' });this.sendAudio = (recipientId, url) => this.sendAttachment(recipientId, { type: 'audio', payload: { url } });this.sendImage = (recipientId, url) => this.sendAttachment(recipientId, { type: 'image', payload: { url } });this.sendVideo = (recipientId, url) => this.sendAttachment(recipientId, { type: 'video', payload: { url } });this.sendFile = (recipientId, url) => this.sendAttachment(recipientId, { type: 'file', payload: { url } });this.sendTemplate = (recipientId, payload, options) => this.sendAttachment(recipientId, { type: 'template', payload }, options);this.sendButtonTemplate = (recipientId, text, buttons) => this.sendTemplate(recipientId, { template_type: 'button', text, buttons });this.sendGenericTemplate = (recipientId, elements, ratio = 'horizontal', options) => this.sendTemplate(recipientId, { template_type: 'generic', elements, image_aspect_ratio: ratio // FIXME rename to image_aspect_ratio? | ||
}, options);this.sendTaggedTemplate = (recipientId, elements, tag, ratio = 'horizontal') => this.sendGenericTemplate(recipientId, elements, ratio, { tag });this.sendShippingUpdateTemplate = (recipientId, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipientId, elements, 'SHIPPING_UPDATE', ratio);this.sendReservationUpdateTemplate = (recipientId, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipientId, elements, 'RESERVATION_UPDATE', ratio);this.sendIssueResolutionTemplate = (recipientId, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipientId, elements, 'ISSUE_RESOLUTION', ratio);this.sendAppointmentUpdateTemplate = (recipientId, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipientId, elements, 'APPOINTMENT_UPDATE', ratio);this.sendGameEventTemplate = (recipientId, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipientId, elements, 'GAME_EVENT', ratio);this.sendTransportationUpdateTemplate = (recipientId, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipientId, elements, 'TRANSPORTATION_UPDATE', ratio);this.sendFeatureFunctionalityUpdateTemplate = (recipientId, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipientId, elements, 'FEATURE_FUNCTIONALITY_UPDATE', ratio);this.sendTicketUpdateTemplate = (recipientId, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipientId, elements, 'TICKET_UPDATE', ratio);this.sendListTemplate = (recipientId, elements, buttons, topElementStyle = 'large') => this.sendTemplate(recipientId, { template_type: 'list', elements, buttons, top_element_style: topElementStyle });this.sendOpenGraphTemplate = (recipientId, elements) => this.sendTemplate(recipientId, { template_type: 'open_graph', elements });this.sendReceiptTemplate = (recipientId, attrs) => this.sendTemplate(recipientId, _extends({ template_type: 'receipt' }, attrs));this.sendAirlineBoardingPassTemplate = (recipientId, attrs) => this.sendTemplate(recipientId, _extends({ template_type: 'airline_boardingpass' }, attrs));this.sendAirlineCheckinTemplate = (recipientId, attrs) => this.sendTemplate(recipientId, _extends({ template_type: 'airline_checkin' }, attrs));this.sendAirlineItineraryTemplate = (recipientId, attrs) => this.sendTemplate(recipientId, _extends({ template_type: 'airline_itinerary' }, attrs));this.sendAirlineFlightUpdateTemplate = (recipientId, attrs) => this.sendTemplate(recipientId, _extends({ template_type: 'airline_update' }, attrs));this.sendQuickReplies = (recipientId, textOrAttachment, quickReplies) => {// quick_replies is limited to 11 | ||
(0, _invariant2.default)(Array.isArray(quickReplies) && quickReplies.length <= 11, 'quickReplies is an array and limited to 11');quickReplies.forEach(quickReply => {if (quickReply.content_type === 'text') {// title has a 20 character limit, after that it gets truncated | ||
(0, _invariant2.default)(quickReply.title.trim().length <= 20, 'title of quickReply has a 20 character limit, after that it gets truncated'); // payload has a 1000 character limit | ||
(0, _invariant2.default)(quickReply.payload.length <= 1000, 'payload of quickReply has a 1000 character limit');}});return this.send(recipientId, _extends({}, textOrAttachment, { quick_replies: quickReplies }));};this.sendSenderAction = (recipientId, action) => this._http.post(`/me/messages?access_token=${this._accessToken}`, { recipient: { id: recipientId }, sender_action: action }).then(res => res.data);this.turnTypingIndicatorsOn = recipientId => this.sendSenderAction(recipientId, 'typing_on');this.turnTypingIndicatorsOff = recipientId => this.sendSenderAction(recipientId, 'typing_off');this.uploadAttachment = (type, url) => this._http.post(`/me/message_attachments?access_token=${this._accessToken}`, { message: { attachment: { type, payload: { url, is_reusable: true } } } }).then(res => res.data);this.uploadAudio = url => this.uploadAttachment('audio', url);this.uploadImage = url => this.uploadAttachment('image', url);this.uploadVideo = url => this.uploadAttachment('video', url);this.uploadFile = url => this.uploadAttachment('file', url);this.generateMessengerCode = (options = {}) => this._http.post(`/me/messenger_codes?access_token=${this._accessToken}`, _extends({ type: 'standard' }, options)).then(res => res.data);this.passThreadControl = (recipientId, targetAppId, metadata) => this._http.post(`/me/pass_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, target_app_id: targetAppId, metadata }).then(res => res.data);this.takeThreadControl = (recipientId, metadata) => this._http.post(`/me/take_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, metadata }).then(res => res.data);this.getSecondaryReceivers = () => this._http.get(`/me/secondary_receivers?fields=id,name&access_token=${this._accessToken}`).then(res => res.data.data);}; | ||
(0, _invariant2.default)(quickReply.payload.length <= 1000, 'payload of quickReply has a 1000 character limit');}});return this.send(recipientId, _extends({}, textOrAttachment, { quick_replies: quickReplies }));};this.sendSenderAction = (recipientId, action) => this._http.post(`/me/messages?access_token=${this._accessToken}`, { recipient: { id: recipientId }, sender_action: action }).then(res => res.data);this.turnTypingIndicatorsOn = recipientId => this.sendSenderAction(recipientId, 'typing_on');this.turnTypingIndicatorsOff = recipientId => this.sendSenderAction(recipientId, 'typing_off');this.uploadAttachment = (type, url) => this._http.post(`/me/message_attachments?access_token=${this._accessToken}`, { message: { attachment: { type, payload: { url, is_reusable: true } } } }).then(res => res.data);this.uploadAudio = url => this.uploadAttachment('audio', url);this.uploadImage = url => this.uploadAttachment('image', url);this.uploadVideo = url => this.uploadAttachment('video', url);this.uploadFile = url => this.uploadAttachment('file', url);this.generateMessengerCode = (options = {}) => this._http.post(`/me/messenger_codes?access_token=${this._accessToken}`, _extends({ type: 'standard' }, options)).then(res => res.data);this.passThreadControl = (recipientId, targetAppId, metadata) => this._http.post(`/me/pass_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, target_app_id: targetAppId, metadata }).then(res => res.data);this.takeThreadControl = (recipientId, metadata) => this._http.post(`/me/take_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, metadata }).then(res => res.data);this.getSecondaryReceivers = () => this._http.get(`/me/secondary_receivers?fields=id,name&access_token=${this._accessToken}`).then(res => res.data.data);this.getDailyUniqueActiveThreadCounts = () => this._http.get(`/me/insights/page_messages_active_threads_unique&access_token=${this._accessToken}`).then(res => res.data.data);this.getDailyUniqueConversationCounts = () => this._http.get(`/me/insights/page_messages_feedback_by_action_unique&access_token=${this._accessToken}`).then(res => res.data.data);this.setNLPConfigs = (config = {}) => {const query = { nlp_enabled: config.nlp_enabled ? 'true' : 'false' };if (config.custom_token) {query.custom_token = config.custom_token; | ||
} | ||
return this._http. | ||
post(`/me/nlp_configs?${_querystring2.default.stringify(query)}`, { | ||
access_token: this._accessToken }). | ||
then(res => res.data); | ||
};this. | ||
enableNLP = () => this.setNLPConfigs({ nlp_enabled: true });this. | ||
disableNLP = () => this.setNLPConfigs({ nlp_enabled: false });}; |
{ | ||
"name": "messaging-api-messenger", | ||
"description": "Messaging API client for Messenger", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=6" |
112
README.md
@@ -31,2 +31,4 @@ # messaging-api-messenger | ||
* [Handover Protocol API](#handover-protocol-api) | ||
* [Page Messaging Insights API](#page-messaging-insights-api) | ||
* [Built-in NLP API](#built-in-nlp-api) | ||
@@ -1949,1 +1951,111 @@ ## Installation | ||
``` | ||
<a id="page-messaging-insights-api" /> | ||
### Page Messaging Insights API - [Official Docs](https://developers.facebook.com/docs/messenger-platform/insights/page-messaging) | ||
#### getDailyUniqueActiveThreadCounts | ||
```js | ||
client.getDailyUniqueActiveThreadCounts().then(counts => { | ||
console.log(counts); | ||
// [ | ||
// { | ||
// "name": "page_messages_active_threads_unique", | ||
// "period": "day", | ||
// "values": [ | ||
// { | ||
// "value": 83111, | ||
// "end_time": "2017-02-02T08:00:00+0000" | ||
// }, | ||
// { | ||
// "value": 85215, | ||
// "end_time": "2017-02-03T08:00:00+0000" | ||
// }, | ||
// { | ||
// "value": 87175, | ||
// "end_time": "2017-02-04T08:00:00+0000" | ||
// } | ||
// ], | ||
// "title": "Daily unique active threads count by thread fbid", | ||
// "description": "Daily: total unique active threads created between users and page.", | ||
// "id": "1234567/insights/page_messages_active_threads_unique/day" | ||
// } | ||
// ] | ||
}) | ||
``` | ||
#### getDailyUniqueConversationCounts | ||
```js | ||
client.getDailyUniqueConversationCounts().then(counts => { | ||
console.log(counts); | ||
// [ | ||
// { | ||
// "name": "page_messages_feedback_by_action_unique", | ||
// "period": "day", | ||
// "values": [ | ||
// { | ||
// "value": { | ||
// "TURN_ON": 40, | ||
// "TURN_OFF": 167, | ||
// "DELETE": 720, | ||
// "OTHER": 0, | ||
// "REPORT_SPAM": 0 | ||
// }, | ||
// "end_time": "2017-02-02T08:00:00+0000" | ||
// }, | ||
// { | ||
// "value": { | ||
// "TURN_ON": 38, | ||
// "DELETE": 654, | ||
// "TURN_OFF": 155, | ||
// "REPORT_SPAM": 1, | ||
// "OTHER": 0 | ||
// }, | ||
// "end_time": "2017-02-03T08:00:00+0000" | ||
// } | ||
// ], | ||
// "title": "Daily unique conversation count broken down by user feedback actions", | ||
// "description": "Daily: total unique active threads created between users and page.", | ||
// "id": "1234567/insights/page_messages_active_threads_unique/day" | ||
// } | ||
// ], | ||
}) | ||
``` | ||
<a id="built-in-nlp-api" /> | ||
### Built-in NLP API - [Official Docs](https://developers.facebook.com/docs/messenger-platform/built-in-nlp) | ||
#### setNLPConfigs(config) | ||
###### config | ||
Type: `Object` | ||
###### config.nlp_enabled | ||
Type: `Boolean` | ||
###### config.custom_token | ||
Type: `String` | ||
```js | ||
client.setNLPConfigs({ | ||
nlp_enabled: true, | ||
}); | ||
``` | ||
#### enableNLP | ||
```js | ||
client.enableNLP(); | ||
``` | ||
#### disableNLP | ||
```js | ||
client.disableNLP(); | ||
``` |
@@ -0,1 +1,3 @@ | ||
import querystring from 'querystring'; | ||
import axios from 'axios'; | ||
@@ -378,3 +380,2 @@ import invariant from 'invariant'; | ||
// TODO: support formdata fileupload? | ||
// FIXME: prettier bug? | ||
sendAudio = ( | ||
@@ -385,3 +386,3 @@ recipientId: string, | ||
this.sendAttachment(recipientId, { | ||
type: 'audio', // eslint-disable-line | ||
type: 'audio', | ||
payload: { | ||
@@ -778,2 +779,46 @@ url, | ||
.then(res => res.data.data); | ||
/** | ||
* Page Messaging Insights API | ||
* | ||
* https://developers.facebook.com/docs/messenger-platform/insights/page-messaging | ||
*/ | ||
getDailyUniqueActiveThreadCounts = () => | ||
this._http | ||
.get( | ||
`/me/insights/page_messages_active_threads_unique&access_token=${this | ||
._accessToken}` | ||
) | ||
.then(res => res.data.data); | ||
getDailyUniqueConversationCounts = () => | ||
this._http | ||
.get( | ||
`/me/insights/page_messages_feedback_by_action_unique&access_token=${this | ||
._accessToken}` | ||
) | ||
.then(res => res.data.data); | ||
/** | ||
* Built-in NLP API | ||
* | ||
* https://developers.facebook.com/docs/messenger-platform/built-in-nlp | ||
*/ | ||
setNLPConfigs = (config = {}) => { | ||
const query = { | ||
nlp_enabled: config.nlp_enabled ? 'true' : 'false', | ||
}; | ||
if (config.custom_token) { | ||
query.custom_token = config.custom_token; | ||
} | ||
return this._http | ||
.post(`/me/nlp_configs?${querystring.stringify(query)}`, { | ||
access_token: this._accessToken, | ||
}) | ||
.then(res => res.data); | ||
}; | ||
enableNLP = () => this.setNLPConfigs({ nlp_enabled: true }); | ||
disableNLP = () => this.setNLPConfigs({ nlp_enabled: false }); | ||
} |
Sorry, the diff of this file is too big to display
206617
4608
2060