Chatbot IBM Cloud

The marketing team of your hotel proposes to improve its customer service by offering to book rooms with a virtual assistant. The application will record reservations in a database and analyze them on Cognos Analytics.

Examples of virtual assistants that may change:

https://www.facebook.com/PalaisDelOiseaudeJade
https://ibm-poj-4-quiet-tiger.eu-de.mybluemix.net

 

schema2020-2

Intro

  • Create the deployment diagram of the application

Part 1 – Watson Assistant

Deliverable : otelo/mission7/…

  • Create a Watson Assistant service named otelo Watson Assistant.
  • Access the launch tool.

 

watson

 

 

 

skill

 

  • Explore the interface. I used the suggestions of “Content Catalog” to build this virtual assistant.
  • Try the virtual assistant. We can test sentences with key words like joke, hello, contact, schedule and reservation.

 

try

 

  •  Modify the chatbot request with new variables to match the necessary data (dateD,dateF,idPeriod,idroom). For simplicity, we will pass the periodID and the roomID directly.correspondre aux données nécessaires (dateD,dateF,idPeriode,idchambre).

 

watsona3

 

  • create a new assistant
  • link the assistant to the previously created skill

assistantv2-2

 

Part 2 – Test of the Watson Assistant API

  • Retrieve the url and the loggins of Watson Assistant API.

assistantv2-1-1

 

  • Use a REST application like Postman to test your virtual assistant with the provided credentials

 

Method

POST


In Authorization ->Basic auth-> apikey and {your api key}


In Body -> raw -JSON-> {“input”:{“text”:”coucou”}}

  • Get a session id with a url of the form (add the variable http version)
    https://api.eu-gb.assistant.watson.cloud.ibm.com/instances/{instance id}/v2/assistants/{assistant id}/sessions?version=2019-02-28
  • Send a hello message with the number of the session obtained and a url of the form
    https://api.eu-gb.assistant.watson.cloud.ibm.com/instances/{instance id}/v2/assistants/{assistant id}/sessions/{idesssion}/message?version=2019-02-28
  • The virtual assistant replies “Hello, how can I help you?”

 

postmanv2-1

 

 

Part 3 – MySQL on IBM Cloud

Deliverable : otelo/mission7/…
Part 3 or 3 bis at your choice

  • Create a compose for Mysql service on IBM Cloud
  • Connect through Adminer to the Mysql instance with your credentials and the instance address
  • Deploy your Otelo database

 

maria3

 

 

Part 3 bis –  MariaDB on AWS

  • Create a free publicly accessible MariaDB RDS service by going to the AWS console

 

rds-2

rds2

 

  • Change the security group to allow the ip address 0.0.0.0/0 to connect. (All addresses are allowed, avoid this!)

 

maria2

 

  • Connect through Adminer to the MariaDB instance with your RDS credentials and the endpoint address.
  • Deploy your Otelo database

 

maria3

 

 

Part 4  – Local NodeJS application

Deliverable : otelo/mission7/…
Part 4, 4bis or 4 ter at your choice

 

  • Install NodeJS
  • Download the files from the repository https://gitlab.com/cherryclass/otelo
  • Modify the following variables in the app.js file.
var watsonApiKey = "";
//s'arreter avant v2
var watsonURL ="https://api.eu-gb.assistant.watson.cloud.ibm.com/instances/ba3e7f27-4e83-4906-86eb";
//assistant id
var watsonID='';

var myRDSHost ="database-2.eu-west-3.rds.amazonaws.com";
var myRDSLogin ="admin";
var myRDSPassword ="";
  • In the application directory, run npm install to deploy the necessary packages
  • Run npm start to launch the application.npm start.

 

  • Once deployed, access the application from http://localhost:3000 . You get the following interface and can test the virtual assistant. Inspect the NodeJS server console and the browser console.

 

watsonhtml

Part 4 bis – NodeJS application on IBM Cloud

Deliverable : otelo/mission7/…

 

deploy

  • Create the API Key and deploy.

 

deploiement1

  • Observe the deployment in the distribution chain

chatbot4

 

  • Failure on the deployment of the application, this is normal.

 

deploy2

 

  • Modify the following variables in the app.js file in the GIT repository of the tool chain.

var watsonApiKey = “”;
//stop before v2
var watsonURL =”https://api.eu-gb.assistant.watson.cloud.ibm.com/instances/ba3e7f27-4e83-4906-86eb”;
//assistant id
var watsonID=”;

var myRDSHost =”database-2.eu-west-3.rds.amazonaws.com”;
var myRDSLogin =”admin”;
var myRDSPassword =””;

git

 

The application automatically redeploys to GIT commit.

 

Once deployed, access the application from your dashboard.
You get the following interface and can test the virtual assistant.

 

 

watsonhtml

 

 

Optional – Command Line Deployment

 

If the previous step does not work or to discover another way to deploy your application.

Open a command prompt (CMD under windows) and connect to IBM Cloud.

bx login

In the directory containing the code, run

bx cf push

deploiement7

 

 

Optional –  Debugging – App logs

  • Install the IBM Cloud client
  • Open a command prompt (CMD in Windows) and connect to IBM Cloud.

bx login

  • Display the application logs by replacing the name of the application in the command line. In the frame, we can see the response of Watson Assistant.
    • green for nodejs
    • yellow for the assistant

bx cf logs palais-de-l-oiseau-de-jade-nodejs –recent

 

Part 4 ter – NodeJS application on AWS

 

  • Build a Ligthsail NodeJS instance on AWS

light

 

  • Connect to the instance with ssh

 

nodejs

 

 

var watsonApiKey = "";
//stop before v2
var watsonURL ="https://api.eu-gb.assistant.watson.cloud.ibm.com/instances/ba3e7f27-4e83-4906-86eb";
//assistant id
var watsonID='';

var myRDSHost ="database-2.eu-west-3.rds.amazonaws.com";
var myRDSLogin ="admin";
var myRDSPassword ="";
  • In the  /opt/bitnami/apps/myapp/htdocs directory, deploy the app.js, index.html and package.json files (you can copy and paste them, sudo nano monfichier or sudo rm monfichier)

In the application directory, run sudo npm install to deploy the necessary packages
Run npm start to launch the application.

 

Once deployed, access the application from its IP. You get the following interface and can test the virtual assistant. Inspect the NodeJS server console and the browser console.

 

watsonhtml

Part 5 – Booking registration

Deliverable : otelo/mission7/…

  • Modify the lines 214 to 240 to allow the booking registration and of the line_reservation
  • Integrate the chatbot to the Otelo website, three solutions
    • via an external url
    • by using the IBM Cloud integration (assistant->integrations->webchat-embed)
    • by integrating the HTML page (risk of CORS problem)

 

Part 6 – Cognos Analytics

  • Sign up for Cognos Analytics https://www.ibm.com/fr-fr/products/cognos-analyticsExport the reservation table from Adminer in CSV (comma)
    Import the CSV into Cognos (+ transfer a file)Note: It is possible to link a database hosted on IBM Cloud directly to Cognos Analytics. We cannot create a Mysql instance with the trial account. Also, it is not possible to connect to a database from Cognos with the trial version of Cognos.

cognos2

 

  • Use the Cognos wizard in English to generate the following charts:
    • The number of rooms booked by category
    • The number of reservations by date
    • The number of rooms booked since 1 year by date

cognos

Part 7 – Facebook Messenger

Only for an application with a domain (example http:// zorg.zh), in our case IBM Cloud.

  • Create a Facebook page dedicated to the virtual assistant.
  • Connect to Facebook Developer.
  • Add an application.
  • Add the Messenger service

 

  • Generate a token by selecting your page, accept the permissions.

 

messenger2-1

 

  • Add this token to myFacebookToken in app.js by accessing your Git repository (devOps menu). The token is dependent on the Facebook page.
  • Save the file. The application automatically redeploys when you save it. You can check the correct operation in the distribution pipeline. For AWS, restart the application.
  • Configure the webhooks, add the url of your application with /webhook at the end and check the corresponding boxes.

messenger3

 

messenger4

 

If the webhook url does not work:

  • Check that the nodeJs application is working.
  • Check that /webhook is correctly filled in at the end of the url.
  • Check that the Facebook token is registered in app.js and that the application is redeployed.

 

 

webhookerreur

webhookerreur

 

 

  • Add an image for the application.
  • Add a privacy policy URL to publish your application. https://frebourg.es/cgu

 

 

messenger9

 

 

 

 

  • The virtual assistant answers the message. You can check the logs (debugging section).
    • blue for messenger
    • green for nodejs
    • yellow for the assistant

 

facbookconsole