Self hosted chatbot builder installation

Requirement

  1. docker
  2. docker-compose

Installation

1. Clone project

                            
                              $  git clone https://github.com/promptchat/chatbot.git promptchat
                            
                          

or download from link:

Download zip

2. Open project directory

                                $  cd promptchat/
                            

3. Copy file variables.env.example to variables.env

                                $  cp variables.env.example variables.env
                            

4. Open variables.env file

                                $  nano variables.env
                            

5. Set values for file variables

                            
                              DB_PASSWORD=[password for database]
                              PORT=[port where site is will be hosted]
                                APP_URL=[URL where is your hosting located]
                            
                          
Using self-hosted license you need to download "license.txt" file and inject it into your hosting.

6. Build project

                            
                              $ ./run.sh
                            
                          

7. After 5 minutes open http://[YOUR_DOMAIN]:[PORT] from variables.env/

You will see page with admin's credentials to set up.

Console commands

Command Description
./build.sh Project build
./create-dump.sh Create dump to backup.sql
./down.sh Project down
./load-dump.sh Load dump from backup.sql
./run.sh Run project
./update.sh Update project version
./updateAndBuild.sh Update version and build project

Proxy configurations

Prerequisites

To get the best performance from your project installation, your proxy server should support HTTP/2. For most servers, the HTTP/2 protocol only works with HTTPS connections, which means that you need to secure your connections with a SSL/TLS certificate.

You also need to ensure that the OpenSSL library that is used by the reverse proxy server is version 1.0.2 or later. With earlier versions of OpenSSL, users connect using the legacy HTTP/1.1 specification, which lacks the performance benefits of an HTTP/2 connection.

The instructions on this page assume that these requirements are met. Use the following list to determine which server version is required to complete this setup:

Server

Minimum Version

Apache

2.4.17

NGINX

1.11.7

HTTP Strict Transport Security

We also strongly recommend that you set up your reverse proxy server to use HTTP Strict Transport Security (HSTS). This protects your installation against possible man-in-the-middle attacks, where the redirect from the HTTP to the HTTPS version of the site can be exploited to direct a user to a malicious site instead of the secure version of the original page.

The instructions for proxy server header configurations that are provided on this page include the directives that support HSTS.

Performance Optimization for Worker Connections´╗┐

You will also need to optimize the performance settings for your server to allow a sufficient number of connections to Project. These connections are required by pages that support live updates. If you have an insufficient number of connections, or are serving pages over plain HTTP, issues and agile boards that are opened in new tabs are either blank, loading, or partially loaded.

The exact values for connection-related directives varies based on server load. Use the diagnostic tools for your reverse proxy to determine whether you provide sufficient connections and adjust these values accordingly.

Configure Proxy Server Headers

To configure the headers in your proxy server, follow the guidelines that are specific to your server. Configuration guidelines for Apache HTTP Server, IIS, NGINX, and Pound are provided below.

Apache HTTP Server Configuration

To use an Apache HTTP Server as a reverse proxy, you need to run an a2enmod script and add directives to a .conf file on your server.

Requires Apache httpd version 2.4.17 or later.

To set up an Apache HTTP Server as a reverse proxy:´╗┐
  1. Use the following a2enmod script to enable the headers, rewrite, proxy_http, ssl, and modules:

                                            
                                                $ a2enmod headers
                                                $ a2enmod rewrite
                                                $ a2enmod proxy_http
                                                $ a2enmod ssl
                                                $ a2enmod http2
                                            
                                          
  2. Add the following directives to the VirtualHost section of a relevant .conf file:

                                            
                                                Protocols h2 http/1.1
    
                                                RequestHeader set X-Forwarded-Proto "https"
    
                                                RewriteEngine on
                                                AllowEncodedSlashes on
    
                                                ProxyRequests off
    
                                                ProxyPass / http:[YOUR_DOMAIN]:[PORT]/
                                                ProxyPassReverse / http:[YOUR_DOMAIN]:[PORT]/
    
                                                SSLEngine On
                                                SSLCertificateFile [path_to_certificate]
                                                SSLCertificateKeyFile [path_to_key]
                                            
                                          
  3. Set the following variables to match your Hub configuration:

    • Replace [PORT] with the actual port number taken from .variables.

    • Set the value for the [path_to_certificate] to the location of the SSL/TLS certificate for your server.

    • Set the value for the [path_to_key] to the location of the PEM-encoded private key file for the server certificate.

  4. Add the additional HSTS header to the HTTPS VirtualHost directive. Max-age is measured in seconds.

                                                # Guarantee HTTPS for 1 Year including subdomains
                                                Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
                                          

    Note that this header is only valid on a HTTPS VirtualHost

  5. Add a server-side redirect to upgrade non-HTTPS connections the first time the site is accessed. Add this to the non-HTTP VirtualHost.

                                            
                                                [...]
                                                ServerName [YOUR_DOMAIN]
                                                Redirect permanent / https://[YOUR_DOMAIN]/
                                            
                                          

For more information, refer to the documentation for the Apache Module mod_proxy

NGINX Server Configuration

The basic requirements for configuring an NGINX server as a reverse proxy consists of the following steps:

Requires NGINX version 1.11.7 or later.

To configure NGINX reverse proxy headers:
  1. Open the configuration file for your NGINX server. By default, the configuration file is named nginx.conf. The default directory is either /usr/local/nginx/conf, /etc/nginx, or /usr/local/etc/nginx.

    You can find the exact location of the configuration file by entering nginx -V in a command line interface.

  2. Increase the value for the worker_rlimit_nofile directive to a minimum value of 4096.

  3. In the events section, increase the value for the worker_connections directive to a minimum value of 2048.

  4. Update the server directive and add the proxy_set_header and proxy_pass directives in your configuration file. Use the following sample as a guide:

                                              
                                            server {
                                               listen 443 ssl http2;
    
                                                  ssl_certificate [path_to_certificate];
                                                  ssl_certificate_key [path_to_key];
    
                                                  server_name localhost;
    
                                                  add_header Strict-Transport-Security max-age=31536000;
    
                                                  location / {
                                                        proxy_set_header X-Forwarded-Host $http_host;
                                                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                                        proxy_set_header X-Forwarded-Proto $scheme;
    
                                                        client_max_body_size 10m;
    
                                                        proxy_http_version 1.1;
                                                        proxy_pass http:[YOUR_DOMAIN}:[PORT];
                                                  }
    
                                                  location /api/eventSourceBus {
                                                      proxy_cache off;
                                                      proxy_buffering off;
                                                      proxy_read_timeout 86400s;
                                                      proxy_send_timeout 86400s;
                                                      proxy_set_header Connection '';
                                                      chunked_transfer_encoding off;
    
                                                      proxy_set_header X-Forwarded-Host $http_host;
                                                      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                                      proxy_set_header X-Forwarded-Proto $scheme;
                                                      proxy_http_version 1.1;
                                                      proxy_pass http://[YOUR_DOMAIN]:[PORT];
                                                  }
                                            }
                                          
                                          
  5. Set the following variables to match your Project configuration:

    • listen 443 is the port number that you specified in the --base-url parameter.

    • proxy_pass http://[YOUR_DOMAIN]:[PORT] is the path to your Project server with the port that you specified with the --listen-port command.

  6. Save and close your configuration file.

  7. Check for errors in your NGINX configuration by stopping and starting the server with the following commands:

                                            sudo nginx -s stop
                                            sudo nginx
                                          

    Alternatively, you can reload the configuration with the following command:

                                            sudo nginx -s reload
                                          

The client_max_body_size directive defines the maximum amount of data that NGINX accepts in an HTTP request. If you don't specify a value, the default set by NGINX is 1 megabyte. We recommend that you increase the maximum to 10 megabytes to correspond to the default value.

The second location block disables buffering for connections from the agile board to support live updates. If you customize any of the common connection settings in the first location block, you should set the same custom parameters for the /api/eventSourceBus location. You can also put all of your common settings in a separate file and reference the file with an include directive. For more information, read the NGINX documentation.

If you use a Java keystore, you need to convert it to the PKCS12 format to use a NGINX server as an SSL-terminating proxy. The following procedure shows you how to convert the keystore using keytool and openssl.

Changelog

v0.4.1

19.11.2019

Templates feature

v0.4.0

19.11.2019
  • API button support
  • Minimap
  • Zoom

v0.3.6

12.11.2019

Fix no operators issue when operators are online

v0.3.5

08.11.2019

Phone number for customers

v0.3.4

08.11.2019

License integration

v0.3.3

28.10.2019

Templates loading

v0.3.2

23.10.2019

fix geo search

v0.3.1

23.10.2019

New analytic system

v0.3.0

16.10.2019
  • Added tag system for livechat
  • Autosaving for chatbot
  • Bug fixes

v0.2.50

10.10.2019

Remove top header for embed window

v0.2.49

09.10.2019

Added embed mode

v0.2.48

09.10.2019

Fixed nginx config

v0.2.47

09.10.2019

Allow superadmin login as any user

v0.2.46

09.10.2019

Initial release