- [new] Added support for broadcast API:
await client.broadcast([
{
type: 'text',
text: 'Hello, world1',
},
]);
- [new] Added
.getBotInfo()
:
await client.getBotInfo();
// {
// "userId": "Ub9952f8...",
// "basicId": "@216ru...",
// "displayName": "Example name",
// "pictureUrl": "https://obs.line-apps.com/...",
// "chatMode": "chat",
// "markAsReadMode": "manual"
// }
- [new] Added support for webhook APIs:
await client.getWebhookEndpointInfo();
// {
// "endpoint": "https://example.com/test",
// "active": true
// }
await client.setWebhookEndpointUrl('https://www.example.com/callback');
await client.testWebhookEndpoint();
// {
// "success": true,
// "timestamp": "2020-09-30T05:38:20.031Z",
// "statusCode": 200,
// "reason": "OK",
// "detail": "200"
// }
- fix: add
type: 'keyboard'
to theKeyboard
type
- fix: type TemplateElement should allow optional attributes
- deps: bump axios.
- fix: add the missing
warning
package.
- feat: add persona support to typing_on and typing_off
- chore: remove namespace and export types from module instead #627
The whole project has been rewritten with TypeScript and all APIs now accept camelcase keys instead of snakecase keys.
Please checkout the new API document.
- [fix] WechatClient: apply throwErrorIfAny to getAccessToken #502
- [fix] handle arraybuffer correctly in
retrieveMessageContent
- [fix] avoid printing undefined outgoing request body in
onRequest
.
- [deps] update packages
- [deps] use babel 7 instead of babel 6 internally
- [breaking] remove deprecated
sendAirlineFlightUpdateTemplate
- [breaking] remove deprecated createXxxx methods on
MessengerBatch
- [breaking] remove deprecated insight methods
getActiveThreads
andgetReportedConversationsByReportType
- [new] update default graph api version to
v4
- [new] add
getThreadOwner
inMessengerBatch
- [deprecated] add warning for
createListTemplate
andcreateOpenGraphTemplate
- [deprecated] add waning to broadcast methods
createMessageCreative
,sendBroadcastMessage
,cancelBroadcast
,getBroadcast
,startReachEstimation
,getReachEstimate
,getBroadcastMessagesSent
andgenerateMessengerCode
. - [fix] add missing
options
to messenger batch functions 047db83 - [fix] parse batch response body
- [breaking] refine rich menu getter functions error handling when getting 404
- [breaking] return null when no user found (#445)
- [new] add
options.fields
togetUserProfile
:
client
.getUserProfile(USER_ID, {
fields: [
`id`,
`name`,
`first_name`,
`last_name`,
`profile_pic`,
`locale`,
`timezone`,
`gender`,
],
})
.then((user) => {
console.log(user);
// {
// id: '5566'
// first_name: 'Johnathan',
// last_name: 'Jackson',
// profile_pic: 'https://example.com/pic.png',
// locale: 'en_US',
// timezone: 8,
// gender: 'male',
// }
});
- [new] implement
client.getSubscriptions
:
client.getSubscriptions({
access_token: APP_ACCESS_TOKEN,
});
// or
client.getSubscriptions({
access_token: `${APP_ID}|${APP_SECRET}`,
});
- [new] implement
client.getPageSubscription
:
client.getPageSubscription({
access_token: APP_ACCESS_TOKEN,
});
// or
client.getPageSubscription({
access_token: `${APP_ID}|${APP_SECRET}`,
});
- [new] implement
client.debugToken
:
client.debugToken().then((pageInfo) => {
console.log(pageInfo);
// {
// app_id: '000000000000000',
// application: 'Social Cafe',
// expires_at: 1352419328,
// is_valid: true,
// issued_at: 1347235328,
// scopes: ['email', 'user_location'],
// user_id: 1207059,
// }
});
- [new] add
client.multicastFlex
:
client.multicastFlex([USER_ID], 'this is a flex', {
type: 'bubble',
header: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Header text',
},
],
},
hero: {
type: 'image',
url: 'https://example.com/flex/images/image.jpg',
},
body: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Body text',
},
],
},
footer: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Footer text',
},
],
},
styles: {
comment: 'See the example of a bubble style object',
},
});
- [new] support
video
for imagemap:
const res = await client.replyImagemap(REPLY_TOKEN, 'this is an imagemap', {
baseUrl: 'https://example.com/bot/images/rm001',
baseSize: {
height: 1040,
width: 1040,
},
video: {
originalContentUrl: 'https://example.com/video.mp4',
previewImageUrl: 'https://example.com/video_preview.jpg',
area: {
x: 0,
y: 0,
width: 1040,
height: 585,
},
externalLink: {
linkUri: 'https://example.com/see_more.html',
label: 'See More',
},
},
actions: [
{
type: 'uri',
linkUri: 'https://example.com/',
area: {
x: 0,
y: 0,
width: 520,
height: 1040,
},
},
{
type: 'message',
text: 'hello',
area: {
x: 520,
y: 0,
width: 520,
height: 1040,
},
},
],
});
- [new] Add
skipAppSecretProof
option toMessengerClient
:
const client = MessengerClient.connect({
accessToken: ACCESS_TOKEN,
appSecret: APP_SECRET,
skipAppSecretProof: true,
});
- [new] Add
MessengerClient.appSecret
getter:
const client = MessengerClient.connect({
appSecret: 'APP_SECRET',
});
client.appSecret; // 'APP_SECRET'
- [new] Add Line Pay APIs:
const { LinePay } = require('messaging-api-line');
const linePay = LinePay.connect({
channelId: CHANNEL_ID,
channelSecret: CHANNEL_SECRET,
sandbox: true, // default false
});
getPayments(options)
:
linePay
.getPayments({
transactionId: '20140101123123123',
orderId: '1002045572',
})
.then((result) => {
console.log(result);
// [
// {
// transactionId: 1020140728100001997,
// transactionDate: '2014-07-28T09:48:43Z',
// transactionType: 'PARTIAL_REFUND',
// amount: -5,
// productName: '',
// currency: 'USD',
// orderId: '20140101123123123',
// originalTransactionId: 1020140728100001999,
// },
// ]
});
getAuthorizations(options)
:
linePay
.getAuthorizations({
transactionId: '20140101123123123',
orderId: '1002045572',
})
.then((result) => {
console.log(result);
// [
// {
// transactionId: 201612312312333401,
// transactionDate: '2014-07-28T09:48:43Z',
// transactionType: 'PAYMENT',
// payInfo: [
// {
// method: 'BALANCE',
// amount: 10,
// },
// {
// method: 'DISCOUNT',
// amount: 10,
// },
// ],
// productName: 'tes production',
// currency: 'USD',
// orderId: '20140101123123123',
// payStatus: 'AUTHORIZATION',
// authorizationExpireDate: '2014-07-28T09:48:43Z',
// },
// ]
});
reserve(payment)
:
linePay
.reserve({
productName: 'test product',
amount: 10,
currency: 'USD',
orderId: '20140101123456789',
confirmUrl:
'naversearchapp://inappbrowser?url=http%3A%2F%2FtestMall.com%2FcheckResult.nhn%3ForderId%3D20140101123456789',
})
.then((result) => {
console.log(result);
// {
// transactionId: 123123123123,
// paymentUrl: {
// web: 'http://web-pay.line.me/web/wait?transactionReserveId=blahblah',
// app: 'line://pay/payment/blahblah',
// },
// paymentAccessToken: '187568751124',
// }
});
confirm(transactionId, payment)
:
linePay
.confirm(TRANSACTION_ID, {
amount: 1000,
currency: 'TWD',
})
.then((result) => {
console.log(result);
// {
// orderId: 'order_210124213',
// transactionId: 20140101123123123,
// payInfo: [
// {
// method: 'BALANCE',
// amount: 10,
// },
// {
// method: 'DISCOUNT',
// amount: 10,
// },
// ],
// }
});
capture(transactionId, payment)
:
linePay
.capture(TRANSACTION_ID, {
amount: 1000,
currency: 'TWD',
})
.then((result) => {
console.log(result);
// {
// transactionId: 20140101123123123,
// orderId: 'order_210124213',
// payInfo: [
// {
// method: 'BALANCE',
// amount: 10,
// },
// {
// method: 'DISCOUNT',
// amount: 10,
// },
// ],
// }
});
void(transactionId)
:
linePay.void(TRANSACTION_ID);
refund(transactionId, options)
:
linePay.refund(TRANSACTION_ID).then((result) => {
console.log(result);
// {
// refundTransactionId: 123123123123,
// refundTransactionDate: '2014-01-01T06:17:41Z',
// }
});
- [fix] fix LINE buttonsTemplate defaultAction support
- [new] add
.status
property
-
[new] Implement persona apis:
-
createPersona()
:
createPersona({
name: 'John Mathew',
profile_picture_url: 'https://facebook.com/john_image.jpg',
}).then((persona) => {
console.log(persona);
// {
// "id": "<PERSONA_ID>"
// }
});
getPersona(personaId)
:
getPersona(personaId).then((persona) => {
console.log(persona);
// {
// "name": "John Mathew",
// "profile_picture_url": "https://facebook.com/john_image.jpg",
// "id": "<PERSONA_ID>"
// }
});
getPersonas(cursor?: string)
:
getPersonas(cursor).then((personas) => {
console.log(personas);
// {
// "data": [
// {
// "name": "John Mathew",
// "profile_picture_url": "https://facebook.com/john_image.jpg",
// "id": "<PERSONA_ID>"
// },
// {
// "name": "David Mark",
// "profile_picture_url": "https://facebook.com/david_image.jpg",
// "id": "<PERSONA_ID>"
// }
// ],
// "paging": {
// "cursors": {
// "before": "QVFIUlMtR2ZATQlRtVUZALUlloV1",
// "after": "QVFIUkpnMGx0aTNvUjJNVmJUT0Yw"
// }
// }
// }
});
getAllPersonas()
:
getAllPersonas().then((personas) => {
console.log(personas);
// [
// {
// "name": "John Mathew",
// "profile_picture_url": "https://facebook.com/john_image.jpg",
// "id": "<PERSONA_ID>"
// },
// {
// "name": "David Mark",
// "profile_picture_url": "https://facebook.com/david_image.jpg",
// "id": "<PERSONA_ID>"
// }
// ]
});
deletePersona(personaId)
:
deletePersona(personaId);
- [fix]
getAssociatedLabels
: get name field by default and add options for fields.
-
[new] add apis for default rich menu:
-
getDefaultRichMenu()
:
client.getDefaultRichMenu().then((richMenu) => {
console.log(richMenu);
// {
// "richMenuId": "{richMenuId}"
// }
});
setDefaultRichMenu(richMenuId)
:
client.setDefaultRichMenu('{richMenuId}');
deleteDefaultRichMenu()
:
client.deleteDefaultRichMenu();
- [new] add request deubg hook, so now we can use
DEBUG
env variable to enable request debugger:
DEBUG=messaging-api*
- [deps] upgrade all of dependencies and migrate to lerna v3
- [new] use util.inspect.custom instead of Object.inspect
- [fix] add custom token support to appsecret_proof #392
- [new] add custom token support to all
SlackOAuthClient
methods
- [new] support creating AxiosError with Error instance only
- [new] add
quickReply
support:
client.replyText(REPLY_TOKEN, 'Hello!', {
quickReply: {
items: [
{
type: 'action',
action: {
type: 'cameraRoll',
label: 'Send photo',
},
},
{
type: 'action',
action: {
type: 'camera',
label: 'Open camera',
},
},
],
},
});
- [fix] set maxContentLength for Messenger uploadAttachment
- [new] export
Messenger
,MessengerBatch
,MessengerBroadcast
from browser entry
- [new] support LINE Front-end Framework (LIFF):
- [new] support Flex message:
- [new] export
Line
from browser entry, so it can be used in the browser with module bundler:
const { Line } = require('messaging-api-line');
liff.sendMessages([
Line.createText('hello~~~~~~'),
Line.createText('world~~~~~~'),
]);
- [new] Verifying Graph API Calls with
appsecret_proof
If appSecret
is provided, MessengerClient
will enable this feature automatically and include appsecret_proof
in every Graph API requests.
const client = MessengerClient.connect({
accessToken,
appSecret,
});
There are no any visible breaking changes between 2.11 and 3.0, so after this version it uses Graph API 3.0 (https://graph.facebook.com/v3.0/
) as default (#349).
In this version, we bring some fetaures in Messenger Platform 2.4 into messaging-api-messenger
.
- [new] Support scheduling broadcasts
To schedule a broadcast, specify the schedule_time
property when you call the sendBroadcastMessage
API request to send the message.
client
.sendBroadcastMessage(938461089, {
schedule_time: '2018-04-05T20:39:13+00:00',
})
.then((result) => {
console.log(result);
// {
// broadcast_id: '115517705935329',
// }
});
To cancel a scheduled broadcast:
client.cancelBroadcast('115517705935329');
To check on broadcast status.
client.getBroadcast('115517705935329').then((broadcast) => {
console.log(broadcast);
// {
// scheduled_time: '2018-04-05T20:39:13+00:00',
// status: 'SCHEDULED',
// id: "115517705935329"
// }
});
- [new] Support nested predicate in Broadcast API, so you can send broadcast messages with label predicates (and, or, not):
import { MessengerBroadcast } from 'messaging-api-messenger';
const { add, or, not } = MessengerBroadcast;
client.sendBroadcastMessage(938461089, {
targeting: {
labels: and(
'<CUSTOM_LABEL_ID_1>'
or(
'<UNDER_25_CUSTOMERS_LABEL_ID>',
'<OVER_50_CUSTOMERS_LABEL_ID>'
)
),
},
});
- [new] Support getting the thread owner when using Handover Protocol:
client.getThreadOwner().then((threadOwner) => {
console.log(threadOwner);
// {
// app_id: '12345678910'
// }
});
- [new] Support new insights API
getTotalMessagingConnections()
:
client.getTotalMessagingConnections().then((result) => {
console.log(result);
// {
// name: 'page_messages_total_messaging_connections',
// period: 'day',
// values: [
// values: [
// { value: 1000, end_time: '2018-03-12T07:00:00+0000' },
// { value: 1000, end_time: '2018-03-13T07:00:00+0000' },
// ],
// title: 'Messaging connections',
// 'Daily: The number of people who have sent a message to your business, not including people who have blocked or reported your business on Messenger. (This number only includes connections made since October 2016.)',
// id:
// '1386473101668063/insights/page_messages_total_messaging_connections/day',
// }
});
- [new] Support programmatically checking the feature submission status of Page-level Platform features using
getMessagingFeatureReview
:
client.getMessagingFeatureReview().then((data) => {
console.log(data);
// [
// {
// "feature": "subscription_messaging",
// "status": "<pending|rejected|approved|limited>"
// }
// ]
});
- [deprecated]
getOpenConversations()
is deprecated and replaced by newgetTotalMessagingConnections()
See messenger official blog post for more Messenger Platform 2.4 details.
- [changed] use class methods instead of class properties #310
- [fix] handle network error better by fallback to original message #338
- [new] move message creation api into singleton: #255
Messenger.createMessage;
Messenger.createText;
Messenger.createAttachment;
Messenger.createAudio;
Messenger.createImage;
Messenger.createVideo;
Messenger.createFile;
Messenger.createTemplate;
Messenger.createButtonTemplate;
Messenger.createGenericTemplate;
Messenger.createListTemplate;
Messenger.createOpenGraphTemplate;
Messenger.createMediaTemplate;
Messenger.createReceiptTemplate;
Messenger.createAirlineBoardingPassTemplate;
Messenger.createAirlineCheckinTemplate;
Messenger.createAirlineItineraryTemplate;
Messenger.createAirlineUpdateTemplate;
MessengerBatch.sendRequest;
MessengerBatch.sendMessage;
MessengerBatch.sendText;
MessengerBatch.sendAttachment;
MessengerBatch.sendAudio;
MessengerBatch.sendImage;
MessengerBatch.sendVideo;
MessengerBatch.sendFile;
MessengerBatch.sendTemplate;
MessengerBatch.sendButtonTemplate;
MessengerBatch.sendGenericTemplate;
MessengerBatch.sendListTemplate;
MessengerBatch.sendOpenGraphTemplate;
MessengerBatch.sendReceiptTemplate;
MessengerBatch.sendMediaTemplate;
MessengerBatch.sendAirlineBoardingPassTemplate;
MessengerBatch.sendAirlineCheckinTemplate;
MessengerBatch.sendAirlineItineraryTemplate;
MessengerBatch.sendAirlineUpdateTemplate;
MessengerBatch.getUserProfile;
MessengerBatch.sendSenderAction;
MessengerBatch.typingOn;
MessengerBatch.typingOff;
MessengerBatch.markSeen;
MessengerBatch.passThreadControl;
MessengerBatch.passThreadControlToPageInbox;
MessengerBatch.takeThreadControl;
MessengerBatch.requestThreadControl;
MessengerBatch.associateLabel;
MessengerBatch.dissociateLabel;
MessengerBatch.getAssociatedLabels;
- [new] add 2 new metrix to messenger insights: #304
getOpenConversations(options)
:
client.getOpenConversations().then((result) => {
console.log(result);
// {
// name: 'page_messages_open_conversations_unique',
// period: 'day',
// values: [
// { end_time: '2018-03-12T07:00:00+0000' },
// { end_time: '2018-03-13T07:00:00+0000' },
// ],
// title: 'Daily unique open conversations count',
// description:
// 'Daily: The total number of open conversations between your Page and people in Messenger. This metric excludes blocked conversations.',
// id:
// '1386473101668063/insights/page_messages_open_conversations_unique/day',
// }
});
getNewConversations(options)
:
client.getNewConversations().then((result) => {
console.log(result);
// {
// name: 'page_messages_new_conversations_unique',
// period: 'day',
// values: [
// { value: 1, end_time: '2018-03-12T07:00:00+0000' },
// { value: 0, end_time: '2018-03-13T07:00:00+0000' },
// ],
// title: 'Daily unique new conversations count',
// description:
// 'Daily: The number of messaging conversations on Facebook Messenger that began with people who had never messaged with your business before.',
// id:
// '1386473101668063/insights/page_messages_new_conversations_unique/day',
// }
});
- [breaking] rename
Messenger
toMessengerBatch
: #255 - [breaking] rename
getDailyUniqueActiveThreadCounts
togetActiveThreads
#307 - [breaking] remove deprecated MessengerClient method -
sendQuickReplies
- [breaking] Messenger Insights API: resolve
obj
instead of[obj]
: #302
Affected APIs:
- getActiveThreads
- getBlockedConversations
- getReportedConversations
- getReportedConversationsByReportType
Before:
client.getBlockedConversations().then((counts) => {
console.log(counts);
// [
// {
// "name": "page_messages_blocked_conversations_unique",
// "period": "day",
// "values": [
// {
// "value": "<VALUE>",
// "end_time": "<UTC_TIMESTAMP>"
// },
// {
// "value": "<VALUE>",
// "end_time": "<UTC_TIMESTAMP>"
// }
// ]
// }
// ]
});
After:
client.getBlockedConversations().then((counts) => {
console.log(counts);
// {
// "name": "page_messages_blocked_conversations_unique",
// "period": "day",
// "values": [
// {
// "value": "<VALUE>",
// "end_time": "<UTC_TIMESTAMP>"
// },
// {
// "value": "<VALUE>",
// "end_time": "<UTC_TIMESTAMP>"
// }
// ]
// }
});
- [breaking] removed deprecated
getDailyUniqueConversationCounts
insights API #304 - [changed] rename
AirlineFlightUpdateTemplate
toAirlineUpdateTemplate
to match typename #329
AirlineFlightUpdateTemplate -> AirlineUpdateTemplate
- [fix] fix sending attachment with buffer (allow filename) #335
- [fix] fix getReportedConversationsByReportType and improve docs #297
- [fix] avoid pass undefined value to messenger in batch api #326
- [new] support LINE issue link token for account linking: #332
client.issueLinkToken(USER_ID).then((result) => {
console.log(result);
// {
// linkToken: 'NMZTNuVrPTqlr2IF8Bnymkb7rXfYv5EY',
// }
});
- [new] allow pass object as image, audio, video, sticker args: #309
client.pushImage(RECIPIENT_ID, {
originalContentUrl: 'https://example.com/original.jpg',
previewImageUrl: 'https://example.com/preview.jpg',
});
client.pushVideo(RECIPIENT_ID, {
originalContentUrl: 'https://example.com/original.mp4',
previewImageUrl: 'https://example.com/preview.jpg',
});
client.pushAudio(RECIPIENT_ID, {
originalContentUrl: 'https://example.com/original.m4a',
duration: 240000,
});
client.pushSticker(RECIPIENT_ID, {
packageId: '1',
stickerId: '1',
});
-
[new] support LINE ButtonsTemplate alias to match typename
buttons
:- client.sendButtonsTemplate == client.sendButtonTemplate
- client.replyButtonsTemplate == client.replyButtonTemplate
- client.pushButtonsTemplate == client.pushButtonTemplate
- client.multicastButtonsTemplate == client.multicastButtonTemplate
-
[breaking] remove deprecated method
isValidSignature
inLineClient
- [breaking] Throw error when
ok
isfalse
in Telegram: #268
{
ok: false,
result: { /* ... */ }
}
Now throws Telegram API
error.
- [breaking] telegram api return result instead of
{ ok: true, result }
: #313
Before:
{
ok: true,
result: {
key: val
}
}
After:
{
key: val,
}
Make it easier to access result and consist with other platforms.
- [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