Here's what happens when you use Slack as a channel for your digital assistant (or standalone skill):
- Slack hosts your digital assistant through the intermediary of a Slack app.
- Users chat with your digital assistant through the Slack app in the Slack user interface.
See Building Slack apps for Slack's developer documentation for Slack apps.
Here are the steps for creating a Slack channel for Digital Assistant.
Step 1: Get a Slack Workspace
To make your digital assistant (or standalone bot) available in Slack, you need to have a Slack workspace available to you where you have the permissions necessary to create a Slack app.
If you don't have such a workspace available to you, you can create your own. See Slack's Create a new workspace page.
Step 2: Create a Slack App
Go to Slack's Your Apps page.
Click Create an App.
Fill in the App Name and Development Slack Workspace fields and click Create App.
Once the app is created, its Basic Information page appears.
Scroll down to the App Credentials section of the page and note the values of the Client ID, Client Secret, and Signing Secret.
You'll need these credentials when you set up the channel in Digital Assistant.
Step 3: Add OAuth Scopes for the Slack App
In the left navigation of the web console for your Slack app, within the Features section, select OAuth and Permissions.
Under Bot Token Scopes, click Add an OAuth Scope and select app_mentions:read.
Click Add an OAuth Scope again and select im:read.
Scroll down to User Token Scopes, click the Add an OAuth Scope button that appears under that heading, and select im:history.
- If your skill or digital assistant works with attachments,click the Add an OAuth Scope button that appears under that heading, and select files:write.
Currently, because the files:write:user permission only applies to the workspace owner, the workspace owner is the only person who can successfully upload attachments to the skill.
Step 4: Add the App to the Workspace
In the left navigation of the web console for your Slack app, within the Settings section, select Install App.
Click Install App to Your Workspace.
A page will appear showing what the app will be able to do.
Once you have completed this step, you should be able to see the app in your Slack workspace, either by selecting Apps in the left navigation, or by scrolling down to Recent Apps in the left navigation.
Step 5: Create a Channel in Digital Assistant
In Digital Assistant, click Channels in the left menu and then choose Users.
Click + Channel to open the Create Channel dialog.
Give your channel a name.
Choose Slack as the channel type.
Fill in the the values for Client ID, Client Secret, and Signing Secret that you obtained when you created your Slack app.
You can retrieve these values from the Settings page of your Slack app.
In the Channels page, copy the WebHook URL and paste it somewhere convenient on your system. You’ll need this to finish setting up the Slack app.
Click and select the digital assistant or skill that you want to associate with the channel.
In the Route To dropdown, select the digital assistant or skill that you want to associate with the channel.
- Switch on the Channel Enabled control.
Step 6: Configure the Webhook URL in the Slack App
In the left navigation of the web console for your Slack app, select Interactive Components.
Turn the Interactivity switch ON.
In both the Request URL and Options Load URL fields, paste the webhook URL that was generated when you created the channel in Digital Assistant .
Save the changes.
In the left navigation, select OAuth & Permissions.
In the Redirect URLs field, click Add New Redirect URL.
Paste the webhook URL, append
/authorize, and click Add, and then Save URLs.
In the left navigation, select Event Subscriptions.
Set the Enable Events switch to ON.
In the Request URL field, paste the webhook URL.
After you enter the URL, a green Verified label should appear next to the Request URL label.
In the Subscribe to Bots Events section of the page, click Add Bot Event and add the following events:
- If prompted with a banner regarding a change in your permission scopes, click to reinstall the app as suggested.
Click Save Changes.
Step 7: Add the Slack Button
In the left navigation of the web console for your Slack app, select Manage Distribution.
Go to api.slack.com/docs/slack-button and scroll down to the Add the Slack button section.
In the dropdown list in that section, make sure that the Slack app you are working with is selected.
Select the bot option.
Make sure the incoming webhook option is not checked.
Click the Add to Slack button.
On the next page, click Authorize.
You should be redirected to a "success page" that shows that your credentials have been verified and you can access the workspace and app.
Step 8: Test Your Bot in Slack
With the Slack channel and messaging configuration complete, you can test your bot (digital assistant or skill) in Slack.
Open the Slack workspace where you have installed the app.
In the left navigation bar, select the app that is associated with your digital assistant.
- In the Message field, enter text to start communicating with the digital assistant.
Slack channels in Digital Assistant support the following capabilities:
- text (both sending and receiving)
- images (both sending and receiving)
- files (partial support for sending, full support for receiving)
- emojis (partial support for sending, full support for receiving)
- custom properties
- carousel components (but rendered vertically instead of horizontally)
- list components
Slack channels in Digital Assistant have the following message constraints:
- Text Messages
- Maximum length of text message: 3000 characters. If the length exceeds 3000, the text is split over multiple messages.
- Maximum length of text action label: 30 characters
- Types of text actions allowed: Postback, URL
- Horizontal Cards
- Supported?: No. Card is layout is converted to vertical.
- Vertical Cards
- Maximum length of title: 3000 characters
- Maximum length of description: 3000 characters
- Maximum length of card action label: 30 characters
- Maximum number of cards: 100
- Types of card actions allowed: Postback, URL
- Types of card list actions allowed: Postback, URL
- Attachment Messages
- Supported?: Yes
- Types of Actions Allowed: Postback, URL
- Action Buttons
- Maximum length of global action label: 30 characters
- Types of global actions allowed: Postback, URL
Slack Channel Extensions
For Slack channels, you can extend the functionality of
System.CommonResponse components with capabilities that are specific to Slack.
You access the extensions by using the
channelCustomProperties element in the
System.CommonResponse component and setting the appropriate properties. The code has the following format:
... channelCustomProperties: - channel: "slack" properties: PROPERTY_NAME: "PROPERTY_VALUE" ...
Here are the available custom properties for Slack channels:
|Name||Allowed Values||Applies To...||Description|
||Response items of type
||Response items of type
||Response items||By default (if you don't set this property), actions are displayed:
If you want to display actions in a dropdown list, no matter how many actions there are, set this property to
If you want to display actions as buttons, no matter how many actions there are, set this propeorty to
If you want to have different behavior for different types of postback actions, you can use a nested object with Boolean values for each of the following type of actions:
To render actions in a dropdown menu, Slack uses a select menu with static items. See https://api.slack.com/reference/messaging/block-elements#static-select.
||Response items||Use this property to specify the placeholder text shown within the dropdown list.|
||Response items of type
||The string values specified in this property are displayed as fields in a two-column layout (desktop) or a single column layout (mobile).|
Here's an example of using the
renderActionsAsDropDown custom property.
responseItems: - type: "text" text: "Here is a list of the UI features of the Common Response Component:" actions: - ... channelCustomProperties: - channel: "slack" properties: renderActionsAsDropDown: false
And here's an example of using the
renderActionsAsDropDown custom property with nested properties for
responseItems: - type: "text" text: "Here is a list of the UI features of the Common Response Component:" actions: - ... channelCustomProperties: - channel: "slack" properties: renderActionsAsDropDown: postbackActions: false cardPostbackActions: true globalPostbackActions: true
For more general information on
channelCustomProperties, see Channel-Specific Extensions.