Skip to Content

Deploy an SAP Conversational AI Chatbot on Slack

Deploy an SAP Conversational AI chatbot on Slack and add it to a Slack channel to respond to user messages.
You will learn
  • How to deploy a chatbot to Slack
  • How to add app to channel
  • How to talk directly with the app without a channel
thecodesterDaniel WroblewskiMarch 8, 2021
Created by
thecodester
July 28, 2020
Contributors
thecodester

Prerequisites

  • Step 1
    1. Go to the Connect tab.

      Connect tab
    2. Under Third party integrations, click Slack.

      Open Slack

    This will open a set of instructions for integrating with Slack, and a place to store tokens for connecting to Slack. But you can follow the instructions in this tutorial instead.

  • Step 2
    1. Go to https://api.slack.com/apps.

    2. Click Create App.

      Create app
    3. Enter the following:

      Field Name Value
      App Name Animal Facts
      Development Slack Workspace Select your workspace
    4. Click Create App.

      Your app is created.

      New app
  • Step 3
    1. In the Slack app page, in the Basic Information tab, scroll down to the App Credentials section.

      Link text e.g., Destination screen
    2. Copy the Client ID and Client Secret from the Slack app page to the Slack panel in the Connect tab in SAP Conversational AI:

      Link text e.g., Destination screen
    3. Click Get Tokens.

      This will create OAuth and Event URLs.

      Credentials results

      Hold onto to these URLs because you will need to enter them within your app on Slack.

  • Step 4
    1. In the Slack app page, go to OAuth & Permissions.

    2. Click Add New Redirect URL.

      OAuth

      Enter the OAuth URL from SAP Conversational AI, click Add, then click Save URLs.

  • Step 5
    1. In the Slack app page, go to Interactivity & Shortcuts.

      Interactivity
    2. Turn interactivity On.

    3. Enter the events URL from SAP Conversational AI into the Request URL.

      Add request URL

      Click Save Changes.

  • Step 6
    1. In the Slack app page, go to OAuth & Permissions, and scroll down to Scopes.

      Scopes
    2. Click Add an OAuth Scope and add the following scopes:

      Scope
      app_mentions:read
      channels:history
      chat:write
      im:history
      users:read

      These give the app permission, for example, to read mentions entered into Slack or to post messages.

    3. Scroll to the top and click Install App to Workspace, and then click Allow to give your app the needed permissions.

  • Step 7
    1. In the Slack app page, go to Event Subscriptions.

      Events
    2. Turn events On.

    3. Enter the events URL from SAP Conversational AI into Request URL.

    4. Under Subscribe to bot events, and subscribe to events.

      Click Add Bot User Event and add the following events:

      Event
      app_mention
      message.im
      message.channels
    5. Click Save Changes.

  • Step 8

    In the Slack panel in the Connect tab in SAP Conversational AI, go to step 8 (Add my bot to a slack channel).

    Authorize

    Click the link.

    Allow

    Allow the permissions for the app by clicking Allow. You should get a success message.

    Allow OK
  • Step 9
    1. In Slack, scroll down to Apps, click + and add the app to your Slack.

      Add app
    2. Search for Animal Facts and select the app.

      Find app

      After selecting, the Animal Facts is added to your apps in the Slack navigation panel. It’s message screen is also displayed.

      App added
    3. Enter the word cat, and the bot responds by making an API call to get a fact about cats, and displays in the Messages panel.

      App test

      Cats can’t produce fat!?

  • Step 10

    You can also add the app to a channel, so when someone specifically sends a message to the app, the bot processes the message and returns the appropriate response.

    1. Go to the channel and open the Details panel on the right.

      I created a private channel called Test.

    2. Click More > Add Apps, find your app, and to the right click Add.

      Add to channel
    3. Now you can speak to the bot via direct message.

      Test app in channel

      Did you know snails are closely related to oysters and clams?

  • Step 11

    What event occurs when "a message is posted to a channel"?

Back to top