messaging-api-messenger
Advanced tools
Comparing version
@@ -5,3 +5,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 _querystring = require('querystring');var _querystring2 = _interopRequireDefault(_querystring); | ||
var _formData = require('form-data');var _formData2 = _interopRequireDefault(_formData); | ||
var _invariant = require('invariant');var _invariant2 = _interopRequireDefault(_invariant);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
var _invariant = require('invariant');var _invariant2 = _interopRequireDefault(_invariant); | ||
var _lodash = require('lodash.omit');var _lodash2 = _interopRequireDefault(_lodash);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
@@ -47,3 +48,2 @@ | ||
class MessengerClient { | ||
@@ -481,8 +481,2 @@ | ||
/** | ||
@@ -536,77 +530,4 @@ * Templates | ||
// https://developers.facebook.com/docs/messenger-platform/send-api-reference/tags/ | ||
// https://developers.facebook.com/docs/messenger-platform/send-api-reference/list-template | ||
@@ -875,7 +796,7 @@ | ||
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 = (idOrRecipient, message, options) => {const recipient = typeof idOrRecipient === 'string' ? { id: idOrRecipient } : idOrRecipient;return this.sendRawBody(_extends({ recipient, message }, options));};this.sendFormData = (recipient, message, filedata) => {const form = new _formData2.default();const recipientObject = typeof recipient === 'string' ? { id: recipient } : recipient;form.append('recipient', JSON.stringify(recipientObject));form.append('message', JSON.stringify(message));form.append('filedata', filedata);return this._http.post(`/me/messages?access_token=${this._accessToken}`, form, { headers: form.getHeaders() }).then(res => res.data);};this.sendAttachment = (recipient, attachment, options) => this.send(recipient, { attachment }, options);this.sendAttachmentFormData = (recipient, attachment, filedata) => this.sendFormData(recipient, { attachment }, filedata);this.sendText = (recipient, text, options) => this.send(recipient, { text }, options);this.sendIssueResolutionText = (recipient, text) => this.sendText(recipient, text, { tag: 'ISSUE_RESOLUTION' });this.sendAudio = (recipient, audio) => {const attachment = { type: 'audio', payload: {} };if (typeof audio === 'string') {attachment.payload.url = audio;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, audio);};this.sendImage = (recipient, image) => {const attachment = { type: 'image', payload: {} };if (typeof image === 'string') {attachment.payload.url = image;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, image);};this.sendVideo = (recipient, video) => {const attachment = { type: 'video', payload: {} };if (typeof video === 'string') {attachment.payload.url = video;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, video);};this.sendFile = (recipient, file) => {const attachment = { type: 'file', payload: {} };if (typeof file === 'string') {attachment.payload.url = file;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, file);};this.sendTemplate = (recipient, payload, options) => this.sendAttachment(recipient, { type: 'template', payload }, options);this.sendButtonTemplate = (recipient, text, buttons) => this.sendTemplate(recipient, { template_type: 'button', text, buttons });this.sendGenericTemplate = (recipient, elements, ratio = 'horizontal', options) => this.sendTemplate(recipient, { template_type: 'generic', elements, image_aspect_ratio: ratio // FIXME rename to image_aspect_ratio? | ||
}, options);this.sendTaggedTemplate = (recipient, elements, tag, ratio = 'horizontal') => this.sendGenericTemplate(recipient, elements, ratio, { tag });this.sendShippingUpdateTemplate = (recipient, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipient, elements, 'SHIPPING_UPDATE', ratio);this.sendReservationUpdateTemplate = (recipient, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipient, elements, 'RESERVATION_UPDATE', ratio);this.sendIssueResolutionTemplate = (recipient, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipient, elements, 'ISSUE_RESOLUTION', ratio);this.sendAppointmentUpdateTemplate = (recipient, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipient, elements, 'APPOINTMENT_UPDATE', ratio);this.sendGameEventTemplate = (recipient, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipient, elements, 'GAME_EVENT', ratio);this.sendTransportationUpdateTemplate = (recipient, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipient, elements, 'TRANSPORTATION_UPDATE', ratio);this.sendFeatureFunctionalityUpdateTemplate = (recipient, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipient, elements, 'FEATURE_FUNCTIONALITY_UPDATE', ratio);this.sendTicketUpdateTemplate = (recipient, elements, ratio = 'horizontal') => this.sendTaggedTemplate(recipient, elements, 'TICKET_UPDATE', ratio);this.sendListTemplate = (recipient, elements, buttons, topElementStyle = 'large') => this.sendTemplate(recipient, { template_type: 'list', elements, buttons, top_element_style: topElementStyle });this.sendOpenGraphTemplate = (recipient, elements) => this.sendTemplate(recipient, { template_type: 'open_graph', elements });this.sendReceiptTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'receipt' }, attrs));this.sendAirlineBoardingPassTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_boardingpass' }, attrs));this.sendAirlineCheckinTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_checkin' }, attrs));this.sendAirlineItineraryTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_itinerary' }, attrs));this.sendAirlineFlightUpdateTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_update' }, attrs));this.sendQuickReplies = (recipient, textOrAttachment, quickReplies) => {// quick_replies is limited to 11 | ||
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 = (idOrRecipient, message, options) => {const recipient = typeof idOrRecipient === 'string' ? { id: idOrRecipient } : idOrRecipient;return this.sendRawBody(_extends({ recipient, message }, options));};this.sendFormData = (recipient, message, filedata) => {const form = new _formData2.default();const recipientObject = typeof recipient === 'string' ? { id: recipient } : recipient;form.append('recipient', JSON.stringify(recipientObject));form.append('message', JSON.stringify(message));form.append('filedata', filedata);return this._http.post(`/me/messages?access_token=${this._accessToken}`, form, { headers: form.getHeaders() }).then(res => res.data);};this.sendAttachment = (recipient, attachment, options) => this.send(recipient, { attachment }, options);this.sendAttachmentFormData = (recipient, attachment, filedata) => this.sendFormData(recipient, { attachment }, filedata);this.sendText = (recipient, text, options) => this.send(recipient, { text }, options);this.sendAudio = (recipient, audio) => {const attachment = { type: 'audio', payload: {} };if (typeof audio === 'string') {attachment.payload.url = audio;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, audio);};this.sendImage = (recipient, image) => {const attachment = { type: 'image', payload: {} };if (typeof image === 'string') {attachment.payload.url = image;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, image);};this.sendVideo = (recipient, video) => {const attachment = { type: 'video', payload: {} };if (typeof video === 'string') {attachment.payload.url = video;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, video);};this.sendFile = (recipient, file) => {const attachment = { type: 'file', payload: {} };if (typeof file === 'string') {attachment.payload.url = file;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, file);};this.sendTemplate = (recipient, payload, options) => this.sendAttachment(recipient, { type: 'template', payload }, options);this.sendButtonTemplate = (recipient, text, buttons) => this.sendTemplate(recipient, { template_type: 'button', text, buttons });this.sendGenericTemplate = (recipient, elements, options = {}) => this.sendTemplate(recipient, { template_type: 'generic', elements, image_aspect_ratio: options.image_aspect_ratio || 'horizontal' }, (0, _lodash2.default)(options, ['image_aspect_ratio']));this.sendListTemplate = (recipient, elements, buttons, options = {}) => this.sendTemplate(recipient, { template_type: 'list', elements, buttons, top_element_style: options.top_element_style || 'large' });this.sendOpenGraphTemplate = (recipient, elements) => this.sendTemplate(recipient, { template_type: 'open_graph', elements });this.sendReceiptTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'receipt' }, attrs));this.sendAirlineBoardingPassTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_boardingpass' }, attrs));this.sendAirlineCheckinTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_checkin' }, attrs));this.sendAirlineItineraryTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_itinerary' }, attrs));this.sendAirlineFlightUpdateTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_update' }, attrs));this.sendQuickReplies = (recipient, 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(recipient, _extends({}, textOrAttachment, { quick_replies: quickReplies }));};this.sendSenderAction = (idOrRecipient, action) => {const recipient = typeof idOrRecipient === 'string' ? { id: idOrRecipient } : idOrRecipient;return this.sendRawBody({ recipient, sender_action: action });};this.markSeen = recipient => this.sendSenderAction(recipient, 'mark_seen');this.turnTypingIndicatorsOn = recipient => this.sendSenderAction(recipient, 'typing_on');this.turnTypingIndicatorsOff = recipient => this.sendSenderAction(recipient, '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; | ||
(0, _invariant2.default)(quickReply.payload.length <= 1000, 'payload of quickReply has a 1000 character limit');}});return this.send(recipient, _extends({}, textOrAttachment, { quick_replies: quickReplies }));};this.sendSenderAction = (idOrRecipient, action) => {const recipient = typeof idOrRecipient === 'string' ? { id: idOrRecipient } : idOrRecipient;return this.sendRawBody({ recipient, sender_action: action });};this.markSeen = recipient => this.sendSenderAction(recipient, 'mark_seen');this.typingOn = recipient => this.sendSenderAction(recipient, 'typing_on');this.typingOff = recipient => this.sendSenderAction(recipient, '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; | ||
} | ||
@@ -882,0 +803,0 @@ |
{ | ||
"name": "messaging-api-messenger", | ||
"description": "Messaging API client for Messenger", | ||
"version": "0.2.8", | ||
"version": "0.3.0", | ||
"engines": { | ||
@@ -23,4 +23,5 @@ "node": ">=6" | ||
"form-data": "^2.2.0", | ||
"invariant": "^2.2.2" | ||
"invariant": "^2.2.2", | ||
"lodash.omit": "^4.5.0" | ||
} | ||
} |
646
README.md
@@ -44,2 +44,4 @@ # messaging-api-messenger | ||
<br /> | ||
## Usage | ||
@@ -64,2 +66,4 @@ | ||
<br /> | ||
## API Reference | ||
@@ -69,2 +73,4 @@ | ||
<br /> | ||
<a id="send-api" /> | ||
@@ -76,2 +82,4 @@ | ||
Send request raw body using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
###### body | ||
@@ -92,4 +100,8 @@ | ||
<br /> | ||
#### send(userId, message) | ||
Send messages to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
###### userId | ||
@@ -111,2 +123,4 @@ | ||
<br /> | ||
<a id="content-types" /> | ||
@@ -118,2 +132,4 @@ | ||
Send plain text messages to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
###### userId | ||
@@ -133,2 +149,7 @@ | ||
###### options.tag | ||
Type: `String` | ||
Value: `ISSUE_RESOLUTION` | ||
```js | ||
@@ -138,20 +159,14 @@ client.sendText(USER_ID, 'Hello!'); | ||
#### sendIssueResolutionText(userId, text) | ||
Or sending text message with a [tag](https://developers.facebook.com/docs/messenger-platform/message-tags): | ||
###### userId | ||
Type: `String | Object` | ||
Page-scoped user ID of the recipient or [recipient](https://developers.facebook.com/docs/messenger-platform/send-api-reference#recipient) object. | ||
###### text | ||
Type: `String` | ||
```js | ||
client.sendIssueResolutionText(USER_ID, 'Hello!'); | ||
client.sendText(USER_ID, 'Hello!', { tag: 'ISSUE_RESOLUTION' }); | ||
``` | ||
<br /> | ||
#### sendAttachment(userId, attachment) | ||
Send attachment messages to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
###### userId | ||
@@ -176,4 +191,8 @@ | ||
<br /> | ||
#### sendAudio(userId, audio) | ||
Send sounds to specified user by uploading them or sharing a URL using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13503473_1584526905179825_88080075_n.png?oh=085ef554f12d061090677b89f3275d64&oe=59EB29D3" alt="sendAudio" width="250" /> | ||
@@ -205,4 +224,8 @@ | ||
<br /> | ||
#### sendImage(userId, image) | ||
Send images to specified user by uploading them or sharing a URL using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). Supported formats are jpg, png and gif. | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13466577_1753800631570799_2129488873_n.png?oh=5904aadb6aa82cd2287d777359bd3cd2&oe=59F32D6A" alt="sendImage" width="250" /> | ||
@@ -234,4 +257,8 @@ | ||
<br /> | ||
#### sendVideo(userId, video) | ||
Send videos to specified user by uploading them or sharing a URL using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13509239_1608341092811398_289173120_n.png?oh=160ea165834203bae79c24c8e07137de&oe=5A350DB4" alt="sendVideo" width="250" /> | ||
@@ -263,4 +290,8 @@ | ||
<br /> | ||
#### sendFile(userId, file) | ||
Send files to specified user by uploading them or sharing a URL using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13480153_1115020735225077_1305291896_n.png?oh=a972010ea3edd1ea967885b06317efab&oe=59F63578" alt="sendVideo" width="250" /> | ||
@@ -292,2 +323,4 @@ | ||
<br /> | ||
<a id="templates" /> | ||
@@ -299,2 +332,4 @@ | ||
Send structured message templates to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
###### userId | ||
@@ -324,4 +359,8 @@ | ||
<br /> | ||
#### sendButtonTemplate(userId, title, buttons) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/button-template) | ||
Send button message templates to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13509162_1732711383655205_1306472501_n.png?oh=0e2409226bc50b23207bf37bf6e2edb6&oe=5A377CAC" alt="sendButtonTemplate" width="250" /> | ||
@@ -358,4 +397,8 @@ | ||
#### sendGenericTemplate(userId, elements) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template) | ||
<br /> | ||
#### sendGenericTemplate(userId, elements, options) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template) | ||
Send generic message templates to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13509251_1026555627430343_1803381600_n.png?oh=e9fadd445090a4743bfd20fda487be5f&oe=59EE4571" alt="sendGenericTemplate" width="250" /> | ||
@@ -373,44 +416,19 @@ | ||
```js | ||
client.sendGenericTemplate(USER_ID, [ | ||
{ | ||
title: "Welcome to Peter's Hats", | ||
image_url: 'https://petersfancybrownhats.com/company_image.png', | ||
subtitle: "We've got the right hat for everyone.", | ||
default_action: { | ||
type: 'web_url', | ||
url: 'https://peterssendreceiveapp.ngrok.io/view?item=103', | ||
messenger_extensions: true, | ||
webview_height_ratio: 'tall', | ||
fallback_url: 'https://peterssendreceiveapp.ngrok.io/', | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'postback', | ||
title: 'Start Chatting', | ||
payload: 'DEVELOPER_DEFINED_PAYLOAD', | ||
}, | ||
], | ||
}, | ||
]); | ||
``` | ||
###### options | ||
#### sendTaggedTemplate(userId, elements, tag) | ||
###### options.image_aspect_ratio | ||
###### userId | ||
Type: `String` | ||
Value: `horizontal | square` | ||
Default: `horizontal` | ||
Type: `String | Object` | ||
Type: `Object` | ||
Page-scoped user ID of the recipient or [recipient](https://developers.facebook.com/docs/messenger-platform/send-api-reference#recipient) object. | ||
###### options.tag | ||
###### elements | ||
Type: `Array<Object>` | ||
###### tag - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/tags/) | ||
Type: `String` | ||
Value: `SHIPPING_UPDATE | RESERVATION_UPDATE | ISSUE_RESOLUTION APPOINTMENT_UPDATE | GAME_EVENT | TRANSPORTATION_UPDATE | FEATURE_FUNCTIONALITY_UPDATE | TICKET_UPDATE` | ||
```js | ||
client.sendTaggedTemplate( | ||
client.sendGenericTemplate( | ||
USER_ID, | ||
@@ -438,296 +456,26 @@ [ | ||
], | ||
'GAME_EVENT' | ||
{ image_aspect_ratio: 'square' } | ||
); | ||
``` | ||
#### sendShippingUpdateTemplate(userId, elements) | ||
Adding a [tag](https://developers.facebook.com/docs/messenger-platform/message-tags) to a message allows you to send it outside the 24+1 window, for a limited number of use cases, per [Messenger Platform policy](https://developers.facebook.com/docs/messenger-platform/policy-overview). | ||
###### userId | ||
Type: `String | Object` | ||
Page-scoped user ID of the recipient or [recipient](https://developers.facebook.com/docs/messenger-platform/send-api-reference#recipient) object. | ||
###### elements | ||
Type: `Array<Object>` | ||
```js | ||
client.sendShippingUpdateTemplate(USER_ID, [ | ||
{ | ||
title: "Welcome to Peter's Hats", | ||
image_url: 'https://petersfancybrownhats.com/company_image.png', | ||
subtitle: "We've got the right hat for everyone.", | ||
default_action: { | ||
type: 'web_url', | ||
url: 'https://peterssendreceiveapp.ngrok.io/view?item=103', | ||
messenger_extensions: true, | ||
webview_height_ratio: 'tall', | ||
fallback_url: 'https://peterssendreceiveapp.ngrok.io/', | ||
client.sendGenericTemplate( | ||
USER_ID, | ||
[ | ||
{ | ||
// ... | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'postback', | ||
title: 'Start Chatting', | ||
payload: 'DEVELOPER_DEFINED_PAYLOAD', | ||
}, | ||
], | ||
}, | ||
]); | ||
], | ||
{ tag: 'ISSUE_RESOLUTION' } | ||
); | ||
``` | ||
#### sendReservationUpdateTemplate(userId, elements) | ||
<br /> | ||
###### userId | ||
#### sendListTemplate(userId, items, buttons, options) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/list-template) | ||
Type: `String | Object` | ||
Send list message templates to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
Page-scoped user ID of the recipient or [recipient](https://developers.facebook.com/docs/messenger-platform/send-api-reference#recipient) object. | ||
###### elements | ||
Type: `Array<Object>` | ||
```js | ||
client.sendReservationUpdateTemplate(USER_ID, [ | ||
{ | ||
title: "Welcome to Peter's Hats", | ||
image_url: 'https://petersfancybrownhats.com/company_image.png', | ||
subtitle: "We've got the right hat for everyone.", | ||
default_action: { | ||
type: 'web_url', | ||
url: 'https://peterssendreceiveapp.ngrok.io/view?item=103', | ||
messenger_extensions: true, | ||
webview_height_ratio: 'tall', | ||
fallback_url: 'https://peterssendreceiveapp.ngrok.io/', | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'postback', | ||
title: 'Start Chatting', | ||
payload: 'DEVELOPER_DEFINED_PAYLOAD', | ||
}, | ||
], | ||
}, | ||
]); | ||
``` | ||
#### sendIssueResolutionTemplate(userId, elements) | ||
###### userId | ||
Type: `String | Object` | ||
Page-scoped user ID of the recipient or [recipient](https://developers.facebook.com/docs/messenger-platform/send-api-reference#recipient) object. | ||
###### elements | ||
Type: `Array<Object>` | ||
```js | ||
client.sendIssueResolutionTemplate(USER_ID, [ | ||
{ | ||
title: "Welcome to Peter's Hats", | ||
image_url: 'https://petersfancybrownhats.com/company_image.png', | ||
subtitle: "We've got the right hat for everyone.", | ||
default_action: { | ||
type: 'web_url', | ||
url: 'https://peterssendreceiveapp.ngrok.io/view?item=103', | ||
messenger_extensions: true, | ||
webview_height_ratio: 'tall', | ||
fallback_url: 'https://peterssendreceiveapp.ngrok.io/', | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'postback', | ||
title: 'Start Chatting', | ||
payload: 'DEVELOPER_DEFINED_PAYLOAD', | ||
}, | ||
], | ||
}, | ||
]); | ||
``` | ||
#### sendAppointmentUpdateTemplate(userId, elements) | ||
###### userId | ||
Type: `String | Object` | ||
Page-scoped user ID of the recipient or [recipient](https://developers.facebook.com/docs/messenger-platform/send-api-reference#recipient) object. | ||
###### elements | ||
Type: `Array<Object>` | ||
```js | ||
client.sendAppointmentUpdateTemplate(USER_ID, [ | ||
{ | ||
title: "Welcome to Peter's Hats", | ||
image_url: 'https://petersfancybrownhats.com/company_image.png', | ||
subtitle: "We've got the right hat for everyone.", | ||
default_action: { | ||
type: 'web_url', | ||
url: 'https://peterssendreceiveapp.ngrok.io/view?item=103', | ||
messenger_extensions: true, | ||
webview_height_ratio: 'tall', | ||
fallback_url: 'https://peterssendreceiveapp.ngrok.io/', | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'postback', | ||
title: 'Start Chatting', | ||
payload: 'DEVELOPER_DEFINED_PAYLOAD', | ||
}, | ||
], | ||
}, | ||
]); | ||
``` | ||
#### sendGameEventTemplate(userId, elements) | ||
###### userId | ||
Type: `String | Object` | ||
Page-scoped user ID of the recipient or [recipient](https://developers.facebook.com/docs/messenger-platform/send-api-reference#recipient) object. | ||
###### elements | ||
Type: `Array<Object>` | ||
```js | ||
client.sendGameEventTemplate(USER_ID, [ | ||
{ | ||
title: "Welcome to Peter's Hats", | ||
image_url: 'https://petersfancybrownhats.com/company_image.png', | ||
subtitle: "We've got the right hat for everyone.", | ||
default_action: { | ||
type: 'web_url', | ||
url: 'https://peterssendreceiveapp.ngrok.io/view?item=103', | ||
messenger_extensions: true, | ||
webview_height_ratio: 'tall', | ||
fallback_url: 'https://peterssendreceiveapp.ngrok.io/', | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'postback', | ||
title: 'Start Chatting', | ||
payload: 'DEVELOPER_DEFINED_PAYLOAD', | ||
}, | ||
], | ||
}, | ||
]); | ||
``` | ||
#### sendTransportationUpdateTemplate(userId, elements) | ||
###### userId | ||
Type: `String | Object` | ||
Page-scoped user ID of the recipient or [recipient](https://developers.facebook.com/docs/messenger-platform/send-api-reference#recipient) object. | ||
###### elements | ||
Type: `Array<Object>` | ||
```js | ||
client.sendTransportationUpdateTemplate(USER_ID, [ | ||
{ | ||
title: "Welcome to Peter's Hats", | ||
image_url: 'https://petersfancybrownhats.com/company_image.png', | ||
subtitle: "We've got the right hat for everyone.", | ||
default_action: { | ||
type: 'web_url', | ||
url: 'https://peterssendreceiveapp.ngrok.io/view?item=103', | ||
messenger_extensions: true, | ||
webview_height_ratio: 'tall', | ||
fallback_url: 'https://peterssendreceiveapp.ngrok.io/', | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'postback', | ||
title: 'Start Chatting', | ||
payload: 'DEVELOPER_DEFINED_PAYLOAD', | ||
}, | ||
], | ||
}, | ||
]); | ||
``` | ||
#### sendFeatureFunctionalityUpdateTemplate(userId, elements) | ||
###### userId | ||
Type: `String | Object` | ||
Page-scoped user ID of the recipient or [recipient](https://developers.facebook.com/docs/messenger-platform/send-api-reference#recipient) object. | ||
###### elements | ||
Type: `Array<Object>` | ||
```js | ||
client.sendFeatureFunctionalityUpdateTemplate(USER_ID, [ | ||
{ | ||
title: "Welcome to Peter's Hats", | ||
image_url: 'https://petersfancybrownhats.com/company_image.png', | ||
subtitle: "We've got the right hat for everyone.", | ||
default_action: { | ||
type: 'web_url', | ||
url: 'https://peterssendreceiveapp.ngrok.io/view?item=103', | ||
messenger_extensions: true, | ||
webview_height_ratio: 'tall', | ||
fallback_url: 'https://peterssendreceiveapp.ngrok.io/', | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'postback', | ||
title: 'Start Chatting', | ||
payload: 'DEVELOPER_DEFINED_PAYLOAD', | ||
}, | ||
], | ||
}, | ||
]); | ||
``` | ||
#### sendTicketUpdateTemplate(userId, elements) | ||
###### userId | ||
Type: `String | Object` | ||
Page-scoped user ID of the recipient or [recipient](https://developers.facebook.com/docs/messenger-platform/send-api-reference#recipient) object. | ||
###### elements | ||
Type: `Array<Object>` | ||
```js | ||
client.sendTicketUpdateTemplate(USER_ID, [ | ||
{ | ||
title: "Welcome to Peter's Hats", | ||
image_url: 'https://petersfancybrownhats.com/company_image.png', | ||
subtitle: "We've got the right hat for everyone.", | ||
default_action: { | ||
type: 'web_url', | ||
url: 'https://peterssendreceiveapp.ngrok.io/view?item=103', | ||
messenger_extensions: true, | ||
webview_height_ratio: 'tall', | ||
fallback_url: 'https://peterssendreceiveapp.ngrok.io/', | ||
}, | ||
buttons: [ | ||
{ | ||
type: 'postback', | ||
title: 'Start Chatting', | ||
payload: 'DEVELOPER_DEFINED_PAYLOAD', | ||
}, | ||
], | ||
}, | ||
]); | ||
``` | ||
#### sendListTemplate(userId, items, buttons, topElementStyle) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/list-template) | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/14858155_1136082199802015_362293724211838976_n.png?oh=46900eb955ff8ea1040fc5353d9be2fa&oe=59F245DD" alt="sendListTemplate" width="500" /> | ||
@@ -749,5 +497,11 @@ | ||
###### topElementStyle | ||
###### options | ||
Type: `Object` | ||
###### options.top_element_style | ||
Type: `String` | ||
Value: `large | compact` | ||
Default: `large` | ||
@@ -788,8 +542,12 @@ ```js | ||
], | ||
'compact' | ||
{ top_element_style: 'compact' } | ||
); | ||
``` | ||
<br /> | ||
#### sendOpenGraphTemplate(userId, elements) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/open-graph-template) | ||
Send open graph message templates to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
###### userId | ||
@@ -820,4 +578,8 @@ | ||
<br /> | ||
#### sendReceiptTemplate(userId, receipt) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/receipt-template) | ||
Send receipt message templates to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13466939_915325738590743_1056699384_n.png?oh=bd6869385dee4c2cfaef1329fc660a01&oe=5A0331D4" alt="sendReceiptTemplate" width="250" /> | ||
@@ -888,4 +650,8 @@ | ||
<br /> | ||
#### sendAirlineBoardingPassTemplate(userId, attributes) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/airline-boardingpass-template) | ||
Send airline boarding pass message templates to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13466921_1408414619175015_4955822_n.png?oh=3136f1ef03e482bda03f433b18745033&oe=5A316E63" alt="sendAirlineBoardingPassTemplate" width="600" /> | ||
@@ -1022,4 +788,8 @@ | ||
<br /> | ||
#### sendAirlineCheckinTemplate(userId, attributes) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/airline-checkin-template) | ||
Send airline checkin message templates to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13466944_1156144061116360_549622536_n.png?oh=1aa077176a59f346abf8d199e133d2d2&oe=59F2476C" alt="sendAirlineCheckinTemplate" width="250" /> | ||
@@ -1068,4 +838,8 @@ | ||
<br /> | ||
#### sendAirlineItineraryTemplate(userId, attributes) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/airline-itinerary-template) | ||
Send airline itinerary message templates to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13466573_979516348832909_515976570_n.png?oh=1eb97bf63d3a9f5c333ba28184085950&oe=59FB8738" alt="sendAirlineItineraryTemplate" width="600" /> | ||
@@ -1208,4 +982,8 @@ | ||
<br /> | ||
#### sendAirlineFlightUpdateTemplate(userId, attributes) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/send-api-reference/airline-update-template) | ||
Send airline flight update message templates to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
<img src="https://scontent-tpe1-1.xx.fbcdn.net/v/t39.2365-6/13503467_502166346641834_1768260104_n.png?oh=141fe3238aa6f04d413705860eb52ede&oe=59F5C6BC" alt="sendAirlineFlightUpdateTemplate" width="250" /> | ||
@@ -1252,2 +1030,4 @@ | ||
<br /> | ||
<a id="quick-replies" /> | ||
@@ -1261,2 +1041,4 @@ | ||
Send messages with quick replies to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request). | ||
###### userId | ||
@@ -1286,2 +1068,4 @@ | ||
<br /> | ||
<a id="sender-actions" /> | ||
@@ -1295,2 +1079,4 @@ | ||
Send sender actions to specified user using the [Send API](https://developers.facebook.com/docs/messenger-platform/reference/send-api#request), to let users know you are processing their request. | ||
###### userId | ||
@@ -1312,5 +1098,7 @@ | ||
<br /> | ||
#### markSeen(userId) | ||
Mark last message as read. | ||
Mark last message as read for specified user. | ||
@@ -1327,6 +1115,8 @@ ###### userId | ||
#### turnTypingIndicatorsOn(userId) | ||
<br /> | ||
Turn typing indicators on. | ||
#### typingOn(userId) | ||
Turn typing indicators on for specified user. | ||
###### userId | ||
@@ -1339,9 +1129,11 @@ | ||
```js | ||
client.turnTypingIndicatorsOn(USER_ID); | ||
client.typingOn(USER_ID); | ||
``` | ||
#### turnTypingIndicatorsOff(userId) | ||
<br /> | ||
Turn typing indicators off. | ||
#### typingOff(userId) | ||
Turn typing indicators off for specified user. | ||
###### userId | ||
@@ -1354,5 +1146,7 @@ | ||
```js | ||
client.turnTypingIndicatorsOff(USER_ID); | ||
client.typingOff(USER_ID); | ||
``` | ||
<br /> | ||
<a id="attachment-upload-api" /> | ||
@@ -1364,5 +1158,8 @@ | ||
Upload specified type attachment using URL address. | ||
###### type | ||
Type: `String` | ||
Value: `image | video | audio | file` | ||
@@ -1379,4 +1176,8 @@ ###### url | ||
<br /> | ||
#### uploadAudio(url) | ||
Upload audio attachment using URL address. | ||
###### url | ||
@@ -1392,4 +1193,8 @@ | ||
<br /> | ||
#### uploadImage(url) | ||
Upload image attachment using URL address. | ||
###### url | ||
@@ -1405,4 +1210,8 @@ | ||
<br /> | ||
#### uploadVideo(url) | ||
Upload video attachment using URL address. | ||
###### url | ||
@@ -1418,4 +1227,8 @@ | ||
<br /> | ||
#### uploadFile(url) | ||
Upload file attachment using URL address. | ||
###### url | ||
@@ -1430,2 +1243,5 @@ | ||
``` | ||
<br /> | ||
<a id="tags" /> | ||
@@ -1437,2 +1253,4 @@ | ||
Getting tags list via an API. | ||
```js | ||
@@ -1486,2 +1304,4 @@ client.getMessageTags().then(tags => { | ||
<br /> | ||
<a id="user-profile-api" /> | ||
@@ -1493,2 +1313,4 @@ | ||
Retrieving a Person's Profile. | ||
###### userId | ||
@@ -1514,2 +1336,4 @@ | ||
<br /> | ||
<a id="messenger-profile-api" /> | ||
@@ -1521,5 +1345,8 @@ | ||
Retrieves the current value of one or more Messenger Profile properties by name. | ||
###### fields | ||
Type: `Array<String>` | ||
Value: `account_linking_url | persistent_menu | get_started | greeting | whitelisted_domains | payment_settings | target_audience | home_url` | ||
@@ -1554,4 +1381,8 @@ ```js | ||
<br /> | ||
#### setMessengerProfile(profile) | ||
Sets the values of one or more Messenger Profile properties. Only properties set in the request body will be overwritten. | ||
###### profile | ||
@@ -1582,7 +1413,12 @@ | ||
<br /> | ||
#### deleteMessengerProfile(fields) | ||
Deletes one or more Messenger Profile properties. Only properties specified in the fields array will be deleted. | ||
###### fields | ||
Type: `Array<String>` | ||
Value: `account_linking_url | persistent_menu | get_started | greeting | whitelisted_domains | payment_settings | target_audience | home_url` | ||
@@ -1593,2 +1429,4 @@ ```js | ||
<br /> | ||
<a id="persistent-menu" /> | ||
@@ -1602,2 +1440,4 @@ | ||
Retrieves the current value of persistent menu. | ||
```js | ||
@@ -1627,4 +1467,8 @@ client.getPersistentMenu().then(menu => { | ||
<br /> | ||
#### setPersistentMenu(menu) | ||
Sets the values of persistent menu. | ||
###### menu | ||
@@ -1689,4 +1533,10 @@ | ||
> Note: You must set a get started button to use the persistent menu. | ||
<br /> | ||
#### deletePersistentMenu | ||
Deletes persistent menu. | ||
```js | ||
@@ -1704,2 +1554,4 @@ client.deletePersistentMenu(); | ||
Retrieves the current value of get started button. | ||
```js | ||
@@ -1714,4 +1566,8 @@ client.getGetStartedButton().then(getStarted => { | ||
<br /> | ||
#### setGetStartedButton(payload) | ||
Sets the values of get started button. | ||
###### payload | ||
@@ -1725,4 +1581,8 @@ | ||
<br /> | ||
#### deleteGetStartedButton | ||
Deletes get started button. | ||
```js | ||
@@ -1740,2 +1600,4 @@ client.deleteGetStartedButton(); | ||
Retrieves the current value of greeting text. | ||
```js | ||
@@ -1753,4 +1615,8 @@ client.getGreetingText().then(greeting => { | ||
<br /> | ||
#### setGreetingText(greeting) | ||
Sets the values of greeting text. | ||
###### greeting | ||
@@ -1769,4 +1635,8 @@ | ||
<br /> | ||
s | ||
#### deleteGreetingText | ||
Deletes greeting text. | ||
```js | ||
@@ -1782,2 +1652,4 @@ client.deleteGreetingText(); | ||
Retrieves the current value of domain whitelist. | ||
```js | ||
@@ -1790,4 +1662,8 @@ client.getDomainWhitelist().then(domains => { | ||
<br /> | ||
#### setDomainWhitelist(domains) | ||
Sets the values of domain whitelist. | ||
###### domains | ||
@@ -1801,4 +1677,8 @@ | ||
<br /> | ||
#### deleteDomainWhitelist | ||
Deletes domain whitelist. | ||
```js | ||
@@ -1814,2 +1694,4 @@ client.deleteDomainWhitelist(); | ||
Retrieves the current value of account linking URL. | ||
```js | ||
@@ -1825,4 +1707,8 @@ client.getAccountLinkingURL().then(accountLinking => { | ||
<br /> | ||
#### setAccountLinkingURL(url) | ||
Sets the values of account linking URL. | ||
###### url | ||
@@ -1838,4 +1724,8 @@ | ||
<br /> | ||
#### deleteAccountLinkingURL | ||
Deletes account linking URL. | ||
```js | ||
@@ -1851,2 +1741,4 @@ client.deleteAccountLinkingURL(); | ||
Retrieves the current value of payment settings. | ||
```js | ||
@@ -1863,4 +1755,8 @@ client.getPaymentSettings().then(settings => { | ||
<br /> | ||
#### setPaymentPrivacyPolicyURL(url) | ||
Sets the values of payment privacy policy URL. | ||
###### url | ||
@@ -1874,4 +1770,8 @@ | ||
<br /> | ||
#### setPaymentPublicKey(key) | ||
Sets the values of payment public key. | ||
###### key | ||
@@ -1885,4 +1785,8 @@ | ||
<br /> | ||
#### setPaymentTestUsers(users) | ||
Sets the values of payment test users. | ||
###### users | ||
@@ -1896,4 +1800,8 @@ | ||
<br /> | ||
#### deletePaymentSettings | ||
Deletes payment settings. | ||
```js | ||
@@ -1903,2 +1811,4 @@ client.deletePaymentSettings(); | ||
<br /> | ||
<a id="target-audience" /> | ||
@@ -1910,2 +1820,4 @@ | ||
Retrieves the current value of target audience. | ||
```js | ||
@@ -1923,4 +1835,8 @@ client.getTargetAudience().then(targetAudience => { | ||
<br /> | ||
#### setTargetAudience(type, whitelist, blacklist) | ||
Sets the values of target audience. | ||
###### type | ||
@@ -1942,4 +1858,8 @@ | ||
<br /> | ||
#### deleteTargetAudience | ||
Deletes target audience. | ||
```js | ||
@@ -1949,2 +1869,4 @@ client.deleteTargetAudience(); | ||
<br /> | ||
<a id="chat-extension-home-url" /> | ||
@@ -1956,2 +1878,4 @@ | ||
Retrieves the current value of chat extension home URL. | ||
```js | ||
@@ -1968,4 +1892,8 @@ client.getChatExtensionHomeURL().then(chatExtension => { | ||
<br /> | ||
#### setChatExtensionHomeURL(url, attributes) | ||
Sets the values of chat extension home URL. | ||
###### url | ||
@@ -1986,4 +1914,8 @@ | ||
<br /> | ||
#### deleteChatExtensionHomeURL | ||
Deletes chat extension home URL. | ||
```js | ||
@@ -1993,2 +1925,4 @@ client.deleteChatExtensionHomeURL(); | ||
<br /> | ||
<a id="messenger-code-api" /> | ||
@@ -2002,2 +1936,4 @@ | ||
Generating a Messenger code. | ||
###### options | ||
@@ -2031,2 +1967,4 @@ | ||
<br /> | ||
### Handover Protocol API | ||
@@ -2036,2 +1974,4 @@ | ||
Passes thread control from your app to another app. | ||
###### userId | ||
@@ -2055,4 +1995,8 @@ | ||
<br /> | ||
#### takeThreadControl(userId, metadata) - [Official Docs](https://developers.facebook.com/docs/messenger-platform/take-thread-control) | ||
Takes control of a specific thread from a Secondary Receiver app. | ||
###### userId | ||
@@ -2072,4 +2016,8 @@ | ||
<br /> | ||
#### getSecondaryReceivers - [Official Docs](https://developers.facebook.com/docs/messenger-platform/secondary-receivers) | ||
Retrieves the list of apps that are Secondary Receivers for a page. | ||
```js | ||
@@ -2091,2 +2039,4 @@ client.getSecondaryReceivers().then(receivers => { | ||
<br /> | ||
<a id="page-messaging-insights-api" /> | ||
@@ -2098,2 +2048,4 @@ | ||
Retrieves a count of the unique active threads your app participated in per day. | ||
```js | ||
@@ -2128,4 +2080,8 @@ client.getDailyUniqueActiveThreadCounts().then(counts => { | ||
<br /> | ||
#### getDailyUniqueConversationCounts | ||
Retrieves a count of actions that were initiated by people your app was in an active thread with per day. | ||
```js | ||
@@ -2168,2 +2124,4 @@ client.getDailyUniqueConversationCounts().then(counts => { | ||
<br /> | ||
<a id="built-in-nlp-api" /> | ||
@@ -2175,2 +2133,4 @@ | ||
Set values of NLP configs. | ||
###### config | ||
@@ -2194,4 +2154,8 @@ | ||
<br /> | ||
#### enableNLP | ||
Enabling Built-in NLP. | ||
```js | ||
@@ -2201,6 +2165,10 @@ client.enableNLP(); | ||
<br /> | ||
#### disableNLP | ||
Disabling Built-in NLP. | ||
```js | ||
client.disableNLP(); | ||
``` |
@@ -6,2 +6,3 @@ import querystring from 'querystring'; | ||
import invariant from 'invariant'; | ||
import omit from 'lodash.omit'; | ||
@@ -35,3 +36,2 @@ import type { | ||
SendSenderActionResponse, | ||
MessageTag, | ||
MessageTagResponse, | ||
@@ -413,8 +413,2 @@ FileData, | ||
sendIssueResolutionText = ( | ||
recipient: UserID | Recipient, | ||
text: string | ||
): Promise<SendMessageSucessResponse> => | ||
this.sendText(recipient, text, { tag: 'ISSUE_RESOLUTION' }); | ||
sendAudio = ( | ||
@@ -523,4 +517,6 @@ recipient: UserID | Recipient, | ||
elements: Array<TemplateElement>, | ||
ratio: string = 'horizontal', | ||
options?: SendOption | ||
options?: { | ||
...SendOption, | ||
image_aspect_ratio?: 'horizontal' | 'square', | ||
} = {} | ||
): Promise<SendMessageSucessResponse> => | ||
@@ -532,82 +528,7 @@ this.sendTemplate( | ||
elements, | ||
image_aspect_ratio: ratio, // FIXME rename to image_aspect_ratio? | ||
image_aspect_ratio: options.image_aspect_ratio || 'horizontal', | ||
}, | ||
options | ||
omit(options, ['image_aspect_ratio']) | ||
); | ||
// https://developers.facebook.com/docs/messenger-platform/send-api-reference/tags/ | ||
sendTaggedTemplate = ( | ||
recipient: UserID | Recipient, | ||
elements: Array<TemplateElement>, | ||
tag: MessageTag, | ||
ratio: string = 'horizontal' | ||
): Promise<SendMessageSucessResponse> => | ||
this.sendGenericTemplate(recipient, elements, ratio, { tag }); | ||
sendShippingUpdateTemplate = ( | ||
recipient: UserID | Recipient, | ||
elements: Array<TemplateElement>, | ||
ratio: string = 'horizontal' | ||
): Promise<SendMessageSucessResponse> => | ||
this.sendTaggedTemplate(recipient, elements, 'SHIPPING_UPDATE', ratio); | ||
sendReservationUpdateTemplate = ( | ||
recipient: UserID | Recipient, | ||
elements: Array<TemplateElement>, | ||
ratio: string = 'horizontal' | ||
): Promise<SendMessageSucessResponse> => | ||
this.sendTaggedTemplate(recipient, elements, 'RESERVATION_UPDATE', ratio); | ||
sendIssueResolutionTemplate = ( | ||
recipient: UserID | Recipient, | ||
elements: Array<TemplateElement>, | ||
ratio: string = 'horizontal' | ||
): Promise<SendMessageSucessResponse> => | ||
this.sendTaggedTemplate(recipient, elements, 'ISSUE_RESOLUTION', ratio); | ||
sendAppointmentUpdateTemplate = ( | ||
recipient: UserID | Recipient, | ||
elements: Array<TemplateElement>, | ||
ratio: string = 'horizontal' | ||
): Promise<SendMessageSucessResponse> => | ||
this.sendTaggedTemplate(recipient, elements, 'APPOINTMENT_UPDATE', ratio); | ||
sendGameEventTemplate = ( | ||
recipient: UserID | Recipient, | ||
elements: Array<TemplateElement>, | ||
ratio: string = 'horizontal' | ||
): Promise<SendMessageSucessResponse> => | ||
this.sendTaggedTemplate(recipient, elements, 'GAME_EVENT', ratio); | ||
sendTransportationUpdateTemplate = ( | ||
recipient: UserID | Recipient, | ||
elements: Array<TemplateElement>, | ||
ratio: string = 'horizontal' | ||
): Promise<SendMessageSucessResponse> => | ||
this.sendTaggedTemplate( | ||
recipient, | ||
elements, | ||
'TRANSPORTATION_UPDATE', | ||
ratio | ||
); | ||
sendFeatureFunctionalityUpdateTemplate = ( | ||
recipient: UserID | Recipient, | ||
elements: Array<TemplateElement>, | ||
ratio: string = 'horizontal' | ||
): Promise<SendMessageSucessResponse> => | ||
this.sendTaggedTemplate( | ||
recipient, | ||
elements, | ||
'FEATURE_FUNCTIONALITY_UPDATE', | ||
ratio | ||
); | ||
sendTicketUpdateTemplate = ( | ||
recipient: UserID | Recipient, | ||
elements: Array<TemplateElement>, | ||
ratio: string = 'horizontal' | ||
): Promise<SendMessageSucessResponse> => | ||
this.sendTaggedTemplate(recipient, elements, 'TICKET_UPDATE', ratio); | ||
// https://developers.facebook.com/docs/messenger-platform/send-api-reference/list-template | ||
@@ -618,3 +539,3 @@ sendListTemplate = ( | ||
buttons: Array<TemplateButton>, | ||
topElementStyle: string = 'large' | ||
options?: { top_element_style?: 'large' | 'compact' } = {} | ||
): Promise<SendMessageSucessResponse> => | ||
@@ -625,3 +546,3 @@ this.sendTemplate(recipient, { | ||
buttons, | ||
top_element_style: topElementStyle, | ||
top_element_style: options.top_element_style || 'large', | ||
}); | ||
@@ -753,3 +674,3 @@ | ||
turnTypingIndicatorsOn = ( | ||
typingOn = ( | ||
recipient: UserID | Recipient | ||
@@ -759,3 +680,3 @@ ): Promise<SendSenderActionResponse> => | ||
turnTypingIndicatorsOff = ( | ||
typingOff = ( | ||
recipient: UserID | Recipient | ||
@@ -762,0 +683,0 @@ ): Promise<SendSenderActionResponse> => |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
211225
-4.61%4
33.33%4558
-4.82%2086
-1.51%+ Added
+ Added