Home

Awesome

WARNING: This repository is no longer maintained :warning:

This repository will not be updated. The repository will be kept available in read-only mode.

Create a banking chatbot with FAQ discovery, anger detection and natural language understanding

In this code pattern, we will create a chatbot using Node.js and Watson Assistant. The Assistant flow will detect customer emotions and be enhanced by using Natural Language Understanding to identify location entities. For FAQs, a call to the Discovery service will use passage retrieval to pull answers from a collection of documents.

When the reader has completed this pattern, they will understand how to:

NOTE: This code pattern has been updated to include instructions for accessing Watson services running on IBM Cloud Pak for Data. These updates can be found in the specific instructions for deploying your app locally, or deploying your app to OpenShift on IBM Cloud. The main change required is that your application will need additional credentials to access the IBM Cloud Pak for Data cluster that is hosting the Watson services.

Click here for more information about IBM Cloud Pak for Data.

architecture

Flow

  1. The FAQ documents are added to the Discovery collection.
  2. The user interacts with a chatbot via the app UI.
  3. User input is processed with Natural Language Understanding (NLU). The context is enriched with NLU-detected entities and keywords (e.g., a location).
  4. The input and enriched context is sent to Assistant. Assistant recognizes intent, entities and dialog paths. It responds with a reply and/or action.
  5. Optionally, a requested action is performed by the app. This may include one of the following:
    • Lookup additional information from bank services to append to the reply
    • Use Discovery to reply with an answer from the FAQ documents

Included components

Featured technologies

Steps

  1. Clone the repo
  2. Create Watson services
  3. Customize the Watson Assistant skill
  4. Load Discovery documents
  5. Deploy the application
  6. Use the web app

1. Clone the repo

Clone the watson-banking-chatbot locally. In a terminal, run:

git clone https://github.com/IBM/watson-banking-chatbot

2. Create Watson services

Provision the following services:

NOTE: If you will be using the Deploy to Cloud Foundry on IBM Cloud deployment option, then you can skip these next steps and jump right to the Deploy the Application section. That deployment option automatically creates the services and links them to your application.

The instructions will depend on whether you are provisioning services using IBM Cloud Pak for Data or on IBM Cloud.

Click to expand one:

<details><summary><b>IBM Cloud Pak for Data</b></summary> <p> <i>Use the following instructions for each of the three services.</i> <p> <h5>Install and provision service instances</h5> <p> The services are not available by default. An administrator must install them on the IBM Cloud Pak for Data platform, and you must be given access to the service. To determine whether the service is installed, Click the <b>Services</b> icon (<img class="lazycontent" src="doc/source/images/services_icon.png" alt="services_icon"/>) and check whether the service is enabled. </details> <details><summary><b>IBM Cloud</b></summary> <p> <h5>Create the service instances</h5> <ul> <li>If you do not have an IBM Cloud account, register for a free trial account <a href="https://cloud.ibm.com/login">here</a>.</li> <li>Click <a href="https://cloud.ibm.com/catalog/services/watson-assistant">here</a> to create a <b>Watson Assistant</b> instance.</li> <li>Click <a href="https://cloud.ibm.com/catalog/services/discovery">here</a> to create a <b>Discovery</b> instance.</li> <li>Click <a href="https://cloud.ibm.com/catalog/services/natural-language-understanding">here</a> to create a <b>Natural Language Understanding</b> instance.</li> </ul> </details>

3. Customize the Watson Assistant skill

The following instructions will depend on if you are provisioning Assistant from IBM Cloud or from an IBM Cloud Pak for Data cluster. Choose one:

<details><summary>Provision on IBM Cloud Pak for Data</summary> <p> </p> </details> <details><summary>Provision on IBM Cloud</summary> <p> </p> </details>

To find the Skill ID for Watson Assistant:

To view the Assistant dialog, click on the skill and choose the Dialog tab. Here's a snippet of the dialog:

dialog

4. Load Discovery documents

By default, the application will create a collection named watson-banking-chatbot, but you can configure it to use another collection by setting the run-time environment variables DISCOVERY_COLLECTION_ID and DISCOVERY_ENVIRONMENT_ID.

The following instructions will depend on if you are provisioning Discovery from IBM Cloud or from an IBM Cloud Pak for Data cluster. Choose one:

<details><summary>Provision on IBM Cloud Pak for Data</summary> <p>

NOTE: The Environment Id for Cloud Pak for Data collections is always set to default.

disco_cpd_projectid

</p> </details> <details><summary>Provision on IBM Cloud</summary> <p> </p> </details>

5. Deploy the application

Click on one of the options below for instructions on deploying the Node.js server.

localopenshiftpublic

6. Use the web app

The web app presents a customer service chatbot. Interact with the chatbot by pressing the buttons when prompted or use the Type something box. The chatbot is powered by Watson Assistant with additional information coming from Discovery and Natural Language Understanding.

demo

Troubleshooting

Links

License

This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.

Apache License FAQ