This application demonstrates how the Conversation service uses intent capabilities in a simple chat interface.
Give it a try! Click the button below to fork into IBM DevOps Services and deploy your own copy of this application on Bluemix.
The app interface is designed and trained for chatting with a cognitive car. The chat interface is on the left, and the JSON that the JavaScript code receives from the server is on the right. Your questions and commands are run against a small set of sample data trained with intents like these:
turn_on
weather
capabilities
To see all the intents, open /training/car_intents.csv
.
These intents help the system to understand variations of questions and commands that you might submit. For example, if you say "Wipers on" or "I want to turn on the windshield wipers", the system understands that in both cases your intent is the same and responds accordingly.
If you have used the Deploy to Bluemix button above, skip to Creating a Workspace below.
- Create a Bluemix Account
Sign up in Bluemix, or use an existing account. Watson Beta or Experimental Services are free to use.
-
Download and install the Cloud-foundry CLI tool
-
Edit the
manifest.yml
file and change the<application-name>
to something unique.
applications:git
- services:
- conversation-service
name: <application-name>
command: npm start
path: .
memory: 256M
The name you use will determinate your application url initially, e.g. <application-name>.mybluemix.net
.
- Connect to Bluemix in the command line tool For US Region
$ cf api https://api.ng.bluemix.net
$ cf login -u <your user ID>
- Create the Conversation Service in Bluemix
$ cf create-service conversation experimental conversation-service
- Push it live!
$ cf push
-
Once the service has been provisioned, you will need to create a workspace. To do that navigate to the service instance tile within Bluemix. Once there click on the Manage menu item. Click on the Launch Tooling button within the documentation at which point a new tab will open in your browser, and you will be prompted to login if you have not done so before. Log in with your Bluemix credentials.
-
Once logged in you should be able to Create a Workspace. Press the Create button and give the workspace a name (and optional description). Press Create to finish creating the workspace.
-
A new workspace tile will be created within the tooling. Press on the menu button within the workspace tile, and select View details:
In the Details UI copy the 36 character UNID ID field (e.g. 84a74a20-1390-4540-ce8a-eabac5fdf921). This is the Workspace ID. -
Open the workspace by pressing the Get started button within the workspace tile. You will be navigated to the Intents screen. At this point you can either create your own itents by following the instructions on screen, or upload the intents used in this application. To upload the predefined intents from here simply press the Import intents button . Once you imported the intents or created your own the service will take a few moments to train the service.
-
Return to your application, either in your local dev environment, or on Bluemix. If running on Bluemix you will need to create a new Environment Variable called WORKSPACE_ID. Paste in the value of the Workspace id (obtained in step 3 above) as the value of the new variable. Restart your application. If running your application locally, skip to the next section.
For information on workspaces, see the full Conversation service documentation.
The application uses Node.js and npm.
- Copy the credentials from your
conversation-service
service in Bluemix to a.env
file in the root. - Use the Conversation tooling app to create a workspace, as described above, and add the workspace id to the
.env
file (see above for details on obtaining the Workspace ID). - Install Node.js
- Go to the project folder in a terminal and run:
npm install
- Start the application
npm start
- Go to http://localhost:3000
To troubleshoot your Bluemix application, use the logs. To see the logs, run:
$ cf logs <application-name> --recent
This sample code is licensed under Apache 2.0. Full license text is available in LICENSE.