Creating a banking chat bot hosted at IBM Cloud connected to IBM Watson using No

Fri Mar 15 2019 15:24:18 GMT+0100 (Hora estándar romance), David Ibáñez

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.

IBMCloud.png

Steps

  • Install the necessary prerequisits.
  • Clone the chat web app repository.
  • Create a Watson assistant interface on IBM Watson manager page.

Prerequisitis

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

git.PNGs

Now go to new folder create by git

cd assistant-simple.git

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

watson.PNG

Set you prefferred Service name and click on Create Button.

When the process is finished, you'll be redirected to your new service manager page.

watson service page.PNG

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 ASSISTANT_APIKEY to ASSISTANT_IAM_APIKEY.

envFile.PNG

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 Service entry.
Resources.PNG

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 Launch Tool

watson service page.PNG

Create a new skill

In the Watson Assitant page (the last opened) go to skills tab and click on Create new

skills.PNG

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.

Click on import skill and click on Choose JSON File. select the file detailed above. Don't change the option selected Everything (Intents, Entities, and Dialog)

import.PNG

After selecting the file on your computer, click on Import.

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.

create assistant.PNG

Set a Name And click on Create

After the system create the new assistant it redirects your new assistant's manager page.

assist manager.PNG

Now, let's assign a our skills to this assistant. Click on Add dialog skills

add skill to assistant.PNG

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.

api details.PNG

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 assistant_id:

ASSISTANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Running the application loacally

Open your command/bash tool and install the necessary npm packages:

npm install

Execute your application

npm start

You should see something like this. You can write and Watson Assistant will answer you.

browser.PNG

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.

ibmcloud login

Enter your user and password

Specify a region. I selected number 4. eu-gb

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.

powershell.png

Now, go to your files and edit manifest.yml file. Change the name field to something unique.
For example, - name: my-app-name.

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:

result.PNG

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.

That's it

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!


Tags

Follow us

Latest blogs
How to train YOLOv3 using Darknet on Colab notebook and speed up load times
Wed Apr 10 2019 14:57:55 GMT+0200 (Hora de verano romance)
Creating a banking chat bot hosted at IBM Cloud connected to IBM Watson using No
Fri Mar 15 2019 15:24:18 GMT+0100 (Hora estándar romance)
Getting back to #100DaysOfCode
Wed Mar 06 2019 22:30:42 GMT+0100 (Hora estándar romance)
50 days of the 100DaysOfCode challenge
Sun Feb 17 2019 16:47:31 GMT+0100 (Hora estándar romance)
creating your own framework part #2
Tue Jan 29 2019 22:48:31 GMT+0100 (Hora estándar romance)

Latest comments