messaging-api-messenger
Advanced tools
Changelog
0.7.16 / 2019-01-29
options.fields
to getUserProfile
: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',
// }
});
client.getSubscriptions
:client.getSubscriptions({
access_token: APP_ACCESS_TOKEN,
});
// or
client.getSubscriptions({
access_token: `${APP_ID}|${APP_SECRET}`,
});
client.getPageSubscription
:client.getPageSubscription({
access_token: APP_ACCESS_TOKEN,
});
// or
client.getPageSubscription({
access_token: `${APP_ID}|${APP_SECRET}`,
});
Changelog
0.7.15 / 2018-11-12
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,
// }
});
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',
},
});
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,
},
},
],
});
Changelog
0.7.14 / 2018-11-07
skipAppSecretProof
option to MessengerClient
:const client = MessengerClient.connect({
accessToken: ACCESS_TOKEN,
appSecret: APP_SECRET,
skipAppSecretProof: true,
});
Changelog
0.7.13 / 2018-10-30
MessengerClient.appSecret
getter:const client = MessengerClient.connect({
appSecret: 'APP_SECRET',
});
client.appSecret; // 'APP_SECRET'
Changelog
0.7.11 / 2018-10-17
.status
propertyChangelog
0.7.10 / 2018-10-09
[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);
getAssociatedLabels
: get name field by default and add options for fields.Changelog
0.7.8 / 2018-09-19
DEBUG
env variable to enable request debugger:DEBUG=messaging-api*
Changelog
0.7.6 / 2018-08-23
SlackOAuthClient
methodsChangelog
0.7.5 / 2018-08-04
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',
},
},
],
},
});