Skip to content

Latest commit

 

History

History
221 lines (125 loc) · 13.6 KB

VM.md

File metadata and controls

221 lines (125 loc) · 13.6 KB

Host your Chatbot on Virtual Machine

This is the guide for preparing Bluemix and Docker environments

Start Virtual Machine

  • Load and launch Virtual Machine

    Name and operating system Memory size Hard disk Start Log In Chatbot on Desktop Edit Docker.env

Environment settings

  • Update ~/Desktop/Chatbot/Docker.env with credentials
  • Please be aware of the variables of the values DO NOT HAVE quotes and between key and value there is a =, e.g. key=value
  • Good example:

     VISUAL_RECOGNITION_API_KEY=abcdefghijklmnopqrstuvwxyz12345678901234
  • Bad example

     VISUAL_RECOGNITION_API_KEY="abcdefghijklmnopqrstuvwxyz12345678901234"
  • Create Watson services

Acquire Visual Recognition service on Bluemix

  • After register the Bluemix account, then sign in

  • Go to Bluemix catalog, search Visual Recognition

    Catalog
  • Click Create button after selecting the Free plan

    Create Visual Recognition service Created Visual Recognition service

Get API key from tab of Service credentials then apply it in ~/Desktop/Chatbot/Docker.env.

  • Click on Service credentials tab, then select credential dropdown button, copy api_key

    Service credentials
  • Update ~/Desktop/Chatbot/Docker.env, paste copied api_key to Docker.env

Train Visual Recognition API with the training files, get new trained classifier ID then apply it in ~/Desktop/Chatbot/Docker.env

  • Go back to Bluemix console, go back to Manage tab then click on Visual Recognition Tool (Beta) button to launch the Visual Recognition Tool

    Tooling for Visual Recognition
  • Due to the GFW blocked the unsecured connection of Bluemix as below, use https://visual-recognition-tooling.mybluemix.net/

    Broken link Use HTTPS
  • For the first time visit of this tool, the API key is needed for authentication

    First time visit Sign in using API key
  • Then click on Create button to get started

    Tooling interface
  • You will see this page, go to next step refer to following step

    Tooling interface for training

Download training images and unzip it

Upload training images

  • Choose training zip files from /Chatbot-training folder, then choose ALL of them according to the class names including the negative sample

    Tooling for training Tooling
  • Name each of the classes

    Tooling for training Training in progress
  • Copy the classifier ID

    Trained classifier
  • Paste classifier ID in ~/Desktop/Chatbot/Docker.env

    Update Docker.env

Add other Watson services

  • Go to Bluemix catalog, search Conversation

    Search Conversation service
  • Name service as you want, and make sure there is a Credential name available then click on Create button

    Create Conversation service
  • Then you will see this page, and click on Service credentials, then copy username and password

    Conversation interface Service credentials
  • Paste username and password in ~/Desktop/Chatbot/Docker.env

    Username Password
  • Start creating a new Conversation, click on Manage menu on the left then click on Launch tool

    Conversation
  • For the first time visit of this tool, the IBM ID is needed for authentication, but as long as you've authenticated by Bluemix, it will treat you as a authorized user after clicking on the Log in with IBM ID by default. Otherwise you can try to sign in again with your Bluemix credentials

    Conversation
  • Click on Upload icon to upload the training file, to locate the training file, go to /Chatbot-training/conversation folder, find innovation-day.json file

    Conversation Upload popup Select training file Import (upload)
  • There will be one more panel named iChat, click on the menu on the top right, then select View details in order to copy workspace ID

    Created conversation workspace Workspace menu View details and copy workspace ID
  • Paste workspace ID in ~/Desktop/Chatbot/Docker.env

    Update Workspace ID
  • Go to Bluemix catalog, search Speech to Text

    Speech-to-Text
  • Name service as you want, and make sure there is a Credential name available then click on Create button

    Create Speech-to-Text service
  • Then you will see this page below, go to next step refer to following step

    Create Speech-to-Text service
  • Copy username and password, paste them to ~/Desktop/Chatbot/Docker.env and save the file

    Speech-to-Text-Username Speech-to-Text-Password
  • Go to Bluemix catalog, search Text to Speech

    Search Text to Speech
  • Then you will see this page below, go to next step refer to following step, then copy username and password

    Create Text to Speech service Text to Speech Service credentials
  • Paste username and password in ~/Desktop/Chatbot/Docker.env

    Username Password
  • Update ~/Desktop/Chatbot/Docker.env with your Blockchain service URL, replace it with actual one if you're hosting the Blockchain service on the Bluemix (refer to Blockchain practice)

    APPLICATION_API_URL=https://your_block_chain_service.mybluemix.net

  • Get IP address from the Virtual Machine

    Connection Information Connection Information
  • In Virtual Machine, replace the URL with service URL with your IP address and Blockchain service port, assume it is http://10.0.2.15:3000

    APPLICATION_API_URL=http://10.0.2.15:3000

Now you're ready for building the Docker image.

Build Docker image

  • Open the Terminal and run the Docker build command

    docker run -p 8888:9080 --env-file ~/Desktop/Chatbot/Docker.env chatbot

    Terminal

Launch

  • Wait for the message The server defaultServer is ready to run a smarter planet.

    Terminal Output
  • Now you can visit the Chatbot web application via http://10.0.2.15:8888/

    Chatbot
  • Note that the Shipping address CAN NOT be Beijing, Shanghai, Wuhan, Chengdu, Dalian, or Shenzhen as they are treated as transit. Use other cities in the world, like Tokyo, or some other locations you like.