This application demonstrates how the Watson Conversation service can be used to build a simple on-board telco chat application.
- We will learn and understand how to integrate the Conversation, Discovery and Cloudant services.
Following services are used from IBM Cloud:
- Watson Conversation Service
- Cloudant NoSQLDB Database Service
- Watson Discovery Service
See the app demo
For more information about Conversation, see the detailed documentation.
The app interface is designed and trained for chatting with the telco customers. Your questions and commands are run against a small set of sample data trained with intents like these:
view profile
view account
edit email
These intents help the system to understand variations of questions and commands that you might submit.
Example commands that can be executed by the Conversation service are:
view profile
edit emailId
What are the available plans for Vodafone
What are the available plans for Idea
view my account
view my bill
![](/IBMDevConnect/TelcoChatBot/raw/master/readme_images/Telco-Architecture.png)
- The user writes a query about a service to the chatbot
- The orchestrator accepts query, saves the user context & starts a REST call with the Cognitive APIs.
- Depending on the nature of the query (long /Short tail), the answer is provided by either Watson Conversation API or Watson Discovery Services
Ensure that you have a IBM Cloud account
- Select "Deploy to IBM Cloud" icon below.
-
This action deploys 1 application and 2 services. You can view this on your IBM Cloud Dashboard.
-
Log in with your existing IBM Cloud account or Sign up
-
Name your app and select your REGION, ORGANIZATION and SPACE. Then select DEPLOY.
-
The deploy performs two actions:
- deploys the app run time
- creates a Conversation and Cloudant service instances
- connects to the already created Discovery service
-
To see the status of your app, you can click "Delivery Pipeline".
-
The deployment can take some time.
-
Deployment of the app might FAIL. The reason for the failure is that we have to configure the cloudant database.
To configure the cloudant database please follow the below steps:
-
Click on "cloudant-db" from the IBM Cloud Dashboard. In the landing page, click on Launch button.
-
Click on Databases from left hand navigation. Click on "Create Database" from top right corner.
-
Give a name to the database, like telco-users
-
To load demo / sample data to the database, two versions of data are available under resources folder: telco-users-<number>.json and telco-users-cloudant.txt
-
Install couchimport tool to upload data to cloudant using the following commnands:
MAC / Linux:
Open the Terminal and run the following snippet:
sudo npm install -g couchimport
To get the URL, click on the App in Bluemix dashboard --> Runtime --> Environment Variable --> Under Cloudant service, check for the URL
export COUCH_URL="https://username:password@xxx-bluemix.cloudant.com"
export COUCH_DATABASE="telco-users"
cat telco-users-cloudant.txt | couchimport --db telco-users
Windows:
Open Command Prompt and run:
npm install -g couchimport
(Refer https://nodejs.org/download/release/npm/ for npm installers)
To get the URL, click on the App in IBM Cloud dashboard --> Runtime --> Environment Variable --> Under Cloudant service, check for the URL
set COUCH_URL="https://username:password@xxx-bluemix.cloudant.com"
set COUCH_DATABASE="telco-users"
type telco-users-cloudant.txt | couchimport --db telco-users
Note:
-
Install node.js for your OS from https://nodejs.org/
-
To see if Node is installed, type the below on your command line
node -v
To see if Node Package Manager - npm is installed, type the below on your command line
npm -v
- Make sure that the telco-users-cloudant.txt file is under the same folder from where the Terminal/Command prompt commands are issued
To use the app you're creating, you need to add a workspace to your Conversation service. A workspace is a container for all the artifacts that define the behavior of your service (ie: intents, entities and chat flows).
For more information on workspaces, see the full Conversation service documentation.
-
Navigate to the IBM Cloud dashboard, select the Conversation service that you created
-
Go to the Manage menu item and select Launch Tool. This opens a new tab in your browser, where you are prompted to login if you have not done so before. Use your IBM Cloud credentials.
-
Download the exported file that contains the Workspace contents by clicking exported JSON file
- navigate to the resources folder to find
telcobot-conversation-workspace-handson.json
file - click on the "Raw" link which will open a browser
- Select "Save As" and save the file as a json
- navigate to the resources folder to find
-
Select the import icon:
. Browse to (or drag and drop) the JSON file. Choose to import Everything(Intents, Entities, and Dialog). Then select Import to finish importing the workspace.
-
Refresh your browser. A new workspace tile is created in the tool. Select the menu button within the workspace tile, then select View details:
In the Details UI, copy the 36 character UNID ID field. This is the WORKSPACE_ID. Retain this for the following step where we will create an environment variable. This varibale will be the handle for the application to refer to the Conversation Service that we created.
Launch the Watson Discovery tool. Create a new data collection and give the data collection a unique name.
Save the environment_id and collection_id for next step.
Under Add data to this collection use Drag and drop your documents here or browse from computer to seed the content with the four documents in resources/Discovery folder
-
Click on the deployed app from IBM Cloud Dashboard
-
Go to Runtime -> Environment variables section
-
Under "User defined" section at the botton, click on Add button
-
Under Name, enter WORKSPACE_ID (with out quotes) and under Value, copy the workspace id from importing workspace step
-
Click on Add button again and, enter DISCOVERY_USERNAME and under Value, copy the Disocvery service username
-
Click on Add button again and, enter DISCOVERY_PASSWORD and under Value, copy the Disocvery service password
-
Click on Add button again and, enter DISCOVERY_ENVIRONMENT_ID and under Value, copy the environment id from previous step
-
Click on Add button again and, enter DISCOVERY_COLLECTION_ID and under Value, copy the environment id from previous step
-
Click on Save button. The app will automatically restart.
-
Launch the application from IBM Cloud dashboard
-
Enter an username, say, ajay to login and see the chat bot working
- Log in to IBM Cloud, you'll be taken to the dashboard
- Navigate to the the application you previously created
- Select Logs
- If you want, filter the LOG TYPE by "APP"
This sample code is licensed under Apache 2.0. Full license text is available in LICENSE.
Find more open source projects on the IBM Github Page.