Skip to main content

Bottender 1.1: Multi-Channel Routing, Better Slack APIs Support in Chat, View, Block Kit

· 2 min read
C. T. Lin

In Bottender v1.1, we made two remarkable improvements in:

Multi-Channel Routing

In Bottender v1.0, we first introduced the idea of Routing to help bot developers organize the path of bot actions.

When we come to Bottender v1.1, we are glad to announce Multi-Channel Routing, which enable bot developers to have a dedicated path control cross multiple chat channels.

const {
router,
messenger,
line,
slack,
telegram,
viber,
} = require('bottender/router');

async function MessengerAction(context) {
/* ... */
}
async function LineAction(context) {
/* ... */
}
async function SlackAction(context) {
/* ... */
}
async function TelegramAction(context) {
/* ... */
}
async function ViberAction(context) {
/* ... */
}

function App() {
return router([
messenger(MessengerAction),
line(LineAction),
slack(SlackAction),
telegram(TelegramAction),
viber(ViberAction),
]);
}

More Events for Routing

Besides, Bottender v1.1 adds chat channel specific events for Routing, which allows you to write better modular code in your product codebase.

For example, you can use the same action to update your customer database while a bot user follows/unfollows your bot either on Messenger, LINE or Viber.

const { router, payload, line, telegram } = require('bottender/router');

async function Follow(context) {
console.log(`insert ${context.session.user.id} into database`);
await context.sendText('Welcome to my bot!');
}

async function Unfollow(context) {
console.log(`delete ${context.session.user.id} from database`);
}

function App() {
return router([
payload('GET_STARTED', Follow),
line.follow(Follow),
line.unfollow(Unfollow),
line.join(Follow),
line.leave(Unfollow),
viber.subscribed(Follow),
viber.unsubscribed(Unfollow),
]);
}

Note: Please refer to v1.1.0 Change Log to see the whole list of support events for Routing.

Better Slack APIs Support in Chat, View, Block Kits

Since we have observed the increasing needs of Slack Bots, Bottender 1.1 now supports Slack Chat and View APIs. Slack bot developers, can use Slack Native APIs on Bottender without adaptions. Check out our new doc, Sending Slack Messages for more info.

context.chat.postMessage(/* ... */);
context.chat.postEphemeral(/* ... */);
context.chat.update(/* ... */);
context.chat.delete(/* ... */);
context.chat.meMessage(/* ... */);
context.chat.getPermalink(/* ... */);
context.chat.scheduleMessage(/* ... */);
context.chat.deleteScheduledMessage(/* ... */);
context.chat.scheduledMessages.list(/* ... */);

Plus, we also improved Block Kit and Modal support. Thanks to static type-checking, you can have a pleasant experience when building block kits UIs. For more info, please see our new doc, Slack Block Kit.

context.views.open(/* ... */);
context.views.publish(/* ... */);
context.views.push(/* ... */);
context.views.update(/* ... */);