This application demonstrates how the Bluemix Conversation service can be used to build a simple on-board car chat application.
- We will learn and understand how to integrate the Conversation service with other REST APIs such as NLU, Weather etc
- We will explore further how to enhance the functionalities of the chat application
Following services are used from Bluemix:
- Watson Conversation
- Watson NLU
- IBM Weather Company Data
See the app demo
For more information about Conversation, see the detailed documentation.
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
These intents help the system to understand variations of questions and commands that you might submit.
Example commands that can be executed by the Conversation service are:
turn on windshield wipers
find restaurants
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.
Ensure that you have a Bluemix account
- Select "Deploy to Bluemix" icon below.
-
This action deploys 1 application and 3 services. You can view this on your Bluemix Dashboard.
-
Log in with your existing Bluemix account or Sign up
-
Name your app and select your REGION, ORGANIZATION and SPACE. Then select DEPLOY.
Note: If the "Space" does not get listed, please take help and create it manually
-
The deploy performs two actions:
- deploys the app run time
- creates a Conversation, NLU and Weather service instances
-
The deployment can take some time. You can see its status like the one given below:
Note:
-
Existing Bluemix users with Toolchain Id will see a screen like this.
-
For users without a Toolchain Id, the deployment might fail. It might mean that the user does not have a repository. To fix this, refer to the screen shots below.
- Once your app is deployed, select VIEW YOUR APP
To use the app you're creating, you need to add a worksapce to your Conversation service. A workspace is a container for all the artifacts that define the behavior of your service (ie: intents, entities and chat flows).
For more information on workspaces, see the full Conversation service documentation.
-
Navigate to the Bluemix dashboard, select the Conversation service that you created
-
Go to the Manage menu item and select Launch Tool. This opens a new tab in your browser, where you are prompted to login if you have not done so before. Use your Bluemix credentials.
-
Download the exported file that contains the Workspace contents by clicking exported JSON file
- navigate to the training folder to find
car-dashboard.json
file - click on the "Raw" link which will open a browser
- Select "Save As" and save the file as a json
- navigate to the training folder to find
-
Select the import icon: . Browse to (or drag and drop) the JSON file. Choose to import Everything(Intents, Entities, and Dialog). Then select Import to finish importing the workspace.
-
Refresh your browser. A new workspace tile is created in the tool. Select the menu button within the workspace tile, then select View details:
In the Details UI, copy the 36 character UNID ID field. This is the WORKSPACE_ID. Retain this for the following step where we will create an environment variable. This varibale will be the handle for the application to refer to the Conversation Service that we created.
-
In Bluemix, open the application from the Dashboard (you will have to click on the Application Name). Select Runtime followed by the Environment Variables tab on the right.
-
Scroll down the page to select USER-DEFINED
-
Select ADD
-
Add a variable with the name WORKSPACE_ID
For the value, paste in the Workspace ID you copied earlier. Select SAVE.
-
Restart your application
-
Click on the application link to execute it. Now you are all set to have a conversation !
Here are some sample questions that you can start off with,
- Can you switch on music ?
- Can you find a gas station ?
- Log in to Bluemix, you'll be taken to the dashboard
- Navigate to the the application you previously created
- Select Logs
- If you want, filter the LOG TYPE by "APP"
- Log in to Bluemix, you'll be taken to the dashboard
- Select Compute
- Select the application you previously created
- Select Logs
- If you want, filter the Log Type by selecting the drop-down and selecting Application(APP)
Problem statement: Adding new cuisine types for Indian cuisine like Veg and Non Veg and display respective restaurants
-
Go to the Bluemix Dashboard
-
Go to the Conversation service link. Click on the "Launch Tooling" link.
-
Go to the Entities section. Add entity - "indiancuisine".
Add values for this entity like - Vegetarian and NonVegetarian. Add synonyms to both of these values like "non veg", "Non veg", "veg", "Veg".
- Add another value of cuisine which is "indian"
- Go to the Dialog section and add the condition from cuisine as displayed in the screen shot below for two of the condition for Indian flavours.
We would add the context values for Indian Vegetarian and Non Vegetarian hotels
a) Indian Vegetarian
Sample JSON code:
{
"context": {
"veghotels": "A2B,Vidyarthi"
},
"output": {
"text": {
"values": [
"Sure thing. Navigating to the @cuisine:vegetarian restaurant. Following $veghotels gets great reviews. You'll be there soon."
]
}
}
}
b) Non Vegetarian
Sample JSON code:
{
"context": {
"nonveghotels": "Mass,KFC"
},
"output": {
"text": {
"values": [
"Sure thing. Navigating to the @cuisine:vegetarian restaurant. Following $nonveghotels gets great reviews. You'll be there soon."
]
}
}
}
- Add "Jump To" (see the highlighted section in the screen shot) connection to response of @cuisine
Below is the API usage architecture diagram of this application
Whenever the chat transcript contains a query regarding "weather" of a place, the Conversation service uses NLU to identify the entities like city / town and invokes the Weather service to get the weather details of that city / town.
You can type a query like, "what is the temperature in Bangalore today ?" and the application will respond accordingly.
This sample code is licensed under Apache 2.0. Full license text is available in LICENSE.
See CONTRIBUTING
Find more open source projects on the IBM Github Page