Skip to content

Latest commit

 

History

History
249 lines (138 loc) · 13.7 KB

CHATBOT.md

File metadata and controls

249 lines (138 loc) · 13.7 KB

Host your Chatbot on Docker

This is the guide for preparing Bluemix and Docker environments

Download docker branch of this repository

  • Click here to download the docker branch

  • After downloading, unzip file Chatbot-docker.zip

    Unzip

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-docker/docker/Dockerfile.

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

    Service credentials
  • Update /Chatbot-docker/docker/Dockerfile, paste copied api_key to Dockerfile

    Update Dockerfile
  • Please be aware of the variables of the values DO NOT HAVE quotes

    • Good example:

       ENV VISUAL_RECOGNITION_API_KEY abcdefghijklmnopqrstuvwxyz12345678901234
    • Bad example

       ENV VISUAL_RECOGNITION_API_KEY "abcdefghijklmnopqrstuvwxyz12345678901234"

Train Visual Recognition API with the training files, get new trained classifier ID then apply it in /Chatbot-docker/docker/Dockerfile

  • 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-docker/docker/Dockerfile

    Update Dockerfile

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-docker/docker/Dockerfile

    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-docker/trainings/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-docker/docker/Dockerfile

    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 Dockerfile and save the file

    Update Dockerfile Update Dockerfile
  • 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-docker/docker/Dockerfile

    Update Dockerfile Update Dockerfile

Update /Chatbot-docker/docker/Dockerfile with your Blockchain service UR, replace it with actual one if you're hosting the Blockchain service on the Bluemix (refer to Blockchain practice)

ENV 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.

After installing the Docker, open Terminal on macOS or cmd on Windows

Build Docker image

  • Go to /Chatbot-docker/docker/ 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-docker/docker, then run the command:

    cd /path/to/Chatbot-docker/docker

  • To build the Docker image, run the command by tagging it as chatbot:

    docker build -t chatbot -f Dockerfile ./

Run the Docker image on a new container

  • Run the command:

    docker run -p 8888:9080 chatbot

Launch

Now you can visit your Chatbot web application via

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

Possible issues

  • If you encounter an issue like the output from Terminal or cmd as below after running the docker build command:

     Sending build context to Docker daemon  4.246MB
     Step 1/15 : FROM websphere-liberty:webProfile7
    
     Get https://registry-1.docker.io/v2/library/websphere-liberty/manifests/webProfile7: unauthorized: incorrect username or password
    
  • Please run this command:

    docker logout

Then try to re-build the Docker.