Chat History Server

User generated content can be stored on-premise or in a ServisBOT customer’s private cloud if required due to security or regulation. Our Chat History Server (CHS) provides secure storage of all conversations with end-users.

Technical Details

Installation Instructions

These instructions use docker run to instantiate the CHS, however you may chose to run the container using Docker Compose, Docker Swarm or Kubernetes. Additional integration may be required to run in different container management systems, please contact your customer service representative.

MySQL 8 is also chosen as the persistence layer. Additional persistence implementations may be provided at additional cost, please contact your customer service representative.

Prerequisites

  • A server with Docker installed to host the CHS application
  • An instance of MySQL running that is accessible from the CHS container
  • CHS Enabled for your organization and configured (contact customer support once your CHS is available.)

Configure the MySQL Instance

  • Create a database called sb-chat-history-server (this name can be chosen by the customer to follow their own conventions and standards)
  • Run the following SQL against the database
CREATE TABLE IF NOT EXISTS messages_v1 (
  `id` BIGINT UNIQUE NOT NULL AUTO_INCREMENT,
  `conversationId` VARCHAR(60) NOT NULL,
  `organization` VARCHAR(60) NOT NULL,
  `identity` VARCHAR(60) NOT NULL,
  `contents` JSON NOT NULL,
  `messageId` VARCHAR(60) NOT NULL,
  `timestamp` BIGINT NOT NULL,
  `sbid` VARCHAR(100) NOT NULL UNIQUE,
  PRIMARY KEY (`id`),
  INDEX `conversationId` (`conversationId`),
  INDEX `timestamp` (`timestamp`),
  INDEX `organization` (`organization`)
);
  • Note that the table name can also be customized

Get the CHS Docker Image

docker pull servisbot/chat-history-server:1.0.0

Note: It is advised that a specific version is pulled from Docker Hub to allow the customer to control updates.

Configure your environment

An environemnt file called chs.env is configured to be used with docker run

LOG_LEVEL=info
DB_HOST=my-database-instance
DB_USER=myuser
DB_PASSWORD=my-password
DB_NAME=sb-chat-history-server
DB_PORT=3306
DB_CONNECTION_LIMIT=10
  • LOG_LEVEL : set to info for standard operation, debug, warn & error also available
  • DB_HOST : The host name or IP address of the MySQL instance
  • DB_NAME : The name of the database (or schema) that the CHS will write to
  • DB_USER : The user authorized to read and write to/from DB_NAME
  • DB_PASSWORD : The password for DB_USER
  • DB_PORT : The port that the database instance is listening on
  • DB_CONNECTION_LIMIT : Connection pooling is used in the CHS, this limit the number of connections in the pool

Adjust the settings to match any alternate requirements that you have.

It is also possible to tune the Node.js runtime via

NODE_OPTIONS=--max-old-space-size=512

Initiate the Container

docker run -d -p "8080:8080" --name=sb-chs --env-file=chs.env servisbot/chat-history-server:1.0.0

Explanation :

  • -d will run the CHS container as a daemon. Remove the -d flag to in your current terminal session.
  • -p "8090:8080" will map port 8090 on the host machine to the port that the application is running on within the docker container. (The application runs on port 8080 within the CHS container)
  • --name=sb-chs this will name your container, you may prefer to leave this blank
  • --env-file=chs.env load the Environment Variables from the preconfigured file from the previous steps

Run docker ps to ensure the container is running. It is also possible to tail the logs via:

docker logs -f sb-chs

Confirm Initialization

Once you have the docker container running the main application, you can test the application / database configuration by sending a request to v1/ping. If port 8090 has been mapped as in the previous example, run the following

curl -v localhost:8090/v1/ping

If all is configured correctly, a 200 HTTP response will be returned.

Notes

  • All traffic towards the CHS from ServisBot orginates from a known set of IP Addresses, these will need to be allowed through your network infrastructure to ensure communication betwen ServisBot and the CHS.

Enabling CHS for your org

If you have purchased this add-on for ServisBOT, reach out to your customer care representative with the URL or domain where your CHS can be reached.

Testing

Once everything is configured user generated content will be persisted in your CHS instead of ServisBOT. * Test one of your bots, if you do no have one created yet, follow Getting Started Docs * Review the Chat History * Log into your mysql instance and review the data stored in the messages_v1 table