There is a technological revolution taking place in the service industry with the introduction of Robots. The Robots are powered by artifical intelligence and are able to perform the roles of a waiter, customer relationship executive, cognitive assistant etc. The capabilties of the robot can be enhanced exponentially by integrating with cloud capabilities.
This journey demonstrates a scenario where the robot can answer queries on financial data by integrating with IBM Conversation service and IBM Data Science Experience(DSX). We will take you through the end to end flow of steps in building an interactive interface between NAO Robot, Watson Conversation API & Data Science Experience.
When the reader has completed this journey, they will understand how to:
- Establish the communication between NAO Robot and IBM Data Science Experience with Watson Conversation.
- Create the Watson Conversation chat bot application.
- Perform statistical analysis on a financial dataset using Jupitor (Python) Notebook on IBM Data Science Experience.
The intended audience for this journey are developers who want to develop a complete analytics solution on DSX with a custom web user interface.
- The user asks the questions on the dataset to the NAO Robot.
- The NAO Robot will convert the speech to text, and will send the text to Node-RED Flow for further processing on the cloud. The results from the processing on the cloud is returned to the NAO Robot through the Node-RED flow.
- Node-RED flow sends the converted text to the Watson Conversation API.
- The Watson Conversation API takes the text input. The text is analyzed to determine the intent based on the training provided.
- The context and state of the conversation is saved to the Cloudant DB to track the conversation flow of the user.
- The dataset for analysis is stored in the Object storage.
- Data file is taken as input in csv format.
- The Jupyter notebook receives the Watson Conversation Service API output from Node-RED using Web Sockets. The notebook processes the data based on the question and generates insights. The insights are sent back to the Node-RED flow using Web Socket.
- The Jupyter notebook is powered by Spark.
- The Node-RED flow sends the insights to NAO Robot.
-
Nao-Robot Choregraphe Behaviour: The fruit of a unique combination of mechanical engineering and software, NAO is a character made up of a multitude of sensors, motors and software piloted by a made-to-measure operating system: NAOqi OS.
-
Node-RED: Node-RED is a programming tool for wiring together APIs and online services.
-
Watson-Conversation-API: Build, test and deploy a bot or virtual agent across mobile devices, messaging platforms, or even on a physical robot.
-
IBM Data Science Experience: Analyze data using RStudio, Jupyter, and Python in a configured, collaborative environment that includes IBM value-adds, such as managed Spark.
-
Bluemix Object Storage: A Bluemix service that provides an unstructured cloud data store to build and deliver cost effective apps and services with high reliability and fast speed to market.
-
Jupyter Notebooks: An open-source web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text.
- Data Science: Systems and scientific methods to analyze structured and unstructured data in order to extract knowledge and insights.
- Analytics: Analytics delivers the value of data for the enterprise.
- Python: Python is a programming language that lets you work more quickly and integrate your systems more effectively.
- Jupyter Notebooks: An open-source web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text.
Follow these steps to setup and run this developer journey. The steps are described in detail below.
- Sign up for IBM Bluemix
- Create Bluemix services
- Configure Watson Conversation Application
- View Conversation Intents, Entities and Dialog
- Import the Node-RED flow
- Note the websocket URL
- Sign up for Data Science Experience
- Create the notebook
- Add the data
- Update the notebook with service credentials
- Run the notebook
- Results sent to the Node Red Flow
- Update the NAO Robot Choregraphe Behaviour with service credentials and Node-RED URL
- Transfer the behaviour to NAO Robot
Sign up for IBM Bluemix. By clicking on create a free account you will get 30 days trial account.
Create the Bluemix services by following the link to use the Bluemix UI.
Choose an appropriate name for the Node-RED application - App name:
. Click on Create
.
- On the newly created Node-RED application page, Click on
Visit App URL
to launch the Node-RED editor once the application is inRunning
state. - On the
Welcome to your new Node-RED instance on IBM Bluemix
screen, Click onNext
- On the
Secure your Node-RED editor
screen, enter a username and password to secure the Node-RED editor and click onNext
- On the
Browse available IBM Bluemix nodes
screen, click onNext
- On the
Finish the install
screen, click on Finish - Click on
Go to your Node-RED flow editor
Choose an appropriate name for the Speech to Text Service - App name:
. Click on Create
.
- On the newly created Speech to Text Service page, Click on
Service credentials
thenView credential
and note down the credentials for future use.
Choose an appropriate name for the Conversation Service - App name:
. Click on Create
.
-
On the newly created Conversation Service page, Click on
Service credentials
thenView credential
and note down the credentials for future use. -
On the same page, on the left side now Click on
Manage
icon then on the right side click onLaunch tool
to launch the Conversation Workspaces.
Launch the Watson Conversation tool.
-
Navigate to workspace.json.`
-
Update the workspace id in the workspace.json document under "workspace_id"
-
Click on the "up arrow" to import a workspace & make sure "Everything" option is selected
-
Click choose a file, navigate to workspace.json document and select import
-
Click on "Watson Conversation" at the top to go back to workspace
-
Find the Workspace ID by clicking on the context menu (three vertical dots) of the new workspace and select View details.
- Click on the View details. Note down the Workspace ID.
To view the conversation Intents, Entities and Dialog select the workspace and choose the Intents tab, Entities tab and Dialog tab.
Intents
Intents are purposes or goals expressed in a customer's input, such as answering a question or processing a bill payment. By recognizing the intent expressed in a customer's input, the Conversation service can choose the correct dialog flow for responding to it.
Entities
Entities represent a class of object or a data type that is relevant to a user's purpose. By recognizing the entities that are mentioned in the user's input, the Conversation service can choose the specific actions to take to fulfill an intent.
There are two types of the entities available under the Watson Conversation. One is My entities
and another is System entities
. Refer below for My Entities.
In this conversation two system entities have been used namely @sys-date
and @sys-number
. User has to switch on
the button before using it.
Dialog
The dialog uses the intents and entities that are identified in the user's input, plus context from the application, to interact with the user and ultimately provide a useful response.
In this conversation, the slots feature under dialog has been used to gather multiple informations from the user. Slots for Max
dialog is represented in the above image.
- Clone this repo.
- Navigate to Robotic_AI_Agent_workflow.json.`
- Open the NODERED_BASED_URL and click on "Go To Your Node-RED flow editor" to launch the Node-RED editor.
- Update the Node-RED URL (replace NODERED_BASE_URL with the correct URL) under path in the json file.
- Open the Robotic_AI_Agent_workflow.json file with a text editor and copy all the contents to Clipboard.
- On the Node-RED flow editor, click the Menu and select Import -> Clipboard, select new flow and paste the contents from text editor & click import.
- Components of Node-RED flow includes a web socket server, Watson Conversation Service, Data Science Experience & user defined functions which tie them togeather to enable exchange of information.
- Please review steps 1 to 10 under the Architecture diagram to understand the flow of events using Node-RED.
- Double click on the
conversation
node.Edit conversation node
prompt will open. - Enter the Workspace ID that we noted in Configure Watson Conversation Application.
- Add username & password from Watson Conversation & click done.
The websocket URL is ws://<NODERED_BASE_URL>
/ws/Robot_webpage where the NODERED_BASE_URL
is the marked portion of the URL in the above image.
An example websocket URL for a Node-RED app with name myApp
- ws://myApp.mybluemix.net/ws/ws-robosocket
where myApp.mybluemix.net
is the NODERED_BASE_URL.
The NODERED_BASE_URL can have an additional region information say eu-gb
for UK region and NODERED_BASE_URL could be myApp.eu-gb.mybluemix.net
.
Data Science Experience. By signing up for Data Science Experience, two services: DSX-Spark
and DSX-ObjectStore
will be created in your Bluemix account.
Open IBM Data Science Experience. Use the menu on the top to select Projects
and then Default Project
.
Click on Add notebooks
(upper right) to create a notebook.
- Select the
From URL
tab. - Enter a name for the notebook.
- Optionally, enter a description for the notebook.
- Enter this Notebook URL : (https://github.com/IBM/watson-nao-robot/blob/master/Notebook/Robo_Notebook.ipynb)
- Click the
Create Notebook
button.
Use Find and Add Data
(look for the 10/01
icon)
and its Files
tab. From there you can click
browse
and add data files from your computer.
Note: The data file in the
data
directory -Data.csv
has been downloaded from (https://www.ibm.com/communities/analytics/watson-analytics-blog/retail-sales-marketing-profit-cost/). Change the file name from "WA_Retail-SalesMarketing_-ProfitCost.csv" to "Data.csv" before reading it in DSX. There are spaces in the column names which needs to be replaced with "_" before reading the file in DSX. Ex :- Product line has to be Product_line. Please visit the site for the terms and conditions for usage of the data.
Select the cell below 2.1 Add your service credentials for Object Storage
section in the notebook to update
the credentials for Object Store.
Use Find and Add Data
(look for the 10/01
icon) and its Files
tab. You should see the file names uploaded earlier. Make sure your active cell is the empty one created earlier. Select Insert to code
(below your file name). Click Insert Crendentials
from drop down menu.
In the cell below 7. Expose integration point with a websocket client
, update the websocket url noted in section 5 in the start_websocket_listener
function.
When a notebook is executed, what is actually happening is that each code cell in the notebook is executed, in order, from top to bottom.
Each code cell is selectable and is preceded by a tag in the left margin. The tag
format is In [x]:
. Depending on the state of the notebook, the x
can be:
- A blank, this indicates that the cell has never been executed.
- A number, this number represents the relative order this code step was executed.
- A
*
, this indicates that the cell is currently executing.
There are several ways to execute the code cells in your notebook:
- One cell at a time.
- Select the cell, and then press the
Play
button in the toolbar.
- Select the cell, and then press the
- Batch mode, in sequential order.
- From the
Cell
menu bar, there are several options available. For example, you canRun All
cells in your notebook, or you canRun All Below
, that will start executing from the first cell under the currently selected cell, and then continue executing all cells that follow.
- From the
The results from Data Science Experience are sent to Node-RED flow which is relayed to NAO Robot.
The sample response for the question is given below.
**User**: What is the highest profit of Capri Italy in 2007?
**NAO response**: The highest profit of Capri Italy in 2007 is 310000.
Open the NAO robot project (WatsonNaoRobot.pml) file under choregraphe/watson_nao_robot folder with the Choregraphe.
Connect to the NAO robot using the Connection/Connect
to menu from Choregrpahe.
- Select the behavior.xar file in the project folder strcuture in the top left pane.
- Double click the
WatsonSTT Python Script
box in the choregraphe canvas pane. - Update the Watson Speech to Text credentials in the
auth
variable in the Python code inside thePython Script
box as shown below.
- Select the behavior.xar file in the project folder strcuture in the top left pane.
- Double click the
PostToNode-RED Python Script
box in the choregraphe canvas pane. - Update the Node-RED URL in the
url
variable in the Python code inside thePython Script
box as shown below.
Save the changes to the NAO robot project (WatsonNaoRobot.pml).
- Select
Connection
from Choregraphe Menu and clickUpload to the robot and Play
sub menu to transfer behavior files to the NAO Robot and activate this journey code on the Robot. - Press the front tactile head sensor of the NAO robot and ask your question related to the dataset analysis and insights.