DEV Community

Cover image for Creating Chat Bot in Slack
Nikhil Devarasetty
Nikhil Devarasetty

Posted on

Creating Chat Bot in Slack

What is bot? (from slack)

A bot is the same as a regular app: it can access the same range of APIs and do all of the magical things that a Slack App can do.

But when you build a bot for your Slack App, you're giving that app a face, a name, and a personality, and encouraging users to talk to it.

Your bot can send DMs, it can be mentioned by users, it can post messages or upload files, and it can be invited to channels - or kicked out.

Creating a bot:

  • Create a slack app choosing the workspace.
  • Then navigate to the created app and add bot permissions under OAuth & permissions, it will automatically create a bot user.
  • Hurray! your slack bot is created.

Users need to install the app to use it's bot features

Installing app:

  • App can be distributed publicly for users to install it from slack app directory.
  • App can also be installed through slack OAuth flow

Bot features:

1. Webhooks:

We can create webhook urls for a channel or user of the team and can use the webook url to post messages to selected target.

2. Slash commands:

With slash commands we provide utilities to interact with bot.
Ex: /get-users-list, and provided redirect url which handles the commands request and sends payload.

3. Events:

We can subscribe to the events provided by slack and upon triggering we can handle it with provided redirect url.
Ex: team-join, user_change...

To enable user interactivity with bot enable Allow users to send Slash commands and messages from the messages tab under App Home

With slack block kit we can create interactive forms, surveys, send formatted messages, and more. Explore slack block-kit

Top comments (0)