Creating a banking chatbot hosted at IBM Cloud connected to IBM Watson using Node.js
On this step by step tutorial I'll explain how to create a banking chatbot assistant using the demo app from IBM. The application will be hosted on IBM Cloud and will use the IBM Watson API as the assistant AI.
What will we create?
Based on a demo application by IBM, we'll create a chat web app. All the conversation in this chat will be managed by IBM Watson Assistant. IBM Watson are the AI tools provided as an API by IBM.
- Install the necessary prerequisits.
- Clone the chat web app repository.
- Create a Watson assistant interface on IBM Watson manager page.
Before going further you need to have the following:
- An IBM Cloud account. You can create one for free, no credit card needed.
- Download and install the IBM Cloud CLI tools. This tool allows you to manage your cloud instances reotely by command line interface.
Let's do it!
Clone the repository
Clone the IBM Chat demo repository.
git clone https://github.com/watson-developer-cloud/assistant-simple.git
Now go to new folder create by
Create a Watson Assistant Service
Now, you need to create a Watson service. This service will be a conversation service one.
Open the Watson Assistant conversation creation page
Set you prefferred
Service name and click on
When the process is finished, you'll be redirected to your new service manager page.
In this page you can find the necessary credentials to connect your chatbot app to this new Watson service. You can download your credentials just clicking on
Download button. Save the downloaded file as
.env in the root folder on the recent cloned repository.
IMPORTANT! Open the .env file and rename the fielad name
Where you'll find your stuff on IBM Cloud
Before going further let's save an URL page that can be useful for you working on these service. Your IBM Cloud Resource list. You'll find all your resources listed. From this menu you can access to manage all your apps and services.
Open your resource page linked above and find your new Watson service. You'll find in the
Click on the name of your service to open the manager. Here you can find your credentials and other tools related to your service.
Configure the application
Before going further, we need to configure our new assistant. The assistant has no
intelligence form scrath. The IBM Watson Assistant tool has a complete tool to provide your assistant with the features you need. You need to:
- Create an skill - Is something of what your assistant will know.
- Deploy with an assitant - Link this skill to your new assistant you recently created on steps above.
You need to be in your service manager page. This page the one we opened in the step before. From resources, click on the name of your service. In this page, click on the button
Create a new skill
In the Watson Assitant page (the last opened) go to
skills tab and click on
If we were staring form scratch we would create our skill from zero and we sould implement all the details. But in this case, we have a demo application. This demo application is based on an assistant already skilled. On the repository you'll cloned in the first place, you'll find a folder called
training. There's a file named
bank_simple_workspace.json that contains all the skills details already defined. You can just import this skill.
import skill and click on
Choose JSON File. select the file detailed above. Don't change the option selected
Everything (Intents, Entities, and Dialog)
After selecting the file on your computer, click on
Create new Assistant
Now you need to create an Assistant that will use these skills.
Go to the
Assistants tab and click on
Create new button.
Name And click on
After the system create the new assistant it redirects your new assistant's manager page.
Now, let's assign a our skills to this assistant. Click on
Add dialog skills
Select the bank_simple skill
At this point we have.
- An Assistant ready to use.
- An skill set binded to this assistant.
- A service ready to use this assistant.
Configure the API keys
Don't leave your new assistant page. Open the
three dot button to open the options menu of the assistant. Select the
View API details.
You'll see your API Keys. Now, open your local files and open the
.env file we created some steps before.
Insert a first line on this file with the following variable containing the value you have on your
Running the application loacally
Open your command/bash tool and install the necessary npm packages:
Execute your application
You should see something like this. You can write and Watson Assistant will answer you.
Deploying to IBM Cloud as a Cloud Foundry Application
What we'll do at this point is to upload our new application to an IBM Cloud server to run there.
Let's start login in to IBM Cloud from the shell.
Specify a region. I selected number 4.
Now we need to target a Cloud Foundry organization and space.
ibmcloud target -cf
My result for both steps looks like this on my Power Shell console.
Now, go to your files and edit
manifest.yml file. Change the name field to something unique.
For example, -
Deploy the application to IBM Cloud.
ibmcloud app push
If you set not a unique name, the command will throw you an error:
The app cannot be mapped to route my-app-name.eu-gb.mybluemix.net because the route exists in a different space.
If this happens, change the
manifest.yml until you find a non existing name.
My final result is likes this:
Now it's time to try if everything works ok and our application is accessible using our browser. Open your url to check your app. You can find your URL on the image above in the
routes field. Your url will be different from the one appearing in the image.
Now your app is configured and running on IBM Cloud. Now you can play with the UI or the skills on your Watson assistant.
you can always add other services to this application in order to recogninze images, talk, and everything you can find on Watson AI API!