This application demonstrates how the Conversation service uses intent capabilities in a simple chat interface.
For more information about Conversation, see the detailed documentation.
Either way you deploy this app, you must have a Bluemix account and run some steps within 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
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
play music
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.
# Getting Started using Bluemix![](readme_images/Deploy on Bluemix - simple app.png)
1 Ensure that you have a Bluemix account.
2 Ensure that you have the necessary space available in your Bluemix account. This action deploys 1 application and 1 service.
- You can view this on your Bluemix Dashboard. Tiles will show what space you have available.
- For example, for Services & APIS
![](readme_images/services.PNG)
1 Select Deploy to Bluemix.
2 Log in with an existing Bluemix account or sign up.
3 Name your app and select your REGION, ORGINIZATION, and SPACE. Then select DEPLOY.
-
This performs two actions:
- Creates the app
- Creates a Conversation service instance that the user needs for workspace creation
-
The status of the deployment is shown. This can take some time.
4 Once your app has deployed, select VIEW YOUR APP.
5 Navigate to your Bluemix Dashboard and [import a workspace](#workspace). Setup your workspace then return to these steps.6 After you have set up a workspace, add the WORKSPACE_ID environment variable.
## Using Cloudfoundry CLI tool to deploy your applicationTo build the application:
1 Download and install the Cloudfoundry CLI tool.
2 Git clone the project https://github.com/watson-developer-cloud/conversation-simple
3 Navigate to the conversation-simple
folder
4 Connect to Bluemix in the command-line tool:
For US Region
$ cf api https://api.ng.bluemix.net
$ cf login -u <your user ID>
5 Create the Conversation service in Bluemix:
$ cf create-service conversation free conversation-service
6 Push it live:
$ cf push <application-name>
The name you use determinates your application URL initially, such as <application-name>.mybluemix.net
.
1 Ensure that you have a Bluemix account. While you can do part of this deployment locally, you must still use Bluemix.
2 In Bluemix, [create a Conversation Service](http://www.ibm.com/watson/developercloud/doc/conversation/convo_getstart.shtml). - [Import a workspace](#workspace) - Copy the [Service Credentials](#credentials) for later use. - Return to these stepsThe application uses Node.js and npm.
1 Copy the credentials from your conversation-service
service in Bluemix to a .env
file in the root.
2 Use the Conversation tooling app to import a workspace and add the workspace ID environment variable to the .env
file. For details about obtaining the workspace ID, see Step 5 in the workspace section.
3 Install Node.js.
4 Open the terminal, go to the project folder, and run this command:
npm install
5 Start the application by running this command:
npm start
6 Open http://localhost:3000
in a browser.
Note: If you are interested in deploying you local application or the changes you have made locally to Bluemix, go to this section
# Service Credentials1 Go to the Bluemix Dashboard and select the Conversation service instance. Once there, select the Service Credentials menu item.
2 Select ADD CREDENTIALS. Name your credentials then select ADD.
3 Copy the credentials (or remember this location) for later use.
# Import a workspaceTo 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 this sample app, a workspace is provided.
For more information on workspaces, see the full Conversation service documentation.
1 Navigate to the Bluemix dashboard, select the Conversation service that you created.
2 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.
3 If you are deploying through Bluemix, download the exported JSON file that contains the Workspace contents. If deploying locally, this was cloned and is in the training folder (training/car_workspace.json).
4 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.
5 Refresh your browser. A new workspace tile is created within the tooling. 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**.6 Return to the deploy steps that you were following:
- For Local - return to step 2
- For Bluemix - return to step 5
1 In Bluemix, open the application from the Dashboard. Select Environment Variables.
2 Select USER-DEFINED.
3 Select ADD.
4 Add a variable with the name WORKSPACE_ID. For the value, paste in the Workspace ID you copied earlier. Select SAVE.
5 Restart your application.
- 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).
To see the logs, run the command
$ cf logs < application-name > --recent
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.