Search This Blog

Monday, April 17, 2017

How to make IBM Watson Chatbot using conversation service API Part 1 ?


IBM has provided a lot of services with Watson platform. One of them is the conversation service which lets you make an intelligent bot for your customers which can be front end for your customers and can help generate leads and help with various other things like :

  • Quick reservations.
  • Service Tickets
  • Help desk operations.
  • Data Queries and analysis

watson chat bot api
Source : 1redDrop.com

So today I will show you how to use that service and integrate that bot with your business. It could be any Java based platform or any other platform which has integration capabilities either by REST or Web Services.
Lets get started.
Prerequisites:
  • Node JS
  • Cloud foundry CLI


Step 1  Cloning Watson conversation sample demo on GIT
Clone the sample application from IBM Watson conversation repository.
> cd project_root
> git clone https://github.com/watson-developer-cloud/conversation-simple

Step 2 Create service and Workspace
Now login to blue mix console and create a conversation service.
Create the new conversation service, search under Watson category from left dashboard.
my-conversation-service
Now click on Launch tool.

workspace launch

Get the credentials from the service and save it in notepad, this will be used in our .env file,located in project_root( The environment file for app)



About Workspaces(Very important to understand Conversation workspace)

This workspace is the brain of our bot. It has three components

  1. #Intents
  2. @Entities
  3. Dialogs

Intents are the queries which users might type or ask from bot.
E.g What day is today ? What time is today ? Weather condition in New York ?
Intent for the above could be - #information_request
ibm watson intent

Entities are the objects and conversation flow is driven around them.
E.g @appliance  entity might have – AC/Cooler/Fridge/TV
conversation entities

Dialog are the panels for the conversation flow and they define how the chat will go on the basis of inputs and conditions.
ibm watson dialog chat service

Here conversation_start is the entry point and the starting node of the conversation flow.
Next it will wait for user input and if user wants to make a phone call, he might type “call”
It will match the third node which has a condition called #phone intent or @phone entity.
So @phone entity has two components – call/text, it matches and will continue the flow.
The jump to node for the dialog means it will directly move to Phone actions node and will see the condition there, if no condition matches it will go to last node and its a good idea to have a node with true condition at last which will always evaluate to TRUE(any thing else) kind of node.
So here user will get a message “ Sorry I can’t make a phone call … “
Workspace subject is huge and will take a lot of time to design and this is the learning platform for our bot. We need to design intelligent workflow here around the entities and intents to make our bot look smarter to users and take intelligent decisions.

Step 3 Import a sample workspace for our demo from the folder we downloaded.
watson workspace conversation api
Import the workspace from the JSON provided in folder
<project_root>/training/car_workspace.json
image


Now copy the service credentials and workspace Id from the workspace and plug it in the
.env file of our project_root
so you .env file should  look like this.

image
Now its time to do a node build using npm and test it locally first before pushing it to your blue mix platform.

project_root>  npm install
project_root> npm start

That’s it you should be able to view the demo application on your system on port 3000
image

View it on http://localhost:3000


demo

Congratulations, you have setup the first chat bot using IBM watson conversation service.
This tutorial is a part of IBM Watson quick start tutorial series and in next tutorial we will see how we can customize the nodejs app to integrate with other Java based system using REST calls.
Node red also has a conversation node but in our case we need our chat agent to directly call the external systems and fetch us data like weather, IOT etc.


Keep Reading !

Action Item: Subscribe & Share !

No comments:

Post a Comment