This Node.js app, Watson Assistant Chatbot (IBM) and this Web Chat sample demonstrates the integration of a chatbot with an web-based system.
-
Install the dependencies
npm install -
Create a .env file inside the root folder of the app located in:
<project_root>/node-server- The content of the .env file must be:
DB_URL = <MongoDB URL> DB_NAME = <name> HOST = <The url of the app, "http://127.0.0.1:8081" for example> COLLECTION = <Collection that the app is going to use> -
Run the application
npm start -
For this example to work correctly, the application must be published on a server. I recommend publishing on an AWS server, where you are able to create a simple server and put it online for one year free of charge.
- Sign up for an IBM Cloud account.
- Create an instance of the Watson Assistant service and open the console.
- Go to the Watson Assistant page in the IBM Cloud Catalog
- Click Create
- Go to your Resource List and select the previously create Watson Assistant service
- Click Launch Watson Assistant to open the console
IBM divides a chatbot into assistants and skills, where assistants are the chatbots themselves and skills are the chatbot's ability to process language and respond, on the console you are able to associate a chatbot with a skill.
-
In your IBM Cloud console, select the Skills option.
-
Click Create Skill.
-
Select Dialog skill and hit next.
-
Select Import skill and upload the JSON located in:
<project_root>/watson-assistant-skill/skill-Pizzaria.json -
Click Import.
-
Open the skill Pizzaria.
-
Click Options and then Webhooks.
-
Fill in the URL field with:
<YOUR HOST URL>/pizzaria/dashboard/webhook- The Node app must be published so the chatbot can send requests to it.
-
In your IBM Cloud console, select the Assistant option.
-
Click Create Assistant.
- Enter tha name and the description and hit create.
-
Select your assistant and click Add dialog skill.
-
Select the pizzaria skill.
-
Click Integrate Web Chat
- If you're using the lite plan, click Try Plus Plan, that's just for the automated WEB Integration, you can do it mannually through HTTP requests, check the Watson Assistant API docs.
-
Create an integration.
-
Save your integrationID.
-
Click Save Changes.
-
Open the file located in:
<project_root>/web-site-chatbot-example/js/init.js -
Replace the text INTEGRATION_ID with your integrationID.
-
Run the example located in:
<project_root>/web-site-chatbot-example/index.html
-
Order a pizza in the WebChat or inside the IBM Console on the Try It option.
-
Create an account on the Node app.
-
Login after you made an order, the order should be listed on the main screen of the node app.
