Skip to main content

Slack

Prerequisite

  • A bot created on the KB Dashboard.
  • A Slack account with a created workspace.

Step 1: Create a Slack app

  1. Open YourApps page, and login with your Slack account.

  2. Click Create New App or Create an App if this is your first application.

  3. On the Create an app page, select From scratch.\

  4. On the Name app & choose workspace page, enter the name of your application and select a workspace for your application.

  5. Review and agree to the Slack API terms of service. Then click Create App. Once the application is created, you are directed to Basic Information page.

  6. Move to the App Credentials section of the Basic Information page. Then copy and save the Client ID and Client Secret, and Signing Secret.\

Step 2: Add permissions

  1. In the left panel, select OAuth & Permissions.

  2. On the OAuth & Permissions page, move to the the Scopes section. Click Add an OAuth Scope under the Bot Token Scopes pane to add the following permissions:
    app_mentions:read
    channels:history
    chat:write
    commands
    groups:history
    im:history
    mpim:history
    users:read\

  3. On the OAuth & Permissions page, move to the OAuth Tokens for Your Workspace section, and then click Install Workspace.\

  4. On the pop-up page, review the workspace permissions that the application will access and then click Allow.

  5. Copy and save the Bot User OAuth Token.\

Step 3: Configure your bot

  1. Log in to KB Dashboard.

  2. Select a bot from the Personal page or click Create bot if you don't have one.

  3. On the Playground page of the bot, click Publish.

  4. Find the Slack channel and click Configure.\

  5. Copy and save the OAuth2 Redirect URL, Event Request URL and Slash Request URL for later use.\

  6. Complete the Slack channel configurations as follows:

    ConfigurationsDescription
    TokenThe Bot User OAuth Token of your Slack application. Obtain the Bot User OAuth Token on the OAuth & Permissions page of your Slack application.
    Client IDThe client ID of your Slack application. Obtain it on the Basic Information page of your Slack application.
    Client SecretThe Client Secret of your Slack application. Obtain it on the Basic Information page of your Slack application.
    Signing SecretThe Signing Secret of your Slack application. Obtain it on the Basic Information page of your Slack application.
  7. Click Save.

Step 4: Configure your Slack app

  1. Go back to YourApps page and find your application.

  2. Add redirect URL:

    1. Click OAuth & Permissions.

    2. In the Redirect URLs section, click Add New Redirect URL. Then enter the redirect URL copied earlier and click Add.

    3. Click Save URLs.\

  3. Configure the bot events that your application subscribes to. Slack will notify your bot of the subscribed user activities.

    1. Click Event Subscriptions and toggle Enable Events to on.

    2. Enter the previously copied event request URL in the Request URL field.\

    3. Expand the Subscribe to bot events section, click Add Bot User Event to add the events that your bot will use. For example, app_mention and message.im.

    4. Click Save Changes.\

  4. Configure slash commands to allow users to send messages to your bot using slash commands:

    1. Click Slash Commands. Then click Create New Command on the Slash Command page.\

    2. Configure the command configurations and then click Save.

      Command: Set the command to /new_thread to use this command to clear chat history with the bot.
      Request URL: The request URL is the Slash Request URL copied from the Slack channel configurations in KB Dashboard.\

  5. Enable the user to send a message to your bot:

    1. Click App Home.\

    2. In the Show Tabs section, select the Allow users to send Slash commands and messages from the messages tab checkbox under the MessagesTab option.\

  6. (Optional) If you want to distribute this bot to other workspaces, you need to complete the following operations:

    1. Click Manage Distribution, and expand Remove Hard Coded Information pane.\

    2. Select the I’ve reviewed and removed any hard-coded information checkbox after you read the information above.

    3. Click Activate Public Distribution.\

    4. Copy the generated sharable URL in the Share Your App with Any Workspace section.\

    5. Add &state={app_id} at the end of the copied sharable URL. The app_id is the ID of your slack application.
      https://slack.com/oauth/v2/authorize?client_id=4878914704467.6568343811620&scope=app_mentions:read,channels:history,chat:write,commands,groups:history,im:history,mpim:history,users:read&user_scope=&state={app_id}

Step 5: Publish and test your bot

  1. Go back to the KB Dashboard.

  2. Find your bot and click Publish.

  3. Enter a change log and select the Slack channel. Then click Publish.

  4. Click Authorize

  5. Select workspace

  6. Click the Open in Slack link to chat with your bot in Slack.