Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1 changelog #555

Merged
merged 1 commit into from
Dec 5, 2019
Merged

v1 changelog #555

merged 1 commit into from
Dec 5, 2019

Conversation

chentsulin
Copy link
Collaborator

@chentsulin chentsulin commented Dec 2, 2019

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 finds index.js entry and bottender.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.scheduleMessage({
  text: 'Hello world!',
  postAt: '299876400',
});

Telegram -

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',
    },
  ],
});

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

messenger

  • [new] add pageId config to automatically add subscribe app in bottender messenger webhook set.
  • [removed] get-started, greeting, persistent-menu, whitelisted-domains cli subcommands has been removed. Use profile 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 to reply and shouldBatch to true 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>');

@codecov-io
Copy link

codecov-io commented Dec 2, 2019

Codecov Report

Merging #555 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #555   +/-   ##
=======================================
  Coverage   79.89%   79.89%           
=======================================
  Files          89       89           
  Lines        3965     3965           
  Branches      952      963   +11     
=======================================
  Hits         3168     3168           
+ Misses        762      758    -4     
- Partials       35       39    +4
Impacted Files Coverage Δ
packages/create-bottender-app/src/shared/log.ts 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d5d5b3...7c55248. Read the comment docs.

CHANGELOG.md Outdated
Slack -

```js
await context.chat.scheduleMessage({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only this one has await in example, maybe we can remove it to unify with others

@chentsulin chentsulin force-pushed the changelog branch 2 times, most recently from c778331 to 5a3e94a Compare December 5, 2019 06:45
@chentsulin chentsulin marked this pull request as ready for review December 5, 2019 07:28
@chentsulin chentsulin force-pushed the changelog branch 4 times, most recently from 64ce348 to 7f4cae4 Compare December 5, 2019 07:53
@chentsulin chentsulin merged commit 14ff7da into master Dec 5, 2019
@chentsulin chentsulin deleted the changelog branch December 5, 2019 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants