Oracle Cloud Infrastructure Documentation

Slack

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

  1. Go to Slack's Your Apps page.

  2. Click Create an App.

  3. Fill in the App Name and Development Slack Workspace fields and click Create App.

    Once the app is created, its Basic Information page appears.

  4. 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.

  5. If your skill or digital assistant works with attachments, navigate to the OAuth and Permissions tab and add the files:write:user permission.
    Note

    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 3: Create a Bot User for the Slack App

  1. In the left navigation of the web console for your Slack app, within the Features section, select Bot Users.

  2. Click Add a Bot User.

  3. Enter a display name and default username.

  4. Set the Always Show My Bot as Online switch to ON.

  5. Click Add Bot User.

  6. Click Save Changes.

Step 4: Add the App to the Workspace

  1. In the left navigation of the web console for your Slack app, within the Settings section, select Install App.

  2. Click Install App to Your Workspace.

  3. Click Authorize.

Once you have completed this step, you should see the app in your Slack workspace in a section of the left navigation labeled Apps.



Step 5: Create a Channel in Digital Assistant

  1. In Digital Assistant, click Channels in the left menu and then choose Users.

  2. Click + Channel to open the Create Channel dialog.

  3. Give your channel a name.

  4. Choose Slack as the channel type.

  5. 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.

  6. Click Create.

  7. 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.

  8. Click icon for the Route To ... dropdown and select the digital assistant or skill that you want to associate with the channel.

  9. In the Route To dropdown, select the digital assistant or skill that you want to associate with the channel.

  10. Switch on the Channel Enabled control.

Step 6: Configure the Webhook URL in the Slack App

  1. In the left navigation of the web console for your Slack app, select Interactive Components.

  2. Turn the Interactivity switch ON.

  3. 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 .

  4. Save the changes.

  5. In the left navigation, select OAuth & Permissions.

  6. In the Redirect URLs field, click Add New Redirect URL.

  7. Paste the webhook URL, append /authorize, and click Add, and then Save URLs.

  8. In the left navigation, select Event Subscriptions.

  9. Set the Enable Events switch to ON.

  10. 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.

  11. In the Subscribe to Bots Events section of the page, click Add Bot Event and add the following events:

    • im_created
    • message.im
  12. If prompted with a banner regarding a change in your permission scopes, click to reinstall the app as suggested.
  13. Click Save Changes.

Step 7: Add the Slack Button

  1. In the left navigation of the web console for your Slack app, select Manage Distribution.

  2. Click the Add to Slack button.

  3. 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.

  1. Open the Slack workspace where you have installed the app.

  2. In the left navigation bar, select the app that is associated with your digital assistant.

  3. In the Message field, enter text to start communicating with the digital assistant.

Supported Capabilities

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)
  • links
  • postbacks
  • custom properties
  • carousel components (but rendered vertically instead of horizontally)
  • list components

Message Constraints

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
showImageInAccessory
  • true
  • false
Response items of type cards. Set to true to show the card image at the right as a small image instead of a larger centered image.
showDatePicker
  • true
  • false
  • a nested object with show, initialDate and placeholder properties
Response items of type text. Set to true to show a date picker next to the text message. See also https://api.slack.com/reference/messaging/block-elements#datepicker.
renderActionsAsDropDown
  • true
  • false
  • nested object with the following properties, each of which takes a Boolean value:
    • postbackActions
    • cardPostbackActions
    • globalPostbackActions
Response items By default (if you don't set this property), actions are displayed:
  • as buttons if there are five or fewer actions
  • in a dropdown list if there are six or more

If you want to display actions in a dropdown list, no matter how many actions there are, set this property to true.

If you want to display actions as buttons, no matter how many actions there are, set this propeorty to false.

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:

  • postbackActions - postback actions defined at the response item level, including text, attachment, and card list items.
  • cardPostbackActions - postback actions defined for an individual card
  • globalPostbackActions - postback actions defined for global 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.

dropDownPlaceholder
  • placeholder text
  • nested object with the following properties, each of which takes a string value:
    • postbackActions
    • cardPostbackActions
    • globalPostbackActions
Response items Use this property to specify the placeholder text shown within the dropdown list.
fields
  • an array of strings
Response items of type text. 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 postbackActions, cardPostbackActions, and globalPostbackActions.

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.