Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

In times of crisis, chatbots can help people quickly find answers they need to critical questions. In the case of a pandemic like COVID-19, people might be trying to find basic information about testing, symptoms, community response, and other resources.

This tutorial shows you how to create a crisis communication chatbot using IBM® Watson™ Assistant and how to add webhooks to Watson Assistant to query for dynamic data using Watson Discovery and COVID-19 APIs.

Learning objectives

In this tutorial, you will:

  • Provision an instance of Watson Assistant
  • Add a dialog skill to your Watson Assistant instance
  • Connect your Watson Assistant with Watson Discovery
  • Create Cloud Functions
  • Integrate data sources via a Watson Assistant webhook


Register for an IBM Cloud account.

Estimated time

This tutorial takes about 40 minutes to complete.



Create your chatbot by setting up a Watson Assistant instance

We show you how to create a chatbot using Watson Assistant, a tool that enables you to build conversational interfaces into any application, device, or channel.

  1. In the IBM Cloud catalog, navigate to the Services and provision an instance of Watson Assistant.

    Watson Assistant Catalog

  2. Launch the Watson Assistant service.

  3. Click Create assistant and follow these detailed instructions for how to create an assistant.

    Watson Assistant Photo2

  4. Name the Watson Assistant instance COVID Crisis Communication.

    Watson Assistant Photo3

  5. Click Add dialog skill to the assistant. Follow the documentation if you have questions.

    Watson Assistant Photo4

  1. Click Import Skill > Choose JSON file and import the data/skill-CDC-COVID-FAQ.json file.

    Watson Assistant Photo5

  2. Go back to All Assistants page. From the action menu ( ), open Settings.

    Watson Assistant Photo6

  3. On the Settings tab, click API Details on the left and make a note of the Assistant ID and API Key for future use.

    Watson Assistant Photo7

  4. Go back to the All Assistants page and click on the Skills link.

    Click the Skills link

  5. On the Skill page, click on the action menu ( ⋮ ) and open View API Details.

    Click the Skills link

  6. On the Skill Details page, make note of the Skill ID for future use.

    Click the Skills link

  7. Go back to your dialog skill and click on the Preview Link button on the side to get a link to test and verify your assistant.

    Watson Assistant Photo9

  8. Ask the Watson Assistant chatbot some questions about COVID-19.

    Watson Assistant Photo10

Integrate your chatbot with data sources

Now that you've created your Watson Assistant-enabled chatbot, you need to connect it to a data source. The following section shows you how to do that by adding webhooks to Watson Assistant that query for dynamic data.

Our crisis communication chatbot uses three different data sources:

Defining webhooks

First, let's look at what webhooks do. A webhook is a mechanism that allows you to call out to an external program based on something happening in your program. When used in a dialog skill, a webhook is triggered when the assistant processes a node that has a webhook enabled. The webhook collects data that you specify or that you collect from the user during the conversation and saves in context variables.

It sends the data as part of a HTTP POST request to the URL that you specify as part of your webhook definition. The URL that receives the webhook is the listener. It performs a predefined action using the information that you pass to it as specified in the webhook definition, and can optionally return a response.

Make use of Watson Discovery to get news information

  1. From your IBM Cloud account, go to Watson Discovery.

    Discover Service

  2. Create a new lite service by clicking Create.

    Create Discover Service

  3. Make note of the API key and the URL. You need that in the next steps.


  4. Open the Watson Discovery NEWS service, which is a prepopulated discovery dataset updated and maintained by the Watson Discovery team.

    Watson Discovery NEWS

  5. From the top right corner, open the API tab. Make note of the Collection ID and Environment ID.

    NEWS Api info

Create Cloud Functions

  1. In the IBM Cloud catalog, go to IBM Cloud Functions.

  2. Click Start Creating.


  3. Select Create Action.


  4. Name your action. For the Runtime dropdown, select Node.js 10.


  5. Replace the code with data/covid-webhook.js


  6. Our code has two main parts. We decide whether to call the COVID-19 API or Watson Discovery based on a parameter sent on the function call. If a query param of type=api is set, you call the COVID-19 api on the summary endpoint.

    It returns the data in the following format:

      Countries: [
          Country: "",
          Slug: "",
          NewConfirmed: 0,
          TotalConfirmed: 0,
          NewDeaths: 0,
          TotalDeaths: 0,
          NewRecovered: 0,
          TotalRecovered: 0
          Country: " Azerbaijan",
          Slug: "-azerbaijan",
          NewConfirmed: 0,
          TotalConfirmed: 0,
          NewDeaths: 0,
          TotalDeaths: 0,
          NewRecovered: 0,
          TotalRecovered: 0
  7. If you want to make a call to the Discovery service, you need to set some parameters that let you call the IAM-enabled service. On the left, click on the Parameters tab. Add the following parameters:

    • api_key(Discovery API key)
    • url (URL to your Discovery service instance)
    • collection_id
    • env_id


  8. Enable the action as a web action. To do so, select the Endpoints tab on the left. Click the checkbox beside Enable as Web Action.


  9. Make note of the HTTP URL. You will use this as the webhook for your assistant. You will have to add .json in the end of this URL to make it work as a webhook.

    http endpoint

Integrate data sources via a Watson Assistant webhook

For detailed instructions on how to integrate data sources via a webhook, check out our documentation: Making Programmatic Calls from Watson Assistant.

Here are the specific steps to add a webhook to your COVID-19 chatbot.

  1. Bring up the COVID-19 assistant you created earlier. Find it in your IBM Cloud account under Services > IBM Watson Assistant. Open the dialog by clicking the CDC COVID FAQ Dialog.

    View Watson Assistant

  2. Click on Options on the left.


  3. Under Options > Webhooks, in the URL text box, paste the URL from the Cloud Funciton step. Make sure to add a .json at the end of the URL.


  4. Select Dialog on the left navigation.


  5. Open up any dialog node you want to add a webhook call for.

  6. After selecting the node, click Customize.


  7. Enable your webhooks by moving the toggle button to On in the Webhooks section. Click Save.


  8. Add any parameter your webhook needs. These will be sent as query parameters.

    webhook parameters

  9. Test that your webhook integration is working by going to the Try It tab and initiating a dialog that calls the webhook.

    webhook test

You can easily use webhooks to give your Watson Assistant access to many external APIs and databases.

Next steps

Now that you know how to create a COVID-19 chatbot and connect it to Watson Discovery and the COVID-19 API, there are a few different integration paths you can take. The following tutorials show you how to integrate this chatbot with Slack, with a simple web application, or with a Node-RED dashboard.

Workshop Resources

Code Content Authors


No description, website, or topics provided.



No releases published


No packages published