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.
CHS is the combination of a node.js application and a database.
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 if this is the case.
MySQL 5.6 or greater is supported as the persistence layer. Additional persistence implementations may be provided at additional cost, please contact your customer service representative if this is the case.
ServisbotChatHistory
(this name can be chosen by the customer to follow their own conventions and standards).CREATE TABLE IF NOT EXISTS Messages (
Id BIGINT UNIQUE NOT NULL AUTO_INCREMENT,
ConversationId VARCHAR(60) NOT NULL,
Organization VARCHAR(60) NOT NULL,
Identity VARCHAR(60) NOT NULL,
Contents TEXT 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)
);
CREATE TABLE IF NOT EXISTS Interactions (
Id BIGINT UNIQUE NOT NULL AUTO_INCREMENT,
ConversationId VARCHAR(60) NOT NULL,
Organization VARCHAR(60) NOT NULL,
Identity VARCHAR(60) NOT NULL,
Contents TEXT 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: The Contents column on all tables also supports the “JSON” type.
git clone git@github.com:servisbot/servisbot-labs.git
cd servisbot-labs/sb-chat-history-server
docker build -t servisbot/chat-history-server .
An environment 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_PORT=3306
DB_CONNECTION_LIMIT=10
APP_VERSION=v1
DB_IMPLEMENTATION=MYSQL
info
for standard operation, debug
, warn
& error
also availableAdjust 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
When you pass in the version only those routes get mounted on the api. So if you pass in v1 you wont be able to hit v2.
Below is a list of the current supported versions:
The CHS API documentation is available at the root of the CHS @ /swagger/api.yml
e.g. https://mychs.com/swagger/api.yml
docker run -d -p "8080:8080" --name=sb-chs --env-file=chs.env servisbot/chat-history-server:<specific-version>
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
will 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
Once you have the docker container running the main application, you can test the application/database configuration by running sb-cli app chs-discover <ip/url>
command against that server.
Note: The logged in user must have the IT role in their organization to have access to this command.
<ip/url>
is an HTTP/HTTPS URL or IP of the CHS/about
,/persist
, and /history
endpoints by storing and retrieving some test data./about
fails, the other endpoints are not tested.Example:
sb-cli app chs-discovery http://127.0.0.1:8080
Starting CHS Discovery command
conversationId: app_conversation_id_ABCDEFG
1. Testing server route /about:
{
"ok": true,
"version": "v1",
"status": 200
}
Result: /about is working normally.
2. Testing server route /persist:
{
"status": 200,
"statusText": "OK"
}
Result: Successfully saved message 'CHS persistence test message'.
3. Testing server route /history:
{
"status" 200,
"body": [
{
"id": "app_id_ABCDEFG",
"to": "server",
"key": "TIMELINEMESSAGE:::app_conversation_id_ABCDEFG:::12345678910:::app_id_ABCDEFG",
"type": "TimelineMessage",
"version": "v2",
"contents": {
"message": "CHS persistence test message"
},
"identity": "app_identity_ABCDEFG",
"timestamp": 12345678910,
"contentType": "message",
"organization": "someorg",
"correlationId": "aBc-deFGh",
"conversationId": "app_conversation_id_ABCDEFG"
}
],
"ok": true
}
Result: The saved message has been retrieved successfully.
chs-discovery result: /about, /persist and /history are all working normally.
Finished CHS Discovery command.
Your network will need to allow incoming traffic from the machine running the chs-discovery command.
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. Once enabled you can use this URL to test the addon via sb-cli chs
commands.
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
The following IPs will need to be whitelisted for ingress in your firewall to allow communication for ServisBot.
34.248.122.125/32
52.49.224.4/32
34.231.250.115/32
52.1.103.10/32
18.192.226.131/32
3.127.31.62/32
18.223.189.202/32
3.12.195.105/32