- [fix] fix LINE API URL typos for getting group and room member ids
- [new] implement
requestThreadControl
:
client.requestThreadControl(USER_ID, 'free formed text for primary app');
- [fix] handle axios error in batch
- [fix] let batch api use internal axios instance
- [fix] broadcast
startReachEstimation
request path - [fix] broadcast
getReachEstimate
request method
- [new] Support
origin
for test:
const { MessengerClient } = require('messaging-api-messenger');
const client = MessengerClient.connect({
accessToken: ACCESS_TOKEN,
origin: 'https://mydummytestserver.com',
});
- [fix] Add default value for LINE
_sendCarouselTemplate
options
-
[new] Support broadcast methods:
-
broadcastMessage(broadcastList, message)
-
broadcastText(broadcastList, text [, options])
-
broadcastPicture(broadcastList, picture [, options])
-
broadcastVideo(broadcastList, video [, options])
-
broadcastFile(broadcastList, file [, options])
-
broadcastContact(broadcastList, contact [, options])
-
broadcastLocation(broadcastList, location [, options])
-
broadcastURL(broadcastList, url [, options])
-
broadcastSticker(broadcastList, stickerId [, options])
-
broadcastCarouselContent(broadcastList, richMedia [, options])
- [new] add Slack
postEphemeral
method:
client.postEphemeral('C8763', 'U56781234', { attachments: [someAttachments] });
- [new] add SlackOAuthClient custom token support:
client.callMethod('chat.postMessage', {
token: 'custom token',
channel: CHANNEL,
text: 'hello',
});
- [fix] Not to use page token as default token when create subscription. #267
- [new] Add
getUpdates
:
client
.getUpdates({
limit: 10,
})
.then(data => {
console.log(data.result);
/*
[
{
update_id: 513400512,
message: {
message_id: 3,
from: {
id: 313534466,
first_name: 'first',
last_name: 'last',
username: 'username',
},
chat: {
id: 313534466,
first_name: 'first',
last_name: 'last',
username: 'username',
type: 'private',
},
date: 1499402829,
text: 'hi',
},
},
...
]
*/
});
- [changed] Support original
baseSize
key in LINE imagemap APIs.
- [fix] Not to attach empty array as
quick_replies
to message. #261
- [new] Add
sendVideoNote
:
client.sendVideoNote(CHAT_ID, 'https://example.com/video_note.mp4', {
duration: 40,
disable_notification: true,
});
- [changed] Rename arguments in
logCustomEvent
for consistency:
appId -> app_id
pageId -> page_id
userId -> page_scoped_user_id
client.logCustomEvents({
app_id: APP_ID,
page_id: PAGE_ID,
page_scoped_user_id: USER_ID,
events: [
{
_eventName: 'fb_mobile_purchase',
_valueToSum: 55.22,
_fb_currency: 'USD',
},
],
});
Original keys (appId
, pageId
, userId
) will be removed when v0.7
or v0.8
release.
- [changed] Rename
Messenger
toMessengerBatch
:
const { MessengerBatch } = require('messaging-api-messenger');
client.sendBatch([
MessengerBatch.createText(USER_ID, '1'),
MessengerBatch.createText(USER_ID, '2'),
MessengerBatch.createText(USER_ID, '3'),
MessengerBatch.createText(USER_ID, '4'),
MessengerBatch.createText(USER_ID, '5'),
]);
Original APIs on Messenger
will be changed when v0.7
release.
- [new] Add
createSubscription
method:
client.createSubscription({
app_id: APP_ID,
callback_url: 'https://mycallback.com',
fields: ['messages', 'messaging_postbacks', 'messaging_referrals'],
verify_token: VERIFY_TOKEN,
});
- [new] ID Matching API:
Given a user ID for an app, retrieve the IDs for other apps owned by the same business.
client
.getIdsForApps({
user_id: USER_ID,
app_secret: APP_SECRET,
})
.then(result => {
console.log(result);
});
Given a user ID for a Page (associated with a bot), retrieve the IDs for other Pages owned by the same business.
client
.getIdsForPages({
user_id: USER_ID,
app_secret: APP_SECRET,
})
.then(result => {
console.log(result);
});
- [fix] pass options into
setGetStarted
Support Game APIs!
sendGame
:
client.sendGame(CHAT_ID, 'Mario Bros.', {
disable_notification: true,
});
setGameScore
:
client.setGameScore(USER_ID, 999);
getGameHighScores
:
client.getGameHighScores(USER_ID);
- [new] Support new options (
imageAspectRatio
,imageSize
,imageBackgroundColor
) for template message images #247
client.replyButtonTemplate(REPLY_TOKEN, altText, {
thumbnailImageUrl,
title,
imageAspectRatio: 'rectangle',
imageSize: 'cover',
imageBackgroundColor: '#FFFFFF',
actions,
});
client.replyCarouselTemplate(REPLY_TOKEN, altText, columns, {
imageAspectRatio: 'rectangle',
imageSize: 'cover',
});
- [new] Add
sendMediaGroup
:
client.sendMediaGroup(CHAT_ID, [
{ type: 'photo', media: 'BQADBAADApYAAgcZZAfj2-xeidueWwI' },
]);
- [new] Support WeChat! 🎉🎉🎉
- [breaking] Remove
client.getHTTPClient()
useclient.axios
instead #236
- [breaking] Set default
is_reusable
to false when upload attachment #221 - [breaking] Remove messenger profile deprecated methods #239
getGetStartedButton -> getGetStarted
setGetStartedButton -> setGetStarted
deleteGetStartedButton -> deleteGetStarted
getGreetingText -> getGreeting
setGreetingText -> setGreeting
deleteGreetingText -> deleteGreeting
getDomainWhitelist -> getWhitelistedDomains
setDomainWhitelist -> setWhitelistedDomains
deleteDomainWhitelist -> deleteWhitelistedDomains
getChatExtensionHomeURL -> getHomeURL
setChatExtensionHomeURL -> setHomeURL
deleteChatExtensionHomeURL -> deleteHomeURL
- [new] Add Inline mode API -
answerInlineQuery
:
client.answerInlineQuery(
'INLINE_QUERY_ID',
[
{
type: 'photo',
id: 'UNIQUE_ID',
photo_file_id: 'FILE_ID',
title: 'PHOTO_TITLE',
},
{
type: 'audio',
id: 'UNIQUE_ID',
audio_file_id: 'FILE_ID',
caption: 'AUDIO_TITLE',
},
],
{
cache_time: 1000,
}
);
-
[new] Add
client.accessToken
getter -
[new] Support pass message object to
postMessage
:
client.postMessage('C8763', { text: 'Hello!' });
client.postMessage('C8763', { attachments: [someAttachments] });
client.postMessage('C8763', { text: 'Hello!' }, { as_user: true });
-
[new] Support call api methods with custom
access_token
(Experimental) -
[fix] Fixed
uploadAttachment
with buffer data using afilename
option pass in:
client.uploadAttachment('image', buffer, { filename: 'image.jpg' });
- [new] Support pass
options.quick_replies
to send message with quick replies: #216
client.sendText(USER_ID, 'Pick a color:', {
quick_replies: [
{
content_type: 'text',
title: 'Red',
payload: 'DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_RED',
},
],
});
- [new] Support upload attachment from buffer or stream #219
For example:
client.uploadImage(buffer);
client.uploadImage(fs.creatReadStream('xxx.jpg'));
- [docs] update docs and type for nlp config model #222
- [new] support
getPageInfo
to get page name and page id using Graph API. For example:
client.getPageInfo().then(page => {
console.log(page);
// {
// name: 'Bot Demo',
// id: '1895382890692546',
// }
});
- [new] auto stringify
options.attachments
in SlackpostMessage
#208
- [fix] make NLP config model value match Facebook API #207
- [fix] make sure
options.messaging_type
works for all send apis #205
A large update to support Messenger Platform 2.2. 🎉
Messenger Team has created a messaging_type
property which is required in all requests to the send API. You can send it with messaging_type
option:
client.sendText(USER_ID, 'Awesome!', { messaging_type: 'RESPONSE' });
Available messaging types:
UPDATE
as defaultRESPONSE
using{ messaging_type: 'RESPONSE' }
optionsMESSAGE_TAG
using{ tag: 'ANY_TAG' }
optionsNON_PROMOTIONAL_SUBSCRIPTION
using{ messaging_type: 'NON_PROMOTIONAL_SUBSCRIPTION' }
options
Two additional tags, PAIRING_UPDATE
and APPLICATION_UPDATE
, has been supported by passing as option:
client.sendGenericTemplate(
USER_ID,
[
{
//...
},
],
{ tag: 'PAIRING_UPDATE' }
);
client.sendGenericTemplate(
USER_ID,
[
{
//...
},
],
{ tag: 'APPLICATION_UPDATE' }
);
New Media Template - docs
In order to make image and video sharing more interactive, you can attach a CTA button to your media:
client.sendMediaTemplate(USER_ID, [
{
media_type: 'image',
attachment_id: '1854626884821032',
buttons: [
{
type: 'web_url',
url: 'https://en.wikipedia.org/wiki/Rickrolling',
title: 'View Website',
},
],
},
]);
Broadcast - docs
To use the broadcast API, you must create messages using createMessageCreative
:
client
.createMessageCreative([
{
attachment: {
type: 'template',
payload: {
template_type: 'generic',
elements: [
{
title: 'Welcome to Our Marketplace!',
image_url: 'https://www.facebook.com/jaspers.png',
subtitle: 'Fresh fruits and vegetables. Yum.',
buttons: [
{
type: 'web_url',
url: 'https://www.jaspersmarket.com',
title: 'View Website',
},
],
},
],
},
},
},
])
.then(({ message_creative_id }) => {
// ...
});
After you got a message_creative_id
, you can send it as broadcast messages:
client.sendBroadcastMessage(message_creative_id);
Or sponsored messages:
client.sendSponsoredMessage(message_creative_id, {
message_creative_id: 938461089,
daily_budget: 100,
bid_amount: 400,
targeting: "{'geo_locations': {'countries':['US']}}",
});
Targeting Broadcast Messages - docs
You can manage your users with associated labels using following methods:
createLabel(name)
associateLabel(userId, labelId)
dissociateLabel(userId, labelId)
getAssociatedLabels(userId)
getLabelDetails(labelId, options)
getLabelList()
deleteLabel(labelId)
And send broadcast messages to only associated users:
client.sendBroadcastMessage(message_creative_id, { custom_label_id: LABEL_ID });
Estimating Broadcast Size - docs
To get the approximate number of people a broadcast message will be sent, you can use Estimating API:
- startReachEstimation(customLabelId)
- getReachEstimate(reachEstimationId)
Note: Due to the fact that reach estimation is a resource intensive process, it is executed in two steps.
More Configuration for Built-in NLP - docs
We have more parameters are supported now:
client.setNLPConfigs({
nlp_enabled: true,
model: 'custom',
custom_token: 'your_token',
verbose: true,
n_best: 8,
});
There are a bunch of insights APIs introduced in this version:
getInsights(metrics, options)
getBlockedConversations
getReportedConversations
getReportedConversationsByReportType
getBroadcastMessagesSent
Note:
getDailyUniqueConversationCounts
is deprecated.
Custom Event Logging - docs
Log custom events by using the Application Activities Graph API endpoint.
client.logCustomEvents({
appId: APP_ID,
pageId: PAGE_ID,
userId: USER_ID,
events: [
{
_eventName: 'fb_mobile_purchase',
_valueToSum: 55.22,
_fb_currency: 'USD',
},
],
});
Support messenger platform 2.2 - #186
See more details in Messenger official release post and changelog.
-
[new] Support Slack conversations APIs #185
- getConversationInfo
- getConversationMembers
- getAllConversationMembers
- getConversationList
- getAllConversationList
- [new] Added
passThreadControlToPageInbox
method:
client.passThreadControlToPageInbox(USER_ID);
is equivalent to
client.passThreadControl(USER_ID, 263902037430900);
See more details in Messenger docs.
- [new] Introducing new Rich Menu APIs!
See more details in LINE Official docs.
- [fix] return null when no any messenger profile setting exists #176
- [deps] Upgrade
axios
tov0.17.0
.
- [renamed] Following profile methods has been renamed to match api key:
getGetStartedButton
->getGetStarted
setGetStartedButton
->setGetStarted
deleteGetStartedButton
->deleteGetStarted
getGreetingText
->getGreeting
setGreetingText
->setGreeting
deleteGreetingText
->deleteGreeting
getChatExtensionHomeURL
->getHomeURL
setChatExtensionHomeURL
->setHomeURL
deleteChatExtensionHomeURL
->deleteHomeURL
The deprecated methods will be removed after v0.6.0
.
- [new] A big improvement on error message.
For example, when you catch the error and log it out:
client.sendText().catch(console.error);
You can get some useful information to help you resolve the issue.
Error: Messenger API - 2500 OAuthException An active access token must be used to query information about the current user.
at handleError (/Users/chentsulin/Projects/yoctol/ttt/node_modules/messaging-api-messenger/lib/MessengerClient.js:64:9)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Error Message -
Messenger API - 2500 OAuthException An active access token must be used to query information about the current user.
Request -
POST https://graph.facebook.com/v2.10/me/messages?access_token=
Request Data -
{
"recipient": {
"id": ""
},
"message": {
"text": ""
}
}
Response -
400 Bad Request
Response Data -
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "GOnNuiN/ewZ"
}
}
The error messages are powered by axios-error package.
- [deprecated]
client.getHTTPClient()
method is deprecated. useclient.axios
getter instead.
- [breaking]
client.version
now return version number string (2.10
) instead of the v-prefix version (v2.10
).
- [fix] Always throw error when status != 0 in api response body.
- [new] Support methods introduced in Telegram 3.4
See more details in Telegram October 11, 2017 changelog.
-
[new] implement getAccountInfo, getUserDetails, getOnlineStatus:
- [renamed]
getDomainWhitelist
->getWhitelistedDomains
- [renamed]
setDomainWhitelist
->setWhitelistedDomains
- [renamed]
deleteDomainWhitelist
->deleteWhitelistedDomains
- [new] First release of Viber API Support!
- [new] Added a LINE Bot example. Thanks @madeinfree!
-
[new] Gets Payments API support! 🎉
sendInvoice
answerShippingQuery
answerPreCheckoutQuery
- [new] Export version of Graph API:
const { MessengerClient } = require('messaging-api-messenger');
const client = MessengerClient.connect(accessToken);
client.version; // "v2.10"
- [fix] Wrong case in filename.
- [breaking] Renamed
send
tosendMessage
- [breaking] Renamed all of
LINE
to PascalCaseLine
(follow convention from other modules), e.g.LineClient.connect
,Line.createText
.
Example:
const { Line, LineClient } = require('messaging-api-line');
- [docs] Fix a typo.
- [new] Support message factories:
- LINE.createText
- LINE.createImage
- LINE.createVideo
- createAudio
- createLocation
- createSticker
- createImagemap
- createTemplate
- createButtonTemplate
- createConfirmTemplate
- createCarouselTemplate
- createImageCarouselTemplate
For example:
const { LINE } = require('messaging-api-line');
client.reply(REPLY_TOKEN, [
LINE.createText('Hello'),
LINE.createImage(
'https://example.com/original.jpg',
'https://example.com/preview.jpg'
),
LINE.createText('End'),
]);
- [docs] Show method arguments in tables.
- [new] Support message batching via
sendBatch
:
const { Messenger } = require('messaging-api-messenger');
client.sendBatch([
Messenger.createText(USER_ID, '1'),
Messenger.createText(USER_ID, '2'),
Messenger.createText(USER_ID, '3'),
Messenger.createText(USER_ID, '4'),
Messenger.createText(USER_ID, '5'),
]);
- publish docs changes to npm.
-
[new] Support ImageCarouselTemplate methods
- replyImageCarouselTemplate
- pushImageCarouselTemplate
- multicaseImageCarouselTemplate
- [new] using
AttachmentPayload
to send cached attachment:
client.sendImage(USER_ID, { attachment_id: '55688' });
client.sendAudio(USER_ID, { attachment_id: '55688' });
client.sendVideo(USER_ID, { attachment_id: '55688' });
client.sendFile(USER_ID, { attachment_id: '55688' });
- [docs] A big improvement.
- [breaking] Renamed messenger typing methods:
turnTypingIndicatorsOn => typingOn
turnTypingIndicatorsOff => typingOff
- [breaking] Removed tagged template methods:
- sendTaggedTemplate
- sendShippingUpdateTemplate
- sendReservationUpdateTemplate
- sendIssueResolutionTemplate
- sendAppointmentUpdateTemplate
- sendGameEventTemplate
- sendTransportationUpdateTemplate
- sendFeatureFunctionalityUpdateTemplate
- sendTicketUpdateTemplate
Use tag
option instead:
client.sendText(USER_ID, 'Hello!', { tag: 'ISSUE_RESOLUTION' });
client.sendGenericTemplate(
USER_ID,
[
{
// ...
},
],
{ tag: 'ISSUE_RESOLUTION' }
);
- [breaking] Renamed
topElementStyle
tooptions.top_element_style
insendListTemplate
@6840ec7 - [breaking] Renamed
ratio
tooptions.image_aspect_ratio
insendGenericTemplate
@701e717
- [breaking] Removed
SlackClient
export, usingSlackOAuthClient
orSlackWebhookClient
instead. - [breaking]
getUserList
now returns object includes cursor.
- [breaking] Changed
contact.firstName
tocontact.first_name
, andcontact.phoneNumber
tocontact.phone_number
insendContact
method.
- [new] Support
mark_seen
sender action:
client.markSeen(USER_ID);
- [new] Implement supergroup or channel methods
kickChatMember
unbanChatMember
restrictChatMember
promoteChatMember
exportChatInviteLink
setChatPhoto
deleteChatPhoto
setChatTitle
setChatDescription
pinChatMessage
unpinChatMessage
leaveChat
- [new] Support calling send API with recipient object:
client.sendText(
{
phone_number: '+1(212)555-2368',
name: { first_name: 'John', last_name: 'Doe' },
},
'Hello World'
);
- [new] Support send media (sendAudio、sendImage、sendVideo、sendFile) using
Buffer
orReadStream
:
client.sendImage(USER_ID, buffer);
client.sendFile(USER_ID, fs.createReadStream('LookGreatToMe.pdf'));
- [docs] Added Slack OAuth API document
- [new] Implement Page Messaging Insights API
- [new] Implement Built-in NLP API
- [new] Slack OAuth Client
- [docs] A big improvement.
- [docs] prettify code examples with prettier
- [new] Chat Extension Home URL API
- [new] Messenger Code API
- [new] Handover Protocol APIs
- [new] add 5 new tagged templates
- [deps] upgrade default graph api version to
v2.10
- [new] LINE Group/Room Member API
- [new] Add optional parameters to telegram api #47.
- [new] Implement get methods
getUserProfilePhotos
getFile
getChat
getChatAdministrators
getChatMembersCount
getChatMember
- [new] Implement updating methods
editMessageText
editMessageCaption
editMessageReplyMarkup
deleteMessage
- [new]
forwardMessage
method
- [deps] Update
lerna
tov2.0.0
.
- [new] Support send open graph template with
MessengerClient.sendOpenGraphTemplate
.
- [new] First release.
- [new] Add
engines
inpackage.json
#38. - [new] Setup test coverage report using
codecov
.
- [fix] Fix wrong checking rules in
sendQuickReplies
methods.
- [fix]
retrieveMessageContent
should returnPromise<Buffer>
.
- [new] First release.
- [docs] rewrite new docs for Messenger & LINE
- [breaking] APIs now return detail data and not just an
axios
response. - [breaking] rename
factory
toconnect
- [new] support use specified graph api version
- [new] support menu locale
- [new] support greeting locale
- [breaking] rename
inputDisabled
tocomposerInputDisabled
- [new] support more
reply
methods andmulticast
methods