Sunday, May 21, 2017

Azure Bot Service: Basic Slack Integration

If you have been following along so far we have created a basic bot and then we have fooled around with prompt dialog as it renders in different channels.  The goal of this post is to chat a bit about basic slack integration.

Bots use the concept of bot connectors to connect with various channels.  A channel can be considered a "line of communication" with a particular client.  Configuration for the channel is done via the bot developer portal.  Here is what my dev portal looks like:

As you can see, there are several options that are built in.  One of the above is a "direct line" which could probably be used to connect with many more channels via a generic interface.  We will probably talk about that one in an upcoming post.

There are a couple of different steps when enabling slack integration.  The official documentation for this process can be found here.

Step 1: Create a Slack Application

Slack already has a built-in concept of an "application" that essentially creates a user and funnels messages to and from that user to the backend that you configure.  Visit this link to create an app.

Step 2: Add the "bot feature" to your Slack Application

Once you have your app created, you need to add the "bot feature" to this application.  This is found under the basic information tab and then the add features and functionality section.

When you create a bot, you are simply asked for the default username for the bot.  Pick anything you'd like!

Step 3: Set the Redirect URI

 This step is required in order to assist with authentication between the slack bot and the Azure bot service.  This option can be found under the OAuth & Permissions tab and the Redirect URLs.

It should look something like this:

Step 4: Configure Channel

Here, you need to basically pass in the OAuth information from slack to the bot dev portal channel configuration. 

The client id, client secret information, and verification token can be found on the Basic Information tab under the App Credentials 

From the Microsoft bot framework portal, click the slack icon to add slack to the list of channels.  Then click "edit" to be taken to the submit your credentials step of the slack integration.

Enter in the required information, and confirm the slack credentials.  After that, mark the checkbox at the bottom that will enable the bot on slack.

Step 5: Install App to your team and test

After you have enabled the bot, you can now distribute it to your team.  Do this in the slack app configuration in the Basic Information tab and the Install your app to your team section.  Once this is done, you should be able to message and interact with your app in your slack channel.

At this point, you should now be chatting with your bot via Slack.  Pretty cool stuff!

No comments:

Post a Comment