### Copy Example Settings for CLI Installation Source: https://doc.livehelperchat.com/docs/install Create a settings.ini file for the command-line installer by copying the example configuration. ```bash cp cli/example.settings.ini cli/settings.ini ``` -------------------------------- ### Auto Login Link Example (Subdomain Install) Source: https://doc.livehelperchat.com/docs/development/auto-login Example of an HTML anchor tag with an auto-login link for a Live Helper Chat installation on a subdomain. This example logs in a user by their username and sets the link validity to 60 seconds. ```html Login me ``` -------------------------------- ### Auto Login Link Example (Subdirectory Install) Source: https://doc.livehelperchat.com/docs/development/auto-login Example of an HTML anchor tag with an auto-login link for a Live Helper Chat installation in a subdirectory. This example logs in a user by their User ID and sets the link validity to 60 seconds. ```html Login me ``` -------------------------------- ### Install PHP Packages Source: https://doc.livehelperchat.com/docs/install List of required and recommended PHP packages for Live Helper Chat. Ensure these are installed before proceeding with the main installation. ```bash # Optional but Recommended php-phpiredis php-imap php-pecl-redis4 php-pecl-igbinary php-geos php-fpm php-opcache # Required php-json php-cli php-gd php-xml php-common php-pdo php-pecl-zip php-mysqlnd php-mbstring php php-bcmath ``` -------------------------------- ### Execute Live Helper Chat Installation via CLI Source: https://doc.livehelperchat.com/docs/install Run the command-line installer using your settings.ini file to install Live Helper Chat. ```bash php install-cli.php cli/settings.ini ``` -------------------------------- ### Set up Python Virtual Environment Source: https://doc.livehelperchat.com/docs/bot/rasa-faq Set up a Python virtual environment and install Rasa for the non-Docker installation. ```shell python3.6m -m venv ./venv source ./venv/bin/activate pip3 install -U pip pip3 install rasa # Optional, if you get some errors you can try this pip3 --use-feature=2020-resolver install rasa ``` -------------------------------- ### Install Composer Dependencies Source: https://doc.livehelperchat.com/docs/chat/automatic-translations Execute this command to install necessary dependencies for AWS translation setup. Ensure you have the latest version of Composer and a compatible composer.json file. ```bash composer install ``` -------------------------------- ### Install and Initialize Rasa Source: https://doc.livehelperchat.com/docs/bot/rasa-integration Follow these steps to set up a new Rasa project, install dependencies, and initialize a basic bot. Adapt the Python version to your system's requirements. ```bash mkdir rasa cd rasa # Adapt to your Python version python3.6m -m venv ./venv source ./venv/bin/activate pip3 install -U pip pip3 install rasa # (Optional) Try this if you encounter errors pip3 --use-feature=2020-resolver install rasa mkdir bot cd ./bot # Select 'yes' to train the initial model rasa init # Test the bot rasa shell # Start the Rasa REST API service rasa run ``` -------------------------------- ### Start Translation Command Source: https://doc.livehelperchat.com/docs/commands Starts the translation process. This command only works in the web client. ```text !translate ``` -------------------------------- ### Copy Install CLI Script Source: https://doc.livehelperchat.com/docs/install Copy the install-cli.php script to your Live Helper Chat root directory before proceeding with command-line installation. ```bash cp cli/install-cli.php install-cli.php ``` -------------------------------- ### Quick Update Commands for GitHub Installation Source: https://doc.livehelperchat.com/docs/upgrading A collection of essential commands for users who installed Live Helper Chat directly from GitHub, to pull new files, install dependencies, regenerate autoloader, update the database, and clear cache. ```bash cd var/www/lhc_web && git pull origin master ``` ```bash cd var/www/lhc_web && composer install ``` ```bash cd var/www/lhc_web && composer dump-autoload -o -a ``` ```bash cd var/www/lhc_web && php cron.php -s site_admin -c cron/util/update_database ``` ```bash cd var/www/lhc_web && php cron.php -s site_admin -c cron/util/clear_cache ``` -------------------------------- ### Full Tools Section Example for ChatGPT Source: https://doc.livehelperchat.com/docs/bot/chatgpt-responses An example of a complete 'tools' section in the ChatGPT configuration, including file search and custom function calls. ```json [ { "type": "file_search", "vector_store_ids": [""] }, { "type": "function", "name": "password_reminder", "description": "Sends a password reset link to the provided email address.", "parameters": { "type": "object", "properties": { "email": { "type": "string", "description": "The email address associated with the account." } }, "required": ["email"] } }, { "type": "function", "name": "support_price", "description": "Returns paid support price", "parameters": { "type": "object", "properties": {}, "required": [] } } ] ``` -------------------------------- ### Install Composer Dependencies Source: https://doc.livehelperchat.com/docs/install Run this command from the `lhc_web` folder to install Composer dependencies if you are using a version with mail support (v3.30v or newer). ```bash composer.phar install ``` -------------------------------- ### Test Antivirus Installation Source: https://doc.livehelperchat.com/docs/system/system-commands Tests the antivirus installation by specifying the path to a file. Replace with the actual file path. ```bash php cron.php -s site_admin -c cron/util/test_antivirus -p ``` -------------------------------- ### Docker Compose Start Command Source: https://doc.livehelperchat.com/docs/integrating/whatsapp Modify the package.json file in the cloned wa-automate-docker repository to include your webhook URL. Then, use this command to build and start the Docker container. ```bash "start": "npx @open-wa/wa-automate --in-docker -p 8002 --npm-options=--ignore-scripts -w 'https://webhook.site/7a00ac21-60f2-411e-a571-515b37b2025a'" ``` -------------------------------- ### Get Help Command Source: https://doc.livehelperchat.com/docs/commands Returns a list of all possible commands. ```text !help ``` -------------------------------- ### Start Meilisearch Container Source: https://doc.livehelperchat.com/docs/bot/meilisearch-as-rag Command to start the Meilisearch container defined in the docker-compose.yml file. ```bash docker-compose -f docker-compose.yml up -d ``` -------------------------------- ### Start a chat Source: https://doc.livehelperchat.com/docs/javascript-arguments Initiates the chat process. This is equivalent to a user clicking the 'start chat' button. ```APIDOC ## Start a chat ### Description Initiates the chat process. This is equivalent to a user clicking the 'start chat' button. ### Method JavaScript ### Endpoint N/A (JavaScript method) ### Parameters N/A ### Request Example ```javascript window.$_LHC.eventListener.emitEvent('sendChildEvent',[{'cmd' : 'startChat'}]); ``` ### Response N/A ``` -------------------------------- ### Start a Chat via JavaScript Source: https://doc.livehelperchat.com/docs/javascript-arguments Initiate a new chat session by calling `window.$_LHC.eventListener.emitEvent('sendChildEvent',[{'cmd' : 'startChat'}])`. This simulates a user clicking the 'start chat' button. ```javascript window.$_LHC.eventListener.emitEvent('sendChildEvent',[{'cmd' : 'startChat'}]); ``` -------------------------------- ### Install Composer Dependencies Source: https://doc.livehelperchat.com/docs/chat/web-push-notifications Run this command to install or update Composer dependencies required for Web Push notifications. Ensure PHP version 7.x or higher is used. ```bash ./composer.phar update ``` -------------------------------- ### Test Antivirus Setup Source: https://doc.livehelperchat.com/docs/chat/files Execute this command to test your ClamAV antivirus setup. Replace `` with the actual path to a file you want to scan. ```bash php cron.php -s site_admin -c cron/util/test_antivirus -p ``` -------------------------------- ### Run DeepPavlov Source: https://doc.livehelperchat.com/docs/bot/sentiment-analysis Start the DeepPavlov Docker container in the foreground. ```bash docker-compose -f docker-compose.yml up ``` -------------------------------- ### Command Argument Parsing Example Source: https://doc.livehelperchat.com/docs/commands Demonstrates how arguments are parsed and displayed when a text message is defined with placeholders for arguments. ```text 1. {args.arg_1_title} - {args.arg_1} {arg_1} 2. {args.arg_2_title} - {args.arg_2} {arg_2} 3. {args.arg_3_title} - {args.arg_3} {arg_3} 4. {args.arg_command_title} - Command name ``` -------------------------------- ### Text Matching Examples Source: https://doc.livehelperchat.com/docs/bot/triggers These examples show user messages that would be matched by the 'parcel*' text matching rule. ```text parcel parcels ``` -------------------------------- ### CLI Installation Configuration Source: https://doc.livehelperchat.com/docs/development/install-cli This INI file contains database and administrator settings required for the CLI installation. Ensure all sensitive information like passwords and domains are correctly configured. ```ini ; settings.ini [db] host = localhost user = user password = xxxxxxx database = livehelperchat port = 3306 [admin] AdminUsername = username AdminPassword = xxxxxxxx AdminEmail = example@domain.com AdminName = Name AdminSurname = Surname Domain = domain.com DefaultDepartament = Departament ForceVirtualHost = 0 Extensions = ApacheUserGroupName = apache ApacheUserName = apache TimeZone = UTC DefaultConfigs = [] ; You can override any default value from the lh_chat_config table this way. ; DefaultConfigs['sharing_nodejs_path'] = 'somepath' ``` -------------------------------- ### Compile Widget Wrapper Source: https://doc.livehelperchat.com/docs/development/modifying-widget Compile the widget wrapper application by navigating to its directory and running npm install and npm run build. ```bash cd lhc_web/design/defaulttheme/widget/wrapper && npm install && npm run build ``` -------------------------------- ### Install DeepPavlov and Dependencies Source: https://doc.livehelperchat.com/docs/bot/sentiment-analysis-per-message Clone the repository, pull Docker images, download and extract the sentiment model, and clean up the archive. ```shell git clone https://github.com/LiveHelperChat/sentiment-per-message cd sentiment-per-message docker-compose -f docker-compose.yml pull wget https://livehelperchat.com/var/deep_sentence_v2.tgz tar zxfv deep_sentence_v2.tgz rm -f deep_sentence_v2.tgz ``` -------------------------------- ### Chat Command Examples Source: https://doc.livehelperchat.com/docs/modules/forms Examples of using the chat command to display forms, with and without custom explanatory text. The command supports form IDs or direct URLs. ```text !modal 1 We are baking form for you! ``` ```text !modal 1 ``` ```text !modal https://example.com/iframe_url ``` -------------------------------- ### Add Extension Cronjob Source: https://doc.livehelperchat.com/docs/development/cronjob Example of how to register and run a cronjob defined within an extension. ```bash php cron.php -s site_admin -e customstatus -c cron/customcron ``` -------------------------------- ### Running Cronjobs Source: https://doc.livehelperchat.com/docs/performance These are examples of cronjob entries for running various scripts. Some include delays to manage concurrency. ```bash * * * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 5;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 10;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 15;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 20;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 25;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 30;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 35;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 40;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 45;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 50;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * sleep 55;cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/workflow > /dev/null 2>&1 ``` ```bash * * * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -e elasticsearch -c cron/cron_1m > log_1m.txt /dev/null 2>&1 ``` ```bash * * * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/departament-availability > log_dep_availability.txt /dev/null 2>&1 ``` ```bash * * * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -e elasticsearch -c cron/check_health > es_health.txt /dev/null 2>&1 ``` ```bash */5 * * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -e elasticsearch -c cron/cron > log_5m.txt /dev/null 2>&1 ``` ```bash * * * * * cd /home/lhc_web/extension/lhcphpresque/doc/resque.sh && ./resque.sh >> /dev/null 2>&1 ``` ```bash 8 */8 * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/archive > /dev/null 2>&1 ``` ```bash * * * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/notifications > /dev/null 2>&1 ``` ```bash 8 8 * * 0 cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -c cron/util/maintain_database > /dev/null 2>&1 ``` ```bash 40 7 * * * /bin/touch /home/lhc_web/runresque.lock > /dev/null 2>&1 ``` ```bash 10 */8 * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -e elasticsearch -c cron/index_precreate >> precreate.txt /dev/null 2>&1 ``` ```bash * * * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -e fbmessenger -c cron/schedule_compaign > /dev/null 2>&1 ``` ```bash * * * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -e fbmessenger -c cron/collect_recipients > /dev/null 2>&1 ``` ```bash * * * * * cd /home/lhc_web && /usr/bin/php cron.php -s site_admin -e fbmessenger -c cron/send_notification > /dev/null 2>&1 ``` -------------------------------- ### Handling Static Files Source: https://doc.livehelperchat.com/docs/development/common-classes Get web paths for static files, and generate URLs for compressed CSS and JavaScript files. ```php // Returns the web path to the specified folder/file erLhcoreClassDesign::design('js/widgetv2'); // Compresses and returns the URL to the compressed CSS erLhcoreClassDesign::designCSS('css/widgetv2/embed.css;css/widgetv2/embed_override.css'); // Compresses and returns the URL to the compressed JS erLhcoreClassDesign::designJS('js/admintheme.form.angular.js') ``` -------------------------------- ### Run DeepPavlov for FAQ Server Setup Source: https://doc.livehelperchat.com/docs/bot/deeppavlov-faq Clones the DeepPavlov FAQ repository, navigates into it, and builds/starts the Docker containers. Users can edit `Dockerfiles/deep/train/file.csv` to add custom data before building. ```bash git clone https://github.com/LiveHelperChat/faq-deeppavlov.git cd faq-deeppavlov # You can edit `Dockerfiles/deep/train/file.csv` and add your data. docker-compose -f docker-compose.yml build docker-compose -f docker-compose.yml up ``` -------------------------------- ### Year Field Example Source: https://doc.livehelperchat.com/docs/modules/forms Generates a combobox for selecting a year, with options to specify the starting and ending years. ```text [[input||type=year||from=1911||name=BirthYear||name_literal=Birth year||required=required]] ``` -------------------------------- ### Trigger Chat Started Event Source: https://doc.livehelperchat.com/docs/hooks This hook is executed when a new chat session is initiated. It can be used for initial chat setup or analytics. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_started', array( ``` -------------------------------- ### Trigger chat.webhook_incoming_chat_started Hook Source: https://doc.livehelperchat.com/docs/hooks This hook is triggered when an incoming chat, received via webhook, is started. It can be used for initial setup or logging. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.webhook_incoming_chat_started', array( ``` -------------------------------- ### Get User Information Command Source: https://doc.livehelperchat.com/docs/commands Returns all available information about the user. This is useful in XMPP clients to know more about a visitor. ```text !info ``` -------------------------------- ### Run Rasa Docker Container Once Source: https://doc.livehelperchat.com/docs/bot/rasa-integration-intent Run the Rasa Docker container once to perform initial setup or testing. This command starts the container in the foreground. ```bash docker-compose up ``` -------------------------------- ### Embed Google Analytics Tracking in Widget Source: https://doc.livehelperchat.com/docs/google-analytics Example of an embed code for Live Helper Chat that includes Google Analytics event tracking for the start chat action. ```javascript ``` -------------------------------- ### Build New Frontend Widget V2 (Wrapper) Source: https://doc.livehelperchat.com/docs/development/quick-guide Navigate to the wrapper app directory and run these commands to install dependencies and build the new widget V2 (frontend) ReactJS application. ```bash cd lhc_web/design/defaulttheme/widget/wrapper && npm install && npm run build ``` -------------------------------- ### Show Form using a Button in Pre-chat HTML Source: https://doc.livehelperchat.com/docs/modules/forms Embed a button in your pre-chat form that, when clicked, displays a specific form. This is useful for guiding users before a chat starts. ```html ``` -------------------------------- ### Build New Frontend Widget V2 (Widget App) Source: https://doc.livehelperchat.com/docs/development/quick-guide Navigate to the widget app directory and run these commands to install dependencies and build the new widget V2 (frontend) ReactJS application. ```bash cd lhc_web/design/defaulttheme/widget/react-app && npm install && npm run build ``` -------------------------------- ### Send a message as a visitor Source: https://doc.livehelperchat.com/docs/javascript-arguments Use this function to send a message as a visitor. It handles scenarios where the chat has started or not yet started. If the chat has not started, it can prefill message fields and optionally auto-start the chat. If the chat has started, it dispatches an event to add the message. ```javascript function addMessage(message) { // Get user session var chatParams = window.$_LHC.attributes['userSession'].getSessionAttributes(); // Chat has not started yet if (!chatParams['id'] && window.$_LHC.attributes['onlineStatus'].value == true) { // Prefill message field window.$_LHC.eventListener.emitEvent('sendChildEvent',[{'cmd' : 'attr_set', 'arg' : {'type':'attr_set','attr': ['api_data'], data : {'ignore_bot' : true, 'Question' : message}}}]); /* If you want prefill multiple fields at once window.$_LHC.eventListener.emitEvent('sendChildEvent',[{'cmd' : 'attr_set', 'arg' : {'type':'attr_set','attr': ['api_data'], data : {'ignore_bot' : true, 'Username' : document.getElementById('chat-name').value, 'Email':document.getElementById('chat-email').value, 'Question':document.getElementById('chat-question').value, 'Phone' : document.getElementById('chat-phone').value}}}]);*/ /* If you have embed code with popup option you have to prefill those vars using LHCChatOptions.attr_prefill = new Array(); LHCChatOptions.attr_prefill.push({'name':'email','value': document.getElementById('chat-email').value,'hidden':true}); LHCChatOptions.attr_prefill.push({'name':'phone','value': document.getElementById('chat-phone').value}); LHCChatOptions.attr_prefill.push({'name':'username','value': document.getElementById('chat-name').value}); LHCChatOptions.attr_prefill.push({'name':'question','value': document.getElementById('chat-question').value}); */ // We change attribute to auto submit so it will try automatically submit online form first time // Uncomment if you want chat to be auto started // window.$_LHC.eventListener.emitEvent('sendChildEvent',[{'cmd' : 'attr_set', 'arg' : {'type':'attr_set','attr': ['chat_ui','auto_start'], data : true}}]); } else if (chatParams['id']) { // Send as message if chat has started alerady window.$_LHC.eventListener.emitEvent('sendChildEvent',[{'cmd' : 'dispatch_event', 'arg' : { func:'addMessage', attr: { 'id' : ['chatData','id'], 'hash' : ['chatData','hash'], 'mn' : ['chat_ui','mn'], 'theme' : ['theme'], 'lmgsid' : ['chatLiveData','lmsgid'], }, attr_params : { msg: message } }}]); } // We show a widget window.$_LHC.eventListener.emitEvent('showWidget'); } ``` -------------------------------- ### Install Rasa with 2020-resolver Feature Source: https://doc.livehelperchat.com/docs/bot/rasa-integration-intent Install Rasa using the '2020-resolver' feature, which can help resolve dependency conflicts. This is an optional step if you encounter errors during installation. ```bash pip3 --use-feature=2020-resolver install rasa ``` -------------------------------- ### Trigger Mail Conversation Started Passively Source: https://doc.livehelperchat.com/docs/hooks This hook is triggered when a mail conversation is started passively. Use this for custom actions related to passive conversation starts. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('mail.conversation_started_passive',array( ``` -------------------------------- ### Working with User Instances Source: https://doc.livehelperchat.com/docs/development/common-classes Obtain the current user instance, retrieve user data, check login status, and verify module/function access. ```php // Get the logged-in user instance erLhcoreClassUser::instance(); // Get the logged-in user model erLhcoreClassUser::instance()->getUserData(); // Check if a user is logged in erLhcoreClassUser::instance()->isLogged(); // Check if a user has permission to access a specific module and function erLhcoreClassUser::instance()->hasAccessTo('lhfront','default'); ``` -------------------------------- ### Trigger Start Chat Validation Hook Source: https://doc.livehelperchat.com/docs/hooks This hook is called during the validation process for starting a new chat. It allows for custom validation of the provided start chat data. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.validate_start_chat',array('errors' => & $Errors, 'input_form' => & $inputForm, 'start_data_fields' => & $start_data_fields, 'chat' => & $chat,'additional_params' => & $additionalParams)); ``` -------------------------------- ### Example Workflow: Main Menu Trigger Source: https://doc.livehelperchat.com/docs/bot/send-predefined-block This trigger presents the main menu options to the user and calls other triggers based on their selection. ```text Welcome! What can I help you with? [Button: Check Order Status] → Calls Trigger 200 [Button: Contact Support] → Calls Trigger 300 [Button: FAQ] → Calls Trigger 400 ``` -------------------------------- ### Set Custom Content and Start Chat Source: https://doc.livehelperchat.com/docs/javascript-arguments Set custom attributes, such as a 'Question', and then start a chat. Due to asynchronous attribute setting, a `setTimeout` is used to ensure the chat starts after the attributes are applied. ```javascript window.$_LHC.eventListener.emitEvent('sendChildEvent',[{'cmd' : 'attr_set', 'arg' : {'type':'attr_set','attr': ['api_data'], data : {'ignore_bot' : true,'Question' : 'Custom question here'}}}]); // Because attribute set is happens asynchronously you have to wait a bit before starting a chat setTimeout(function(){ window.$_LHC.eventListener.emitEvent('sendChildEvent',[{'cmd' : 'startChat'}]); },200); ``` -------------------------------- ### Initialize Rasa Project Source: https://doc.livehelperchat.com/docs/bot/rasa-integration-intent Initialize a new Rasa project in the 'intent' directory. The '--no-prompt' flag automatically accepts default settings. ```bash mkdir intent cd ./intent # Choose 'yes' to train the initial model rasa init --no-prompt ``` -------------------------------- ### Configure HTTP Server Settings Source: https://doc.livehelperchat.com/docs/nginx-configuration-tips Sets up core HTTP server directives including logging, connection handling, compression, and client body size limits. Adjust these for performance and security. ```nginx http { log_format main '$remote_addr $http_host - [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; types_hash_max_size 2048; server_tokens off; gzip on; gzip_static on; gzip_comp_level 1; gzip_min_length 0; gzip_types text/css image/x-icon image/bmp application/x-javascript application/javascript text/javascript application/json; gzip_proxied any; gzip_http_version 1.1; gzip_disable "MSIE [1-6]\."; gzip_vary on; keepalive_timeout 10 10; client_max_body_size 128m; client_body_buffer_size 128k; client_header_buffer_size 128k; large_client_header_buffers 4 64k; server_names_hash_max_size 4112; server_names_hash_bucket_size 128; # Rest of default config ``` -------------------------------- ### Mail Hook Condition Example Source: https://doc.livehelperchat.com/docs/development/webhooks Example condition for triggering a mail hook based on the message's age and status. This example targets mails older than 6 hours but not more than 7, and ensures the mail has not been responded to. ```twig {args.chat.udate} < {time} - 21600 {args.chat.udate} > {time} - 25200 {args.chat.status} != 2 ``` -------------------------------- ### Node.js Service File Configuration Source: https://doc.livehelperchat.com/docs/node-js Example systemd service file for running the NodeJS Helper as a background service. Adjust user and paths according to your environment. ```systemd [Unit] Description=Live Helper Chat NodeJS Daemon [Service] User=nodejs ExecStart=/usr/bin/forever /var/www/client/lhc_web/extension/nodejshelper/serversc/lhc/server.js LimitNOFILE=100000 [Install] WantedBy=multi-user.target ``` -------------------------------- ### Example Workflow: Contact Support Trigger Source: https://doc.livehelperchat.com/docs/bot/send-predefined-block This trigger initiates a predefined block to collect user information before transferring the chat to a human operator. ```text [Execute predefined block: Trigger 600 - Collect User Info] [Transfer to human operator] ``` -------------------------------- ### Trigger Before Cobrowse Start Source: https://doc.livehelperchat.com/docs/hooks This hook is triggered before cobrowse is started, passing the chat object and errors array by reference. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('cobrowse.before_started',array('chat' => & $Chat, 'errors' => & $errors)); ``` -------------------------------- ### Recompile Everything for Release Source: https://doc.livehelperchat.com/docs/development/quick-guide Run this command from the `lhc_web` folder to recompile all assets and prepare for a new version release. ```bash cd lhc_web/ && ./deploy.sh ``` -------------------------------- ### Build Back Office Bot Builder Application Source: https://doc.livehelperchat.com/docs/development/quick-guide Navigate to the React directory and run this command to build the ReactJS bot builder application for the back office. ```bash cd lhc_web/design/defaulttheme/js/react && npm run build ``` -------------------------------- ### Trigger Chat Started Source: https://doc.livehelperchat.com/docs/hooks This hook is triggered immediately after a chat has been successfully started. It provides the chat object and the initial message. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_started',array('chat' => & $chat, 'msg' => $messageInitial)); ``` -------------------------------- ### Trigger Chat Started Event Source: https://doc.livehelperchat.com/docs/hooks Dispatched when a new chat is successfully started. It provides access to the chat object and the initial message. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_started', array('chat' => & $chat, 'msg' => $messageInitial)); ``` -------------------------------- ### Bot Example with Conditional Button Source: https://doc.livehelperchat.com/docs/bot/conditions Shows how to conditionally display a quick reply button in a bot. The button appears only if the `bot_not_answered` condition is met. ```text bot_not_answered ``` -------------------------------- ### Initialize and Configure Meilisearch Index Source: https://doc.livehelperchat.com/docs/bot/meilisearch-as-rag Sets up a Meilisearch index, defines searchable and filterable attributes, and prepares for document ingestion. Requires a Meilisearch URL and master key. ```php echo "Creating/updating index...\n"; $indexData = [ 'uid' => $indexName, 'primaryKey' => 'id' ]; makeRequest("{$meilisearchUrl}/indexes", 'POST', $indexData, $masterKey); // Configure searchable attributes echo "Configuring searchable attributes...\n"; $searchableAttributes = ['title', 'content', 'description', 'url']; makeRequest("{$meilisearchUrl}/indexes/{$indexName}/settings/searchable-attributes", 'PUT', $searchableAttributes, $masterKey); // Configure filterable attributes echo "Configuring filterable attributes...\n"; $filterableAttributes = ['hostname', 'sitename', 'date', 'filedate', 'categories', 'tags']; makeRequest("{$meilisearchUrl}/indexes/{$indexName}/settings/filterable-attributes", 'PUT', $filterableAttributes, $masterKey); ``` -------------------------------- ### Example DeepPavlov API Response Source: https://doc.livehelperchat.com/docs/bot/sentiment-analysis-per-message This is an example of a successful response from the DeepPavlov sentiment analysis API, indicating the detected sentiment and confidence scores. ```json [ [ "negative" ], [ [ 0.0346120223402977, 0.8017117977142334, 0.023267682641744614, 0.14040860533714294 ] ] ] ``` -------------------------------- ### Build Back Office Svelte Dashboard Widgets Source: https://doc.livehelperchat.com/docs/development/quick-guide Navigate to the Svelte directory and run this command to build the Svelte dashboard widgets for the back office. ```bash cd lhc_web/design/defaulttheme/js/svelte && npm run build ``` -------------------------------- ### Webhook/Auto-responder Setup for Bot Not Replying Source: https://doc.livehelperchat.com/docs/auto-responder This setup can be used as a workaround for bot chats when the bot is not replying. It involves setting a timeout and a message for the timeout. ```text Timeout 10 [10 seconds] Message for timeout ``` ```text Timeout 20 [20 seconds] Message for timeout ``` ```text Timeout 30 [30 seconds] Message for timeout. There you can just enter nothing and choose bot trigger which would close a chat. ``` -------------------------------- ### Configure New Siteaccess Options Source: https://doc.livehelperchat.com/docs/language This snippet demonstrates how to define the configuration for a new site access, including locale, content language, default URL, and theme. ```php 'site_access_options' => array ( 'eng' => array ( 'locale' => 'en_EN', 'content_language' => 'en', 'default_url' => array ( 'module' => 'chat', 'view' => 'startchat', ), 'theme' => array ( 0 => 'customtheme', 1 => 'defaulttheme', ), ), ``` ```php 'site_access_options' => array ( 'rus' => array ( 'locale' => 'ru_RU', 'content_language' => 'ru', 'default_url' => array ( 'module' => 'chat', 'view' => 'startchat', ), 'theme' => array ( 0 => 'customtheme', 1 => 'defaulttheme', ), ), ``` -------------------------------- ### Trigger Mail Conversation Started Source: https://doc.livehelperchat.com/docs/hooks This hook is triggered when a new mail conversation is initiated. It allows for custom logic to run upon conversation start. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('mail.conversation_started',array( ``` -------------------------------- ### Trigger Mail File Verification Start Event (mailconv.file.verify_start) Source: https://doc.livehelperchat.com/docs/hooks This hook indicates that mail file verification is about to start. It passes the mail and file objects. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('mailconv.file.verify_start', array('mail' => $mail, 'chat_file' => $file)); ``` -------------------------------- ### Text Matching Rule Example Source: https://doc.livehelperchat.com/docs/bot/triggers This example demonstrates a text matching rule for a trigger event. The asterisk acts as a wildcard, matching any sequence of characters. ```text parcel* - The user's message must start with "parcel," followed by any word. ``` -------------------------------- ### Action with Query - Text and Image Source: https://doc.livehelperchat.com/assets/files/response-no-stream-e01c9bf3e61f7f209d60e48f85748af0.json Sets up an action that includes user-provided text and an image URL in its payload. This is suitable for scenarios where the user's input needs to be processed along with an attached image. ```json { "_id": "DXQtgvRV-", "type": "text", "content": { "text": "{\n \"role\": \"user\", \"content\": [\n { \"type\": \"input_text\", \"text\": {args.msg.msg} },\n {\n \"type\": \"input_image\",\n \"image_url\": {args.msg.file.file_body_embed}\n }\n\t\t\t]\n}", "attr_options": { "as_json": true, "as_system": true, "json_replace_all": false, "json_replace_args": true, "json_replace": false, "no_reparse": true } } } ``` -------------------------------- ### Trigger Chat Started Hook Source: https://doc.livehelperchat.com/docs/hooks This hook is dispatched when a new chat is successfully started. It provides the chat object and the initial message, allowing for post-start processing. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_started',array('chat' => & $chat, 'msg' => $messageInitial)); ``` -------------------------------- ### Modify Start Chat Form Source: https://doc.livehelperchat.com/docs/hooks This hook is triggered to allow modifications to the start chat form. It provides access to the result, template, parameters, and input data. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.startchat',array('result' => & $Result,'tpl' => & $tpl, 'params' => & $Params, 'inputData' => & $inputData)); ``` -------------------------------- ### Configure .htaccess for Subfolder Installation Source: https://doc.livehelperchat.com/docs/install If running Live Helper Chat in a subfolder, especially with WordPress and pretty permalinks, use these .htaccess rules to allow access. ```apache RewriteEngine On # Previous rules RewriteRule ^lhc_web/.*$ - [L] # Afterward rules ``` -------------------------------- ### Show Form Module Command Source: https://doc.livehelperchat.com/docs/commands Shows a form module with the passed ID and writes the provided explanation. The explanation is optional. You can also pass an external URL. ```text !modal ``` ```text !modal https://example.com ``` -------------------------------- ### Trigger Chat Started Event Source: https://doc.livehelperchat.com/docs/hooks This event is fired when a user starts a chat. It's useful for custom notifications or sending chat data to external services. ```php erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.chat_started', array('chat' => $chat)); ``` -------------------------------- ### Translation File Content Example Source: https://doc.livehelperchat.com/docs/language Example content of a 'translation.ts' file using the TS (Translation Source) format. This file contains context-specific messages and their translations. ```xml system/configuration Browse offers embed code Default translation changed extensioncontent/extensioncontent Only in extesnion found text Completely new context ``` -------------------------------- ### Initialize GLPI Session Source: https://doc.livehelperchat.com/assets/files/glpi-restapi-761a1fcbed65ba6f8627e4639bf45c8f.json Establishes a session with the GLPI API. Requires login credentials and an App-Token. ```APIDOC ## Initialize Session ### Description Initializes a session with the GLPI API to obtain a session token. ### Method GET ### Endpoint /apirest.php/initSession/ ### Query Parameters - **login** (string) - Required - The username for authentication. - **password** (string) - Required - The password for authentication. ### Headers - **Content-Type** (string) - Required - `application/json` - **App-Token** (string) - Required - The application token for API access. ### Response #### Success Response (200) - **SessionToken** (string) - The token representing the established session. #### Response Example ```json { "session_token": "YOUR_SESSION_TOKEN" } ``` ``` -------------------------------- ### Manual open-wa Execution Source: https://doc.livehelperchat.com/docs/integrating/whatsapp Execute this command manually to start open-wa and generate the session.data.json file after logging in from the mobile app. Ensure you replace the placeholder webhook URL with your actual URL. ```bash npx @open-wa/wa-automate -w 'https://webhook.site/7a00ac21-60f2-411e-a571-515b37b2025a' ``` -------------------------------- ### Template Rendering Source: https://doc.livehelperchat.com/docs/development/common-classes Instantiate and fetch content from templates, searching in extensions, customtheme, and defaulttheme directories. ```php // Uses the provided template. // Templates are searched through `extensions`, `customtheme`, and `defaulttheme` $tpl = erLhcoreClassTemplate::getInstance( 'lhfront/default_new.tpl.php'); $tpl->set('new_dashboard',true); $Result['content'] = $tpl->fetch(); ``` -------------------------------- ### Custom HTML for Start Chat Form (Popup) Source: https://doc.livehelperchat.com/docs/theme Use this to insert custom HTML before the start chat form fields when the chat is initiated with an operator in a popup window. ```javascript { "k": ["chat_ui","custom_html_widget"], "v" : "Custom html before start chat form fields, popup" } ``` -------------------------------- ### Nginx Server Block for LiveHelperChat Demo Source: https://doc.livehelperchat.com/docs/nginx-configuration-tips This configuration sets up a server block for a demo installation of LiveHelperChat, including listening on port 80, defining the server name, setting the document root, and configuring access logging. ```nginx # Demo install server { listen *:80; server_name demo.livehelperchat.com; root //livehelperchat_demo_com; access_log /var/log/nginx/access_demo_livehelperchat.log main; location ~* (^(?!(?:(?!(php)).)*/(albums|bin|var|lib|cache|doc|settings|pos|modules)/).*?(index\.php|upgrade\.php)$) { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param PATH_INFO $query_string; fastcgi_param SCRIPT_FILENAME //livehelperchat_demo_com/$fastcgi_script_name; } # Do not allow to hotlink full size images except our self and major search engines location ~* \.(gif|jpe?g?|png|bmp|swf|css|js|svg|otf|eot|ttf|woff|woff2|swf|mp3|map|ogg|wasm|wav|pdf|ico|txt)$ { if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; # # Custom headers and headers various browsers *should* be OK with but aren't # add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; # # Tell client that this pre-flight info is valid for 20 days # add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; } # We don't want to allow bot to load our stuff. No point... # If you are using Cloudflare or any other CDN Cache make sure you have rule so it won't cache empty. # In general I suggest do not use this in case you have CDN because of complexity it brings. if ($http_user_agent ~* "(google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|Chrome-Lighthouse)" ) { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; return 200; } if ($request_method = 'GET') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; } aio on; directio 512; expires max; root //livehelperchat_demo_com; } # This is required if you are running nodeJs extension location /socketcluster/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:8000; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } set $track_pixel "N"; if ($uri ~ /mailconv/tpx/?) { set $track_pixel "T"; } if ($http_user_agent ~* "(Google-RCS-Conversation)" ) { set $track_pixel "T"; } if ($http_user_agent ~* "(google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|Chrome-Lighthouse)" ) { set $track_pixel "${track_pixel}Y"; } location / { if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; # # Om nom nom cookies # add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; # # Custom headers and headers various browsers *should* be OK with but aren't # add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; # # Tell client that this pre-flight info is valid for 20 days # add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } ```