Skip to content

Latest commit

 

History

History
235 lines (130 loc) · 13.5 KB

SHELL.md

File metadata and controls

235 lines (130 loc) · 13.5 KB

Host your Chatbot on Docker

This is the guide for preparing Bluemix and Docker environments

Download shell branch of this repository

  • Click here to download the shell branch

  • After downloading, unzip file Chatbot-shell.zip

    Unzip

Open your Terminal on macOS/Linux or cmd on Windows

  • Go to /Chatbot-shell folder under the Chatbot project root folder from the Terminal or cmd

  • Find your Terminal from macOS

    Terminal cmd
  • Find your cmd from Windows

    Command Command
  • Find your project folder, e.g. /path/to/Chatbot-shell, then run the command:

    cd /path/to/Chatbot-shell

Pull Docker image

docker pull cognitivecoe/webchatbot:latest

Environment settings

  • Update /Chatbot-shell/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 /Chatbot-shell/Docker.env.

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

    Service credentials
  • Update /Chatbot-shell/Docker.env, paste copied api_key to Docker.env

    Update Docker.env Update Docker.env

Train Visual Recognition API with the training files, get new trained classifier ID then apply it in /Chatbot-shell/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 /Chatbot-shell/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 /Chatbot-shell/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 /Chatbot-shell/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 /Chatbot-shell/Docker.env and save the file

    Update Docker.env Update Docker.env
  • 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 Service credentials
  • Paste username and password in /Chatbot-shell/Docker.env

    Update Docker.env Update Docker.env
  • Update /Chatbot-shell/Docker.env with your Blockchain service UR, 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

If you are hosting the Blockchain service locally, obtain IP address first:

  • macOS: Go to System Preferences -> Network, then copy your IP address

    IP Address IP Address
  • Windows: Refer this guide to get the IP address

  • Replace the URL with service URL (with your IP address)

    ENV APPLICATION_API_URL http://xxx.xxx.xxx.xxx:3000

Now you're ready for building the Docker image.

Build Docker image

docker run -p 8888:9080 --env-file Docker.env cognitivecoe/webchatbot

Launch

Now after getting this message The server defaultServer is ready to run a smarter planet., you can visit your Chatbot web application via:

  • macOS: http://localhost:8888/
  • Windows: Refer to Install docker on Windows 10 (5, 6) section of the doc, so the format of the URL would be like http://xxx.xxx.x.x:8888/