Conversational Slack Bots 101

Following up on the VentureBeat article, here is a short tutorial on how to create a Slack bot at API.AI.

Millions of Slack users chat with each other and bots every day. Bots are the best, because you can integrate them with lots of useful services and apps. They provide you with information, deliver notifications, and offer a myriad of other handy features. You can simply talk to the bot naturally and it understands the context to respond intelligently. And now with the API.AI-Slack integration, you can train your bots, so they can have real conversations with users to perform their duties better.

Design conversations

Start with creating an agent at API.AI. The agent will be the conversational part of your bot’s brain.

When you come up with an idea of what conversations your bot should be able to carry with your users, start training the API.AI agent. It’s as simple as providing just a few examples of how people may phrase their requests and define what type of data you want to extract from such requests.

Connect to a web service

After your bot learns how to understand people, it needs to start responding. You can connect your bot to a web service via a webhook. This will allow you to pass information from a matched request into a web service and get a result from it. This way you can implement connections to data services, business logic, etc.


In the API.AI developer account, you can find the test console, where you can try how well your agent understands you already. If your request is recognized, you’ll see which intent was used to process it and what information was extracted.

Train it more right away by adding more examples in existing scenarios or create new ones.

Test some more. Do you love it? Move to the next step.

Create a Slack bot

To enable Slack Integration, go to your agent’s settings, select ‘Integrations’ from the horizontal menu, and turn Slack integration on. Alternatively, you can select ‘Slack integration’ from the left side menu.

To define the way people can interact with your bot, tick the relevant checkboxes in the ‘Message Types’ section.

  • Direct message. The bot will receive a direct message from a user.
  • Direct mention. The bot will answer when mentioned at the beginning of a message.
  • Mention. The bot will answer when mentioned in any part of a message.
  • Ambient. The bot will monitor any message in a channel.

Don’t forget to save the settings.

To connect the bot to your Slack account, click ‘Test in Slack’ and then sign in with your team account. Let your team know about your bot. The more conversations it gets, the more data you’ll have to train it. And the smarter your bot will become as a result.

When you’re ready to publish your bot to the community, go to the Slack Apps webpage where you can find all the necessary documentation. Click on ‘My apps’ from the top menu, and then on ‘Create a new application’.

You’ll be asked to fill in the app name, descriptions of the app and a Redirect URI. Use the Redirect URI from your API.AI agent’s Slack Integration settings.

After clicking on the ‘Create application’ button, you’ll see your Client ID and Client Secret. Go to your API.AI agent’s Slack integration settings and fill in the Client ID and Client Secret fields with the values from your Slack app’s settings. Then click ‘Go online’.

Go back to your app settings on the Slack webpage, scroll down to the ‘Bot User’ section, and configure a new Bot user for your app by clicking on ‘Add a bot to this app’ button.

Scroll up to the top of the page and click the ‘Add to Slack’ link. The Slack button page will open.

Scroll down to the ‘Add to Slack button’ section. Uncheck ‘incoming webhook’ and tick the ‘bot’ checkbox, which generates the HTML code for the ‘Add to Slack’ button that can be added to your website.

To launch the bot for your Slack team, just click the button ‘Add to Slack’ above the generated code.

If you intend to make your bot accessible to other teams, you’ll need to place the ‘Add to Slack’ button on your website, so that anyone can launch your bot by clicking it.

Note: If you want to have your bot published in the Slack App Directory, you have to register as a developer and go through the Slack approval process.

Check out our API.AI for Slack video!