This Node.js app demonstrates the Watson Assistant service in a simple chat interface simulating a cognitive car dashboard.
The following steps are for running locally with Node.js. You can also run locally with Docker.
-
To develop locally, first install Node.js (LTS supported versions).
-
At the command line, go to your project directory.
-
Install the dependencies:
npm install
-
Start the app:
npm start
-
Point your browser to localhost:3000.
After your app is installed and running, experiment with it to see how it responds.
The chat interface is on the left, and the JSON that the JavaScript code receives from the Watson Assistant service is on the right. Your questions and commands are interpreted using a small set of sample data trained with the following intents:
turn_on
turn_off
turn_up
turn_down
traffic_update
locate_amenity
weather
phone
capabilities
greetings
goodbyes
Type a request, such as music on
or I want to turn on the windshield wipers
. The system understands your intent and responds. You can see the details of how your input was understood by examining the JSON data in the Watson understands
section on the right side.
For example, if you type Turn on some music
, the JSON data shows that the system understood the turn_on
intent with a high level of confidence, along with the appliance
entity with a value of music
.
-
Visit the documentation to learn more about intents and entities
-
Go to the tool to learn more about the Car Dashboard's intents, entities, and dialog.
- To launch the tool you need to return to your Project List and select your Watson Assistant Basic Project.
- Click on
Train Service
from the Service List, next toWatson Assistant
. - Log into the tool with your IBM Cloud login and password
- Click on the Car Dashboard workspace
- You will land on the
Intents
tab. Here you can view the intents such asturn_on
, to modify these visit the documentation for the service. - The next tab is where you can modify
entities
such asappliance
. View the documentation to learn how to modify. - The third tab is for modifying the
dialog
. You can learn more about modifyingdialog
in the documentation.
After you have the app deployed and running, you can explore the source files and make changes. Try the following:
- Modify the .js files to change the app logic.
- Modify the .html file to change the appearance of the app page.
- Use the Watson Assistant tool to train the service for new intents, or to modify the dialog flow. For more information, see the Watson Assistant service documentation.
- Try creating your own bot with the tool:
- To launch the tool you need to return to your App List and select your Watson Assistant Basic Project.
- Click on
Train Service
from the Service List, next toWatson Assistant
. - Log into the tool.
- Follow the Getting started guide to create your own Watson Assistant workspace
-
To deploy your project to IBM Cloud, you will need to install the Bluemix CLI. Open a terminal and run the command that corresponds with your operating system:
-
MacOS
sh <(curl -fsSL https://clis.ng.bluemix.net/install/osx)
-
Linux
sh <(curl -fsSL https://clis.ng.bluemix.net/install/linux)
-
Windows Powershell
Copy and paste the following command into a Windows PowerShell terminal console and execute it.
iex(New-Object Net.WebClient).DownloadString('https://clis.ng.bluemix.net/install/powershell')
-
-
Set your API endpoint. Check the top right corner of your IBM Cloud dashboard to determine which of the following Regions your account is set to, then run the corresponding command to set your API Endpoint.
-
US South:
bx api https://api.ng.bluemix.net
-
Germany:
bx api https://api.eu-de.bluemix.net
-
Sydney:
bx api https://api.au-syd.bluemix.net
-
United Kingdom:
bx api https://api.eu-gb.bluemix.net
-
-
In your terminal go to your Project folder and run the following command to login to your IBM Cloud account with your IBM Cloud username and password.
bx login
-
Push the app to IBM Cloud:
bx app push
The app will be deployed using the settings in your project's
manifest.yml
file. -
Access your app at the URL specified in the command output.
After your app is deployed, you can manage it from your IBM Cloud dashboard.
Select your project from the Projects list in the Watson developer console. From the project page, you can do the following:
- Add additional services to your project
- View documentation and credentials for your project's services
- Configure a DevOps toolchain
-
Run the command that corresponds with your operating system to install the IBM Cloud Developer Tools CLI:
-
MacOS or Linux:
curl -sL https://ibm.biz/idt-installer | bash
-
Windows 10:
Set-ExecutionPolicy Unrestricted; iex(New-Object Net.WebClient).DownloadString('http://ibm.biz/idt-win-installer')
-
-
Download and install Docker.
-
If you installed any node dependencies into your project folder, remove them. Open a terminal and run the following command from your project folder, where your starter kit code is:
rm -rf node_modules
-
Build the Docker container:
bx dev build
The build may take a few minutes to complete.
-
Run the Docker container:
bx dev run
-
Point your browser to localhost:3000.
This sample code is licensed under Apache 2.0.
Find more open source projects on the IBM Github Page