bottender
Advanced tools
Changelog
1.5.4 / 2021-10-11
[deprecated] add deprecated warning to the following methods:
context.useAccessToken
context.replyButtonTemplate
context.push
context.pushText
context.pushImage
context.pushVideo
context.pushAudio
context.pushLocation
context.pushSticker
context.pushImagemap
context.pushFlex
context.pushTemplate
context.pushButtonTemplate
context.pushButtonsTemplate
context.pushConfirmTemplate
context.pushCarouselTemplate
context.pushImageCarouselTemplate
context.send
context.sendImage
context.sendVideo
context.sendAudio
context.sendLocation
context.sendSticker
context.sendImagemap
context.sendFlex
context.sendTemplate
context.sendButtonTemplate
context.sendButtonsTemplate
context.sendConfirmTemplate
context.sendCarouselTemplate
context.sendImageCarouselTemplate
Changelog
1.5.1 / 2021-09-14
// bottender.config.js
module.exports = {
channels: {
mychannel: {
enabled: true,
path: '/webhooks/mychannel',
connector: new MyConnector(/* ... */),
},
},
};
messaging-apis
(#806):const {
// clients
MessengerClient,
LineClient,
TelegramClient,
SlackOAuthClient,
ViberClient,
TwilioClient,
// factories
Messenger,
Line,
} = require('bottender');
onRequest
option (#773):// bottender.config.js
function onRequest(body, requestContext) {
console.log({
body,
requestContext,
});
}
module.exports = {
channels: {
messenger: {
// ...
onRequest,
},
whatsapp: {
// ...
onRequest,
},
line: {
// ...
onRequest,
},
telegram: {
// ...
onRequest,
},
slack: {
// ...
onRequest,
},
viber: {
// ...
onRequest,
},
},
};
id
to RequestContext
(#774)connector.preprocess
(#771)messaging-apis
to v1.0.0await context.getUserPersistentMenu();
// [
// {
// locale: 'default',
// composerInputDisabled: false,
// callToActions: [
// {
// type: 'postback',
// title: 'Restart Conversation',
// payload: 'RESTART',
// },
// {
// type: 'web_url',
// title: 'Powered by ALOHA.AI, Yoctol',
// url: 'https://www.yoctol.com/',
// },
// ],
// },
// ]
await context.setUserPersistentMenu([
{
locale: 'default',
composerInputDisabled: false,
callToActions: [
{
type: 'postback',
title: 'Restart Conversation',
payload: 'RESTART',
},
{
type: 'web_url',
title: 'Powered by ALOHA.AI, Yoctol',
url: 'https://www.yoctol.com/',
},
],
},
]);
await context.deleteUserPersistentMenu();
getConfig
(#770):// bottender.config.js
module.exports = {
channels: {
line: {
enabled: true,
path: '/webhooks/line/:channelId',
async getConfig({ params }) {
console.log(params.channelId);
// ...get the config from the API, database or wherever you like when every time receiving a new event
return {
accessToken,
channelSecret,
};
},
},
},
};
emojis
on LINE text message event (#793):if (context.event.isMessage) {
context.event.message.emojis;
// [
// {
// index: 14,
// length: 6,
// productId: '5ac1bfd5040ab15980c9b435',
// emojiId: '001',
// },
// ]
}
LineContext.getMembersCount
method (#824):await context.getMembersCount();
// 10
TelegramEvent.isPollAnswer
and TelegramEvent.pollAnswer
(#745):if (context.event.isPollAnswer) {
console.log(context.event.pollAnswer);
}
pollAnswer
to telegram routes:const { router, telegram } = require('bottender/router');
async function HandlePollAnswer(context) {
// ...
}
function App() {
return router([telegram.pollAnswer(HandlePollAnswer)]);
}
TelegramContext.answerCallbackQuery
(#750):await context.answerCallbackQuery({
url: 'https://example.com/',
});
*
(#758):const { router, slack } = require('bottender/router');
async function HandleAllEvent(context) {
// ...
}
function App() {
return router([slack.event('*', HandleAllEvent)]);
}
context.views.open
in slack home tab (#809)@google-cloud/dialogflow
v4FacebookConnector
to experiment using same connector for Messenger and Facebook.// bottender.config.js
const { FacebookConnector } = require('@bottender/facebook');
module.exports = {
channels: {
facebook: {
enabled: true,
path: '/webhooks/facebook',
connector: new FacebookConnector({
// The top level access token should be provided for the batch requests.
accessToken: process.env.FACEBOOK_ACCESS_TOKEN,
appSecret: process.env.FACEBOOK_APP_SECRET,
verifyToken: process.env.FACEBOOK_VERIFY_TOKEN,
origin: process.env.FACEBOOK_ORIGIN,
async mapPageToAccessToken(pageId) {
console.log(pageId);
return accessToken;
},
}),
onRequest: onFacebookRequest,
},
},
};
Changelog
1.4.10 / 2020-07-24
slack.event
(#842)