You can view a demo of this app.
Sign up for an IBM Cloud account.
Login to IBM Cloud.
With IBM Watson™ Assistant service you can build a solution that understands natural-language input and uses machine learning to respond to customers in a way that simulates a conversation between humans.
Go to your IBM Cloud account and open the catalog. Look for Watson Assistant service and click on it.
Choose the region and space where you want the service to be created. In new accounts it will automatically select your resource group, usually named as default. You don't need to change the name if you don't want to, just click on 'Create'.
Once the service is created click on 'Launch tool' to access it.
In the home tab you have videos and tutorials on how to get started building dialoges. Feel free to explore them. Let's move to the Skills tab.
The natural-language processing happens inside a skill, which is a container for all of the artifacts that define the conversation flow for an application.
You can create a new skill and start from scratch or import an existing conversation.
Download a conversation from here: https://ibm.box.com/v/bank-conversation
Click on the 'Create new' button and then click on the import skill tab.
When you import a skill, you can choose to import only the intents and entities, which can be useful if you want to build a new dialog using the same training data. In this case we will import everything. Click on 'Choose JSON file ' button and find the file you just downloaded. Then click on Import.
IBM Watson™ Assistant is a cognitive bot that you can customize for your business needs, and deploy across multiple channels to bring help to your customers where and when they need it.
Dialog skill
Create a dialog skill. Use the intuitive graphical tool to define the training data and dialog for the conversation between your assistant and your customers. In this lab we imported a sample conversation.
The training data consists of the following artifacts:
Intents: Goals that you anticipate your users will have when they interact with the service. Define one intent for each goal that can be identified in a user's input. For example, you might define an intent named store_hours that answers questions about store hours. For each intent, you add sample utterances that reflect the input customers might use to ask for the information they need, such as, What time do you open? You can also use prebuilt content catalogs provided by IBM to get started with data that addresses common customer goals.
Entities: An entity represents a term or object that provides context for an intent. For example, an entity might be a city name that helps your dialog to distinguish which store the user wants to know store hours for. As you add training data, a natural language classifier is automatically added to the skill, and is trained to understand the types of requests that you have indicated the service should listen for and respond to.
Dialog: Use the dialog tool to build a dialog flow that incorporates your intents and entities. The dialog flow is represented graphically in the tool as a tree. You can add a branch to process each of the intents that you want the service to handle. You can then add branch nodes that handle the many possible permutations of a request based on other factors, such as the entities found in the user input or information that is passed to the service from an external service.
As you make changes to your dialog, you can test it at any time to see how it responds to input. From the Dialog tab, click the conversation bubble icon. In the chat panel, type some text and then press Enter. Check the response to see if the dialog correctly interpreted your input and chose the right response.
The chat window indicates what intents and entities were recognized in the input. In the dialog editor pane, the currently active node is highlighted Feel free to create new intents for your bot.
Once you have tested the dialoge, it's time to collect the credentials. You will need them to connect the web application in future steps to your chatbot.
Click on the Skills name and go back to the Skills overview.
Click on the 3 dots in your Assistant to open a menu and then click on View API details.
Copy the credentials and save them for later. You will need the Workspace ID (skill), username ('apikey') and password.
Click here to deploy the user interface of your bot:
Click on "Create" to create an IBM Cloud API to connect the application with your account and services. The organization, space and region will be automatically filled.
Note: If it takes too long to load the organization, space and region make sure you are deploying the application in an available region for your account. You can change the region under the toolchain name.
Then click on Deploy.
The application will not run till you enter your Watson Assitant credentials. Open the Git to see the application code. Click on "GIT" to access your application repository.
Open the .env file and add the service credentials that you obtained in the previous step. The Watson SDK automatically locates the correct environment variables for either username
, password
, and url
or the apikey
and url
credentials found in the .env file.
Example *.env* file that configures the `apikey` and `url` for a Watson Assistant service instance hosted in the US East region:
```
ASSISTANT_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2
ASSISTANT_URL=https://gateway-wdc.watsonplatform.net/assistant/api
```
- If your service instance uses `username` and `password` credentials, add the `ASSISTANT_USERNAME` and `ASSISTANT_PASSWORD` variables to the *.env* file.
Example *.env* file that configures the `username`, `password`, and `url` for a Watson Assistant service instance hosted in the US South region:
```
ASSISTANT_USERNAME=522be-7b41-ab44-dec3-g1eab2ha73c6
ASSISTANT_PASSWORD=A4Z5BdGENrwu8
ASSISTANT_URL=https://gateway.watsonplatform.net/assistant/api
```
However, if your credentials contain an IAM API key, copy the `apikey` and `url` to the relevant fields.
```JSON
{
"apikey": "ca2905e6-7b5d-4408-9192-e4d54d83e604",
"iam_apikey_description": "Auto generated apikey during resource-key ...",
"iam_apikey_name": "auto-generated-apikey-62b71334-3ae3-4609-be26-846fa59ece42",
"iam_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Manager",
"iam_serviceid_crn": "crn:v1:bluemix:public:iam...",
"url": "https://gateway-syd.watsonplatform.net/assistant/api"
}
```
```
ASSISTANT_IAM_APIKEY=ca2905e6-7b5d-4408-9192-e4d54d83e604
ASSISTANT_IAM_URL=https://gateway-syd.watsonplatform.net/assistant/api
```
Click "Edit" to add your Watson Assistant credentials.
You will need to provide the workspace ID, and username & password. Then click on the green button "Commit changes".
Once you commit the changes the application will start and you will be able to test your chatbot in your given URL. You can go back to IBM Cloud (www.bluemix.net) and wait for your application to start.
Once it is running you can click on the application name and then "Visit app URL" to start chatting with your bot.
Clone the repository to your machine.
-
Install the dependencies
npm install
-
Run the application
npm start
-
View the application in a browser at
localhost:3000
Make sure you modified the .env file with your own credentials.
-
Login to IBM Cloud with the IBM Cloud CLI
ibmcloud login
-
Target a Cloud Foundry organization and space.
ibmcloud target --cf
-
Edit the manifest.yml file. Change the name field to something unique.
For example,- name: my-app-name
. -
Deploy the application
ibmcloud app push
-
View the application online at the app URL.
For example: https://my-app-name.mybluemix.net
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.