Slack

The Druid ChatBot Portal allows you to create the bot once and deploy it in Slack.

Prerequisites

  • You built and published a Druid chat bot.
  • You have a Slack account.
Note:  Slack channel integration is not available in Druid on premise deployments; you cannot activate the channel.

This section describes how to integrate a Druid chat bot with Slack.

Step 1: Create a Slack application for your bot

  1. In your browser, sign in Slack.
  2. Navigate to Your Apps panel.
  3. If this is the first Slack app you build the Your Apps page will look like this:

  4. Click Create New App or Create an App (if you have no other apps). A pop-up appears.
  5. Choose how you want to configure your app’s scopes and settings.
  6. We choose to configure from scratch. If you choose to configure from an app manifest, skip step 5.

    A new pop-up appears.

  7. In the App Name field, enter the name of your Slack application.
  8. From the Development Slack Team drop-down, select the name of your development team. If you are not already a member of a Development Slack Team, create or join one.
  9. Click Create App.
  10. Go to Your apps and click on the Slack app you created for the Druid chatbot integration.
  11. Scroll-down to the App details section and get the following details: Client ID, Client Secret and Signing Secret. Copy / paste them in a document, you will need them at Step 2.

If your app needs special scopes, follow step 2.

Step 2. (Optional) Add special scopes and generate Bot User OAuth Token

A Slack app's capabilities and permissions are governed by the scopes it requests.

If your Slack app needs special scopes which require Bot OAuth Token (which will be used in Druid in Slack channel configuration), for example to transmit Microsoft files, you need to define the specific bot token scopes and generate OAuth Token for Your Workspace.

To do so, follow these steps:

  1. In Slack, select the app and on the Features menu, click OAuth & Permissions.
  2. Scroll down to the Scopes section and under Bot Token Scopes, click the Add an OAuth scope button.
  3. Select the desired scope(s) (e.g., files:read).

  4.   Scroll up to section "OAuth Tokens for Your Workspace" and click the Install to Workspace button.
  5. Allow the app to access your workspace.
  6. Copy the Bot User OAuth Token that was automatically filled in.
Important!  If you add new Bot Token Scopes to the app, you scroll up to section OAuth Tokens for Your Workspace and click Reinstall to Workspace in order for the new scopes to have effect. The Bot User OAuth Token remains unchanged.

Step 3. Activate the Slack Channel

  1. In the Druid ChatBot Portal go to your bot settings. Click the Channels tab, then click Slack. The Slack Channel Info section expands.
  2. Enter the Client Id, Client Secret and Signing Secret of your Slack app, the one copied at Step 1.
  3. (Optional!) If you want your bot to perform actions that require Bot OAuth Token, in the Bot User OAuth Token field, enter the value copied from Slack app.
  4. Click the Publish button. The channel activation might take up to 1 minute. When the channel activation completes, the OAuth & Permissions Redirect URL, Event Subscription Request URL and Interactivity Request URL fields are automatically filled in. Copy the three values, you will need them at Step 3.

After the channel’s activation, the following fields are available in DRUID:

  • [[ChatUser]].ChannelId = "slack"
  • [[ChatUser]].UserId - Stores an unique identifier of the Slack user account.

Step 4. Configure your Slack app

Add a new redirect URL

  1. In Slack, navigate to Your Apps panel and click on your app.
  2. On the left menu, click OAuth & Permissions and scroll down to section Redirect URLs.
  3. Click Add a new Redirect URL.
  4. In the box, enter the OAuth & Permissions Redirect URL copied from the Druid ChatBot Portal (at Step 2) and click Add.
  5. Click Save URLs.

Set up the app interactivity in messages

On the left menu, click Interactivity & Shortcuts and tap on Interactivity.

In the Request URL field, enter the following URL: https://slack.botframework.com/api/Actions. This is the Interactivity Request URL automatically generated in Druid after you published the Slack channel. The value is generic for all bots.

Click Save Changes.

Subscribe to Bot Events

By subscribing to bot events, your app will be notified of user activities at the URL you specify.

Follow these steps to subscribe to six specific bot events:

  1. On the left menu, click Event Subscriptions and tap on Enable Events.
  2. In Request URL, enter the Event Subscription Request URL copied from the Druid ChatBot Portal (at Step 2).
  3. In Subscribe to Bot Events, click Add Bot User Event.
  4. Search for and select these six event types:
    • member_joined_channel
    • member_left_channel
    • message.channels
    • message.groups
    • message.im
    • message.mpim

At the bottom of the screen, click Save Changes.

As you add events in Slack, it lists the scopes you need to request. The scopes you need will depend on the events you subscribe to and how you intend to respond to them. For Slack supported scopes, refer to Scopes and permissions. See also Understanding OAuth scopes for Bots.

Important!  If you set up special scopes on the app which use Bot User Oauth Token, after you subscribe to events, the following message appears at the top of the page: "You’ve changed the permission scopes your app uses. Please reinstall your app for these changes to take effect (and if your app is listed in the Slack App Directory, you’ll need to resubmit it as well)". For Bot events subscriptions to take effect, in that message click the reinstall your app link. Allow the Slack app to access your workspace.

Allow users to send Slash commands and messages from the messages tab

From the Features menu, click App Home and scroll down to the Show Tabs section.

Tap on Messages Tab and tick Allow users to send Slash commands and messages from the messages tab.

Step 5: Add app to Slack workspace

From the left menu, click Basic Information and in the Install your app section, click the Reinstall to Workspace button.

Click Allow to grant the Slack app access to your Slack workspace.

Note:  Based on your workspace configuration, an additional confirmation of the Druid chatbot Slack integration might be needed. To do so, follow these steps:
  1. In Druid Portal, go to your bot, click the Channels tab, then click the Slack channel icon.
  2. Sign in to your Slack workspace.

  3. Check what your Slack bot will be able to view and do, then click Allow.

The app appears in Slack on the left menu under Apps. You can now successfully use the Druid chatbot in the Slack messaging platform.

Note:  In DRUID 7.5 and higher, when a user initiates a conversation with the bot, the Welcome flow will be automatically triggered. Regardless of the user's subscription status to the bot channel, the welcome message will be promptly sent to the user, ensuring a seamless and engaging interaction experience.

Talk to the bot in Slack channels

Note:  This feature is available in DRUID 7.11 onwards.

To talk to the bot in a Slack channel, you need to add the bot to the channel:

  1. Select the Slack Channel.
  2. Click the drop-down arrow next to the channel name to open the channel settings.
  3. Click the Integrations tab.
  4. Click Add an app.
  5. Select the bot from the list to add it to the channel.

To interact with the bot, start your message with @<bot name> to ask the bot something. This will create a thread within the channel where you can continue the conversation.

Each thread has a unique conversation ID in DRUID that stores the thread conversation in the Conversation History.