Releases: Yoctol/bottender
Releases · Yoctol/bottender
1.0.0 / 2019-12-05
- The whole codebase has been fully rewritten with TypeScript.
- The repository becomes a lerna monorepo.
- [new] A brand-new project creator -
create-bottender-app
. You can use following command to create your new bot:
npx create-bottender-app my-app
- [new] Implement new runner and
bottender start
cli. It findsindex.js
entry andbottender.config.js
config file then executes accordingly:
bottender start
To enable console mode:
bottender start --console
- [new] Add new development mode via
bottender dev
cli:
bottender dev
bottender dev --console
The bot server will be restarted after changing the files.
- [new] Add several recommended ways to organize chatbot dialogs and features:
Action:
async function SayHi(context) {
await context.sendText('hi');
}
Pass Props to Action:
const { withProps } = require('bottender');
async function SayHi(context, { name }) {
await context.sendText(`hi! ${name}.`);
}
async function App() {
return withProps(SayHi, { name: 'John' });
}
Router:
const { router, text } = require('bottender/router');
async function SayHi(context) {
await context.sendText('Hi!');
}
async function SayHello(context) {
await context.sendText('Hello!');
}
async function App() {
return router([
text('hi', SayHi), // return SayHi when receiving hi text message
text('hello', SayHello), // return SayHello when receiving hello text message
]);
}
Chain:
const { chain } = require('bottender');
function RuleBased(context, props) {
if (context.event.text === 'hi') {
// discontinue and return SayHi
return SayHi;
}
// continue to next
return props.next;
}
function MachineLearningBased(context, props) {
/* ...skip */
}
function HumanAgent(context, props) {
/* ...skip */
}
function App() {
return chain([
// will execute in following order
RuleBased,
MachineLearningBased,
HumanAgent,
]);
}
- [new] Add
_error.js
entry support for error handling:
// _error.js
module.exports = async function HandleError(context, props) {
await context.sendText(
'There are some unexpected errors happened. Please try again later, sorry for the inconvenience.'
);
console.error(props.error);
if (process.env.NODE_ENV === 'production') {
// send your error to the error tracker, for example: Sentry
}
if (process.env.NODE_ENV === 'development') {
await context.sendText(props.error.stack);
}
};
- [new] Add better custom server support
- [breaking]
middleware
and Handlers has been moved to@bottender/handlers
package. You can install it from registry:
npm install @bottender/handlers
// or using yarn:
yarn add @bottender/handlers
And import them like this:
const {
middleware,
Handler,
MessengerHandler,
LineHandler,
SlackHandler,
TelegramHandler,
ViberHandler,
} = require('@bottender/handlers');
- [breaking] transform all context method parameters to camelcase:
Messenger -
context.sendGenericTemplate([
{
title: "Welcome to Peter's Hats",
imageUrl: 'https://petersfancybrownhats.com/company_image.png',
subtitle: "We've got the right hat for everyone.",
defaultAction: {
type: 'web_url',
url: 'https://peterssendreceiveapp.ngrok.io/view?item=103',
messengerExtensions: true,
webviewHeightRatio: 'tall',
fallbackUrl: 'https://peterssendreceiveapp.ngrok.io/',
},
buttons: [
{
type: 'postback',
title: 'Start Chatting',
payload: 'DEVELOPER_DEFINED_PAYLOAD',
},
],
},
]);
Slack -
context.postMessage({
blocks: [
{
type: 'section',
text: {
type: 'plain_text',
text: 'You updated the modal!',
},
},
{
type: 'image',
imageUrl: 'https://media.giphy.com/media/SVZGEcYt7brkFUyU90/giphy.gif',
altText: 'Yay! The modal was updated',
},
],
});
Telegram -
context.sendMessage('hi', {
disableWebPagePreview: true,
disableNotification: true,
});
Viber -
context.sendFile({
media: 'http://www.images.com/file.doc',
size: 10000,
fileName: 'name_of_file.doc',
});
- [breaking] transform all event attributes to camelcase:
context.event.rawEvent; // all keys is camelcase in this object
-
[breaking] rename
skipProfile
toskipLegacyProfile
, and set to true by default -
[breaking] unify requestContext (#541)
-
[deps] update
messaging-apis
to v1 -
[examples] Rewrite all examples for Bottender v1
-
[docs] A brand-new website with new docs - https://bottender.js.org?new
messenger
- [new] add
pageId
config to automatically add subscribe app inbottender messenger webhook set
. - [removed]
get-started
,greeting
,persistent-menu
,whitelisted-domains
cli subcommands has been removed. Useprofile
instead:
bottender messenger profile get
bottender messenger profile set
bottender messenger profile delete
- [removed] Remove deprecated
context.sendAirlineFlightUpdateTemplate()
.
line
- [new] Implement
context.getMessageContent()
. You can use it to get received media content:
async function App(context) {
if (context.event.isImage || context.event.isVideo || context.event.isAudio) {
const buffer = await context.getMessageContent();
}
}
- [new] LineBot: Set
sendMethod
toreply
andshouldBatch
totrue
by default. - [removed] legacy
menu
cli subcommand has been removed.
slack
- [new] add block kits support:
context.postMessage({
blocks: [
{
type: 'section',
text: {
type: 'plain_text',
text: 'You updated the modal!',
},
},
{
type: 'image',
imageUrl: 'https://media.giphy.com/media/SVZGEcYt7brkFUyU90/giphy.gif',
altText: 'Yay! The modal was updated',
},
],
});
- [fix] use
token
in payload when received a JSON string payload.
telegram
- [new] implement
context.sendAnimation()
:
context.sendAnimation('xxx.mp4');
- [new] implement
context.sendPoll()
const options = ['a', 'b'];
context.sendPoll(question, options);
- [breaking] add messageId to args for all function need messageId:
context.editMessageText('<MESSAGE_ID>', text);
context.editMessageCaption('<MESSAGE_ID>', caption);
context.editMessageReplyMarkup('<MESSAGE_ID>', replyMarkup);
context.editMessageLiveLocation('<MESSAGE_ID>', location);
context.stopMessageLiveLocation('<MESSAGE_ID>');
0.15.17 / 2019-02-01
line
- [new] add member join/leave event to LineEvent
event.isMemberJoined;
event.memberJoined;
event.isMemberLeft;
event.memberLeft;
0.15.16 / 2019-01-29
- [deps] upgrade messaging-api-messenger to 0.7.16
0.15.15 / 2018-12-06
messenger
- [new] Add
page.id
to Messenger sessions:
session.page.id;
line
- [new] Add
skipProfile
toLinekBot
andLinekConnector
. - [new] Add
destination
toLineEvent
.
slack
- [new] Add
skipProfile
toSlackBot
andSlackConnector
.
telegram
- [fix] Add missing cli alias
-w
for--webhook
.
0.15.14 / 2018-11-14
messenger
- [new] provide useful information when setting webhook
0.15.13 / 2018-11-12
messenger
- [new] Add
context.usePersona
:
context.usePersona('<PERSONA_ID>');
await context.sendText('Hello');
await context.sendText('World');
0.15.12 / 2018-11-09
0.15.12
messenger
- [new] Add
skipProfile
option toMessengerBot
andMessengerConnector
to skip auto updating user profile:
const bot = new MessengerBot({
accessToken: ACCESS_TOKEN,
appSecret: APP_SECRET,
skipProfile: true,
});
0.15.11 / 2018-11-07
0.15.11 / 2018-11-07
messenger
- [new] Add
skipAppSecretProof
option toMessengerBot
andMessengerConnector
:
const bot = new MessengerBot({
accessToken: ACCESS_TOKEN,
appSecret: APP_SECRET,
skipAppSecretProof: true,
});
0.15.10 / 2018-11-02
- [new] platform bots: add
origin
option for testing purpose:
new MessengerBot({
// ...
origin: 'https://mydummytestserver.com',
});
new LineBot({
// ...
origin: 'https://mydummytestserver.com',
});
new SlackBot({
// ...
origin: 'https://mydummytestserver.com',
});
new ViberBot({
// ...
origin: 'https://mydummytestserver.com',
});
new TelegramBot({
// ...
origin: 'https://mydummytestserver.com',
});
messenger
- [fix] update Messenger profile_pic check logic
- [fix] fix persona cli error messages
0.15.9 / 2018-10-26
messenger
- [new] Add CLI commands for Messenger persona API:
List all personas:
$ bottender messenger persona list
Create a new persona with name and profile picture url:
$ bottender messenger persona create --name <PERSONA_NAME> --pic <PROFILE_IMAGE_URL>
Get persona by persona ID:
$ bottender messenger persona get --id <PERSONA_ID>
Delete persona by persona ID:
$ bottender messenger persona delete --id <PERSONA_ID>