Digital Developer Conference on Cloud Native Security: Register for free and choose your sessions. June 24, 25, & July 1, 2020 Learn more

Integrate your COVID-19 crisis communication chatbot with Slack

In times of crisis, chatbots can help people quickly find the answers that they need to critical questions. In the case of a pandemic like COVID-19, people might be searching for information about the disease’s progression or where to get tested. In this tutorial, I show you how to integrate a crisis communication chatbot with Slack to make it faster for users to get answers to their COVID-related questions.

This tutorial gives you step-by-step instructions for how you can get your COVID Crisis Communication Assistant up and running with Slack.

The following figure shows you the result.

Slack integration GIF

Learning objectives

In this tutorial, you will:

  • Learn how to build a Slack application
  • Integrate your Slack app with Watson Assistant
  • Build a Call for Code COVID Crisis Communications Slack-enabled Chatbot solution

Prerequisites

Estimated time

It should take you approximately 15 minutes to complete the tutorial after you finish the prerequisites.

Architecture diagram

The following diagram shows the workflow for a Slack chatbot that answers questions about COVID-19.

Crisis Comms Architecture diagram

  1. The user invokes a COVID-19 Slack integration chatbot app and asks a question.
  2. The Slack app calls Watson Assistant service hosted in IBM Cloud.
  3. Watson Assistant uses natural language understanding and machine learning to extract entities and intents of the user question.
  4. The COVID-19 FAQ is sourced from trusted CDC data.
  5. Watson Assistant invokes an OpenWhisk open source-powered IBM Cloud Function.
  6. IBM Cloud Function calls Watson Discovery service running in IBM Cloud.
  7. Watson Discovery scans news articles and responds with relevant articles.
  8. Watson Assistant invokes an OpenWhisk open source-powered IBM Cloud Function.
  9. IBM Cloud Function calls the COVID-19 API to get statistics.
  10. Watson Assistant replies to the Slack app.
  11. The Slack app displays the chat answer to the user.

Steps

After you have the Slack Workspace and your Watson Assistant chatbot up and running, you can integrate Slack with your chatbot.

  1. Go to your COVID-19 Crisis Communications Assistant, and click Add Integration.

    Add integration button in Watson Assistant

  2. In the Watson Assistant UI, scroll down to the section for “Third-party integration”, and select Slack.

    Add integration to Slack

  3. First, you must create a Slack App. Click Create New App, name your application, and point to a Slack development workspace. You can learn more about creating slack apps.

    Create a Slack app

  4. On the Slack app Settings page, go to the Basic Information tab and find the App Credentials section. Copy your verification token from that section.

    Copy App Credentials

  5. Paste the verification token from step 4 into the appropriate area of Step 2 on the Watson Assistant Slack integration page.

    Paste App Credentials

    An optional step here is to add an application icon and application name in the Display information section of the Basic Information tab.

    Paste App Credentials

  6. Navigate to the OAuth & Permissions tab. In the Bot Token Scopes section, click Add an Oauth Scope, and then select the following scopes: app_mentions:read, chat:write, im:history, im:read, and im:write.

    Paste App Credentials

  7. On the OAuth & Permissions tab, click Install App to Workspace, and then click Allow. You should be redirected back to the OAuth & Permissions page.

    Paste App Credentials

    Note: Make sure that you copy your Bot User OAuth access token (starts with xoxb) to both the OAuth access token and the Bot user OAuth access token fields in Step 2 > Section 3 on the Watson Assistant Slack integration page.

    Paste App Credentials

  8. On the Slack app settings page, go to the Event Subscriptions tab. Click On for the Enable Events toggle. Go to Step 3 of the Watson Assistant Slack Integration page, and click Generate Request URL. Paste the requested URL on the Slack app settings page, and verify it on the Enable Events page.

    Paste App Credentials

  9. On the Event Subscriptions tab, find the Subscribe to Bot Events section. Click Add Bot User Event, and then select the event types that you want to subscribe to. You must select at least one of the following types:

    • message.im: Listens for message events that are posted in a direct message channel
    • app_mention: Listens for only message events that mention your app or bot

      Paste App Credentials

      Save your changes.

  10. On the App Home tab, select Edit, and enter a display name and default username for your virtual assistant. Click Save. Enable the Always Show My Bot as Online toggle.

    Paste App Credentials

  11. On the Watson Assistant Slack Integration page, click Save Changes.

  12. Log in to your Slack workspace, and click Browse App. Find the app that you just created and add it to the workspace.

    Paste App Credentials

  13. Test your application by asking questions based on Intents and Entities in your Dialog tree. If you receive answers back, you have successfully integrated your COVID-19 Crisis Communication Assistant. Congratulations!

Summary

Now that you know how to quickly provision a chatbot and connect it to Slack, use your new-found knowledge to create your own solution for dealing with a crisis like COVID-19 and join the Call for Code COVID-19 Challenge.

Pooja Mistry