This guide will give you some basic concepts of developing a Slack bot. For more detail, check official docs.


  • Slack App with following features:

    • Event Subscriptions
    • Permissions
    • Bots

First, create an app on Slack API site. Then setup its features:

  • Event Subscriptions:

    • Subscribe to message.channels event, so your bot can receive message events.
    • Setup webhook URL after your bot server is up.
  • Permissions:

    • Add bot scope to your app
    • Copy Bot User OAuth Access Token (access token) for later use.
  • Bots:

    • Setup your bot's display name.

Build Your First Slack Bot

Check out your app's access token Slack API then fill them in slack-hello-world example:

const { SlackBot } = require('bottender');

const bot = new SlackBot({
  accessToken: '__FILL_YOUR_TOKEN_HERE__',

Then run your server and try it out by invite the Bot User to a channel and talk to him/her/it!


There are many types of events your bot may receive from Slack, but it's up to you whether to subscribe to each of them. In Bottender, you can access them via context.event. For more information, check SlackEvent Reference and official docs.

For the message related events, Bottender supports some helpers:

  • isMessage
  • isChannelsMessage
  • isGroupsMessage
  • isImMessage
  • isMpimMessage
  • isText
  • message
  • text

For example:

bot.onEvent(async context => {
  if (context.event.isChannelsMessage) {
    await context.sendText('Hello, this is a channels message!');
  } else if (context.event.isGroupsMessage) {
    await context.sendText('Hello, this is a groups message!');
  } else if (context.event.isText && context.event.text === 'How are you?') {
    await context.sendText('I am fine.');
  } else {
    await context.sendText('I do not understand.');

Slack Specific

Message Format

In Bottender, you can use function context.sendText() to send messages. You can format messages with Slack message formatting. For more information, check SlackContext Reference and official docs.


You can invite your bot account into a channel. By doing so, the events will create channel sessions. Send method context.sendText() will send to the channel. You can still get the sender's profile with context.session.user.

You can access the channel and team members in and

Get User Info from ID

If you want to get user info from user ID, you can find it with info. For example, getting a user's name can be:

function getNameFromId(id, session) {
  return => === id).name;