Knowledge Base

Support documentation and system guides

Getting Started
System Overview
Architecture
Key Components
Features
Chatbot Widget
Template System
N8N Workflows
Integrations
Google Sheets Setup
RAG Knowledge Base
Administration
Tenant Management
User Management
System Monitoring
Chat Logging
Password Changes
Email Updates
Technical
API Reference
Database Schema
Deployment
Troubleshooting
Getting Started

System Overview

Last updated: January 7, 2025

Conveaux is a multi-tenant AI chatbot platform that enables businesses to deploy customizable chatbots on their websites. The system provides a comprehensive suite of tools for managing chatbot behavior, integrations, and analytics.

Key Features

  • Multi-Tenant Architecture: Support for multiple independent clients with isolated data
  • Customizable Chatbot Widget: Embeddable JavaScript widget with full customization
  • Template Management: Control chatbot personality, prompts, and appearance
  • N8N Workflow Automation: Automated integrations with Slack, Email, Google Sheets
  • RAG Knowledge Base: Upload documents to enhance AI responses
  • Admin Dashboard: Comprehensive management interface
  • System Monitoring: Real-time health checks and metrics

System Status

✅ All Systems Operational
All services are running normally. Last checked:

Quick Stats

  • Total Tenants: 6 active
  • Total Workflows: 18 configured
  • Services Running: 7 Docker containers
  • Uptime: 99.9%
Technical

System Architecture

Last updated: January 7, 2025

Technology Stack

Frontend

  • Admin Interface: HTML, CSS, JavaScript (Vanilla)
  • Chatbot Widget: JavaScript (widget.js, embed.js)
  • Styling: Bootstrap 5, Custom CSS, TailwindCSS
  • Icons: Font Awesome 6

Backend

  • Application Server: Node.js with Express
  • Database: MariaDB
  • Cache: Redis
  • Vector Database: Qdrant (for RAG)
  • Object Storage: MinIO
  • Automation: N8N
  • Web Server: Nginx (reverse proxy)

Docker Services

Services:
- nginx:80,443    # Web server & SSL termination
- app:3000        # Node.js application
- mariadb:3306    # Database
- redis:6379      # Cache & sessions
- qdrant:6333     # Vector database
- minio:9000      # Object storage
- n8n:5678        # Workflow automation

File Structure

/srv/chatbot/
├── app/
│   ├── server.js              # Main application
│   ├── n8n-service.js         # N8N integration
│   ├── rate-limit-middleware.js
│   ├── public/
│   │   ├── admin-dashboard.html
│   │   ├── tenants.html
│   │   ├── template-admin.html
│   │   ├── admin-sidebar-universal.js
│   │   └── portal/
│   │       ├── widget.js      # Chatbot widget
│   │       ├── dashboard.html # Customer portal
│   │       └── integrations.html
│   └── package.json
├── docker-compose.yml
└── nginx/
    └── nginx.conf
Technical

Key Components

Last updated: January 7, 2025

1. Chatbot Widget (widget.js)

The embeddable chatbot widget that appears on client websites.

Features:

  • Toggle open/close functionality
  • Customizable colors and branding
  • Hot links (quick action buttons)
  • Auto-open capability
  • Session management
  • Rate limiting

Embed Code:

<script src="https://conveaux.io/widget.js" 
  data-tenant-id="2" 
  data-api-key="pk_xxxxx">
</script>

2. Template System

Controls chatbot behavior and appearance per tenant.

Template Fields:

  • System Prompt: AI personality and behavior instructions
  • Welcome Message: Initial greeting
  • Chat Title: Widget header text
  • Color Scheme: Primary, bot message, user message colors
  • Hot Links: Quick action buttons
  • Auto-Open: Delay before auto-opening

3. N8N Workflows

Automated integrations triggered by chat events.

Workflow Types:

  • Slack: Send messages to Slack channels
  • Email: Send email notifications
  • Google Sheets: Log conversations to spreadsheets
  • Custom Webhook: POST to any HTTP endpoint

Database Table:

tenant_workflows:
- tenant_id
- workflow_type (slack/email/sheets/webhook)
- n8n_workflow_id
- webhook_url
- workflow_status (active/inactive)
- config (JSON)
Feature

Chatbot Widget

Last updated: January 7, 2025

Overview

The chatbot widget is a JavaScript component that can be embedded on any website to provide AI-powered customer support.

Implementation

Standard Embed:

<script src="https://conveaux.io/widget.js" 
  data-tenant-id="YOUR_TENANT_ID" 
  data-api-key="YOUR_PUBLIC_KEY">
</script>

Legacy Embed (Backward Compatible):

<script src="https://conveaux.io/embed.js" 
  data-tenant-id="YOUR_TENANT_ID" 
  data-api-key="YOUR_PUBLIC_KEY">
</script>

Customization

All customization is done through the Template Management page:

  • Go to Admin Dashboard → Templates
  • Select tenant
  • Modify system prompt, colors, welcome message
  • Save changes
  • Changes apply immediately

Features

Toggle Functionality:

  • Click chat icon to open
  • Click X button to close
  • Smooth animations
  • Remembers state

Hot Links:

Quick action buttons that appear in the chat interface. Users can click these to send pre-defined messages.

Example hot links:
- "What services do you offer?"
- "What are your hours?"
- "How can I contact you?"

Auto-Open:

Automatically open the chat widget after a specified delay (e.g., 3 seconds).

Rate Limiting

  • Guest Sessions: 10 messages per minute
  • IP-Based: 100 requests per 15 minutes
  • Tenant-Based: Configurable per plan
Feature

Template System

Last updated: January 7, 2025

Overview

Templates control how the chatbot behaves and appears for each tenant. Every tenant has one template that defines their chatbot's personality, appearance, and behavior.

Template Components

1. System Prompt

The most important part of the template. This instructs the AI on how to respond.

💡 Tip: The system prompt supports detailed formatting instructions, including emoji usage, response structure, and tone guidelines.

Example System Prompt:

You are a friendly, conversational virtual assistant.

TONE & STYLE:
- Conversational and warm
- Use emojis naturally: 📌 👥 ⚙️ 💻
- Keep responses concise and scannable
- Break up text with line breaks

FORMATTING RULES:
- Start with friendly greeting
- Use emoji bullets instead of plain bullets
- Keep paragraphs short (1-2 sentences)
- End with clear next step

EXAMPLE RESPONSE:
"Hey there 👋

Of course — happy to help with that.

📌 Main point here
👥 Another key point
⚙️ Final point

What would you like to know more about?"

2. Welcome Message

The first message users see when opening the chat.

Example: "Welcome to SudoTechnical! How can I help you today?"

3. Chat Title

Appears in the widget header.

Example: "SudoTechnical Support"

4. Color Scheme

  • Primary Color: Widget theme color
  • Bot Message Color: Background for bot messages
  • User Message Color: Background for user messages

5. Hot Links

Array of quick action buttons:

[
  "What services do you offer?",
  "What are your hours?",
  "How can I contact you?",
  "Tell me about your business"
]

6. Auto-Open Settings

  • Enabled: true/false
  • Delay: milliseconds (e.g., 3000 = 3 seconds)

API Endpoint

PUT /api/template?pk=PUBLIC_KEY
Content-Type: application/json

{
  "system_prompt": "...",
  "welcome_message": "...",
  "chat_title": "...",
  "color_scheme": {
    "primaryColor": "#4f46e5",
    "botMessageColor": "#f3f4f6",
    "userMessageColor": "#4f46e5"
  },
  "hot_links": [...],
  "auto_open_enabled": true,
  "auto_open_delay": 3000
}

Database Schema

templates table:
- id
- tenant_id (FK)
- system_prompt (TEXT)
- welcome_message (VARCHAR)
- chat_title (VARCHAR)
- color_scheme (JSON)
- hot_links (JSON)
- auto_open_enabled (BOOLEAN)
- auto_open_delay (INT)
- created_at
- updated_at
Feature

N8N Workflows

Last updated: January 7, 2025

Overview

N8N workflows enable automated integrations that trigger when chat events occur. Each tenant can have multiple workflows for different integration types.

Workflow Types

1. Slack Integration

Send chat messages to a Slack channel.

Setup:

  1. Create Slack webhook at https://api.slack.com/messaging/webhooks
  2. Go to Integrations page
  3. Toggle Slack ON
  4. Paste webhook URL
  5. Click Save

Message Format:

🤖 New Chat Message

Tenant: SudoTechnical Consulting
User: How can I get started?
Bot: I'd be happy to help you get started...
Time: 2025-01-07 10:30 AM

2. Email Integration

Send email notifications for chat messages.

Setup:

  1. Go to Integrations page
  2. Toggle Email ON
  3. Enter recipient email
  4. Click Save

3. Google Sheets Integration

Log all conversations to a Google Sheet.

Setup:

  1. Create Google Sheet with headers: Timestamp, Tenant, User Message, Bot Reply, Session ID
  2. Get shareable link
  3. Go to Integrations page
  4. Toggle Sheets ON
  5. Paste sheet URL
  6. Click Save

4. Custom Webhook (Enterprise)

POST chat data to any HTTP endpoint.

Workflow Status

  • Inactive: Workflow exists but not configured
  • Active: Workflow configured and running

Database Schema

tenant_workflows table:
- id
- tenant_id (FK)
- workflow_type (slack/email/sheets/webhook)
- n8n_workflow_id (VARCHAR)
- webhook_url (VARCHAR)
- workflow_status (active/inactive)
- config (JSON)
- created_at
- updated_at

N8N Access

  • URL: http://localhost:5678
  • Username: admin
  • Password: conveaux_n8n_2024
⚠️ Note: N8N is only accessible from localhost for security. Use SSH tunnel if remote access needed.
Feature

Google Sheets Integration Setup

Last updated: January 7, 2025

Overview

Google Sheets integration allows you to automatically log chat conversations to a Google Spreadsheet. This requires authentication with your Google account.

💡 Important: Google Sheets requires OAuth authentication. You must provide your own Google credentials to enable this integration.

Authentication Options

Option 1: Service Account (Recommended)

Best for automated, server-to-server access. No user interaction needed after setup.

Advantages:

  • ✅ No token expiration issues
  • ✅ Works automatically 24/7
  • ✅ More secure for production
  • ✅ Easier to manage

Option 2: OAuth 2.0 (User Account)

Uses your personal Google account. Requires periodic re-authentication.

Advantages:

  • ✅ Access to personal Google Sheets
  • ✅ Familiar Google login flow

Disadvantages:

  • ❌ Tokens expire and need refresh
  • ❌ Requires re-authentication

Setup Instructions: Service Account (Recommended)

Step 1: Create Google Cloud Project

  1. Go to Google Cloud Console
  2. Click Select a projectNew Project
  3. Name: "Conveaux Chatbot" (or your preference)
  4. Click Create

Step 2: Enable Google Sheets API

  1. In your project, go to APIs & ServicesLibrary
  2. Search for "Google Sheets API"
  3. Click on it and click Enable

Step 3: Create Service Account

  1. Go to APIs & ServicesCredentials
  2. Click Create CredentialsService Account
  3. Service account name: "conveaux-sheets-logger"
  4. Service account ID: (auto-generated)
  5. Click Create and Continue
  6. Role: Editor (or just "Sheets Editor" if available)
  7. Click ContinueDone

Step 4: Create & Download JSON Key

  1. Click on the service account you just created
  2. Go to Keys tab
  3. Click Add KeyCreate new key
  4. Select JSON
  5. Click Create
  6. JSON file downloads automatically - SAVE THIS FILE!
⚠️ Security Warning: This JSON file contains private keys. Keep it secure and never share it publicly!

Step 5: Share Your Google Sheet

  1. Open your JSON key file
  2. Find the "client_email" field
  3. Copy the email (looks like: conveaux-sheets-logger@project-id.iam.gserviceaccount.com)
  4. Open your Google Sheet
  5. Click Share
  6. Paste the service account email
  7. Give it Editor access
  8. Uncheck "Notify people"
  9. Click Share

Step 6: Upload to Conveaux (Future Feature)

Once implemented, you'll be able to:

  1. Go to Integrations page
  2. Find Google Sheets integration
  3. Click Configure
  4. Upload your JSON key file
  5. Enter your Google Sheet URL
  6. Click Save

Current Workaround: Manual N8N Setup

Until UI is implemented:

  1. Access N8N: http://localhost:5678 (via SSH tunnel)
  2. Open the Google Sheets workflow for your tenant
  3. Click on the Google Sheets node
  4. Click Create New Credential
  5. Select Service Account
  6. Paste contents of your JSON key file
  7. Click Save
  8. Test the workflow

Troubleshooting

Error: "Insufficient Permission"

  • Verify you shared the sheet with the service account email
  • Check the service account has Editor access
  • Make sure Google Sheets API is enabled

Error: "Invalid Credentials"

  • Verify JSON file is complete and not corrupted
  • Check you're using the correct service account
  • Try creating a new key

Error: "Spreadsheet not found"

  • Verify the Sheet URL is correct
  • Check the sheet ID (part of URL between /d/ and /edit)
  • Ensure sheet is shared with service account

Sheet Format

Recommended Column Headers:

Timestamp | Tenant | User Message | Bot Reply | Session ID | RAG Used

Example Data:

2025-01-07 10:30:45 | SudoTechnical | What are your hours? | We're open Mon-Fri 9am-5pm | sess_123 | Yes

Security Best Practices

  1. Rotate Keys: Create new service account keys periodically
  2. Limit Access: Only share sheets with necessary service accounts
  3. Monitor Usage: Check Google Cloud Console for API usage
  4. Backup Sheets: Regularly export/backup your data
  5. Delete Old Keys: Remove unused service account keys

Alternative: Webhook Integration

If Google Sheets authentication is too complex, consider using:

  • Zapier: Connect via webhook → Zapier → Google Sheets
  • Make (Integromat): Similar webhook-based approach
  • Custom API: Build your own middleware service

Future Enhancements

Planned features for easier setup:

  • ✨ Upload JSON key through Integrations UI
  • ✨ OAuth flow for personal Google accounts
  • ✨ Test connection button
  • ✨ Automatic sheet creation
  • ✨ Column mapping configuration
  • ✨ Multiple sheet support
Feature

Integrations Page

Last updated: January 7, 2025

Overview

The integrations page allows tenants to configure their workflow integrations. It automatically detects the logged-in tenant and shows their available integrations.

Customer Access

Customers access integrations through their portal:

  • Login at https://conveaux.io/portal
  • Click "Integrations" in dashboard
  • Or go directly to https://conveaux.io/integrations.html

Auto-Detection

The page automatically detects the tenant by:

  1. Checking URL parameter: ?tenant=X
  2. Checking localStorage: currentTenantId
  3. Checking customer API: /api/customer/tenant

Available Integrations

By Plan:

  • Starter: Slack, Email, Google Sheets
  • Professional: Slack, Email, Google Sheets
  • Enterprise: Slack, Email, Google Sheets, Custom Webhook

Configuration Process

  1. Toggle integration ON
  2. Enter configuration (webhook URL, email, etc.)
  3. Click Save
  4. Integration becomes active immediately

API Endpoints

GET  /api/tenants/:id/workflows
POST /api/tenants/:id/workflows/:type/activate
PUT  /api/tenants/:id/workflows/:type/config
Feature

RAG Knowledge Base

Last updated: January 7, 2025

Overview

RAG (Retrieval-Augmented Generation) allows tenants to upload documents that enhance the AI's knowledge. The system processes documents, creates embeddings, and stores them in Qdrant vector database.

Supported Formats

  • PDF (.pdf)
  • Text (.txt)
  • Word (.doc, .docx)

Upload Process

  1. Go to Template Admin page
  2. Select tenant
  3. Scroll to "Knowledge Base Documents" section
  4. Click "Choose File"
  5. Select document
  6. Optionally add title
  7. Click "Upload Document"
  8. System processes and indexes document

How It Works

  1. Document uploaded via API
  2. Text extracted from document
  3. Text chunked into smaller segments
  4. Embeddings created using AI model
  5. Embeddings stored in Qdrant
  6. When user asks question, relevant chunks retrieved
  7. AI uses retrieved context to answer

API Endpoints

POST   /api/tenants/:id/knowledge/upload
GET    /api/tenants/:id/knowledge/files
DELETE /api/tenants/:id/knowledge/files/:fileId
POST   /api/tenants/:id/knowledge/init

Storage

  • Files: MinIO object storage
  • Metadata: MariaDB
  • Vectors: Qdrant
💡 Tip: Upload company documentation, FAQs, product guides, and policies to improve chatbot accuracy.
Administration

Tenant Management

Last updated: January 7, 2025

Overview

Tenants are independent clients using the Conveaux platform. Each tenant has isolated data, configurations, and customizations.

Current Tenants

  1. Demo Tenant (ID: 1)
  2. SudoTechnical Consulting (ID: 2)
  3. Octane Media LLC (ID: 3)
  4. Allanté Kitchen (ID: 4)
  5. On Target Auto (ID: 11)
  6. Shea Ashby (ID: 12)

Tenant Structure

Each tenant has:

  • ID: Unique identifier
  • Name: Company/organization name
  • Public Key: API key for widget (pk_xxxxx)
  • Template: Chatbot configuration
  • Workflows: 3-4 n8n workflows
  • Knowledge Base: Uploaded documents
  • Customers: Associated user accounts

Creating a Tenant

  1. Go to Tenants page
  2. Click "New Tenant"
  3. Enter name and email
  4. Click Save
  5. System automatically creates:
    • Public key
    • Default template
    • N8N workflows (3)
    • Knowledge base collection

Tenant Actions

  • Dashboard: View analytics
  • Template: Edit chatbot configuration
  • Workflows: Configure integrations
  • Widget Code: Get embed code
  • Edit: Update tenant info

Database Schema

tenants table:
- id (PK)
- name (VARCHAR)
- email (VARCHAR)
- public_key (VARCHAR, unique)
- created_at
- updated_at
Administration

User Management

Last updated: January 7, 2025

User Types

1. Admin Users

Full system access. Can manage all tenants, users, and system settings.

Current Admin Users:

  • admin (admin@localhost)
  • testuser (test@example.com)
  • rmose (rmose002@gmail.com)
  • travis (travis.ashby@sudotechnical.com)

Admin Capabilities:

  • View all tenants
  • Create/edit/delete tenants
  • Manage templates
  • Configure workflows
  • View system monitor
  • Manage admin users

2. Customer Users

Tenant-specific access. Can only manage their own tenant's settings.

Customer Capabilities:

  • View their dashboard
  • Edit their template
  • Configure their integrations
  • Upload knowledge documents
  • View their analytics

Creating Admin Users

  1. Go to User Management page
  2. Click "New User"
  3. Enter username, email, password
  4. Set active status
  5. Click Save

Password Reset

  1. Go to User Management
  2. Find user
  3. Click "Reset Password"
  4. Enter new password
  5. Confirm

Database Schema

admin_users table:
- id (PK)
- username (VARCHAR, unique)
- password_hash (VARCHAR)
- email (VARCHAR)
- is_active (BOOLEAN)
- created_at
- updated_at
- last_login

customers table:
- id (PK)
- tenant_id (FK)
- email (VARCHAR, unique)
- password_hash (VARCHAR)
- name (VARCHAR)
- created_at
- updated_at
Administration

System Monitoring

Last updated: January 7, 2025

Overview

The System Monitor page provides real-time health checks and metrics for all system components.

Monitored Services

Docker Containers:

  • nginx: Web server status
  • app: Node.js application
  • mariadb: Database
  • redis: Cache
  • qdrant: Vector database
  • minio: Object storage
  • n8n: Workflow automation

Application Metrics:

  • Node.js process status
  • Application logs (last 50 lines)
  • Error tracking

N8N Status:

  • Total workflows
  • Active workflows
  • Inactive workflows

Database Statistics:

  • Total tenants
  • Total customers
  • Total templates
  • Total workflows

System Resources:

  • CPU usage
  • Memory usage
  • Disk usage
  • System uptime

Auto-Refresh

The monitor page auto-refreshes every 30 seconds to show current status.

API Endpoints

GET /api/admin/system/docker-status
GET /api/admin/system/app-logs
GET /api/admin/system/n8n-status
GET /api/admin/system/db-stats
GET /api/admin/system/resources
✅ Current Status: All systems operational
Technical

API Reference

Last updated: January 7, 2025

Authentication

Admin Login:

POST /api/login
Content-Type: application/json

{
  "username": "admin",
  "password": "password"
}

Response: { "ok": true, "user": {...} }

Customer Login:

POST /api/customer/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "password"
}

Response: { "success": true, "token": "jwt_token" }

Tenant Endpoints

GET    /api/tenants              # List all tenants
GET    /api/tenants/:id          # Get tenant details
POST   /api/tenants              # Create tenant
PUT    /api/tenants/:id          # Update tenant
DELETE /api/tenants/:id          # Delete tenant

Template Endpoints

GET /api/template?pk=PUBLIC_KEY  # Get template
PUT /api/template?pk=PUBLIC_KEY  # Update template

Body:
{
  "system_prompt": "...",
  "welcome_message": "...",
  "chat_title": "...",
  "color_scheme": {...},
  "hot_links": [...],
  "auto_open_enabled": true,
  "auto_open_delay": 3000
}

Workflow Endpoints

GET  /api/tenants/:id/workflows
POST /api/tenants/:id/workflows/:type/activate
PUT  /api/tenants/:id/workflows/:type/config

Activate body:
{
  "config": {
    "webhook_url": "https://hooks.slack.com/..."
  }
}

Knowledge Base Endpoints

POST   /api/tenants/:id/knowledge/upload
GET    /api/tenants/:id/knowledge/files
DELETE /api/tenants/:id/knowledge/files/:fileId
POST   /api/tenants/:id/knowledge/init

Chat Endpoint

POST /api/chat
Content-Type: application/json

{
  "message": "User message",
  "tenantId": 2,
  "sessionId": "optional_session_id"
}

Response:
{
  "reply": "AI response",
  "sessionId": "session_id"
}

Rate Limiting

  • General: 100 requests per 15 minutes per IP
  • Chat: 10 messages per minute per session
  • Upload: 5 files per hour per tenant
Technical

Database Schema

Last updated: January 7, 2025

Core Tables

tenants

CREATE TABLE tenants (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(255) NOT NULL,
  email VARCHAR(255),
  public_key VARCHAR(50) UNIQUE NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

templates

CREATE TABLE templates (
  id INT PRIMARY KEY AUTO_INCREMENT,
  tenant_id INT NOT NULL,
  system_prompt TEXT,
  welcome_message VARCHAR(500),
  chat_title VARCHAR(100),
  color_scheme JSON,
  hot_links JSON,
  auto_open_enabled BOOLEAN DEFAULT FALSE,
  auto_open_delay INT DEFAULT 3000,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (tenant_id) REFERENCES tenants(id)
);

tenant_workflows

CREATE TABLE tenant_workflows (
  id INT PRIMARY KEY AUTO_INCREMENT,
  tenant_id INT NOT NULL,
  workflow_type VARCHAR(50) NOT NULL,
  n8n_workflow_id VARCHAR(100),
  webhook_url VARCHAR(500),
  workflow_status VARCHAR(20) DEFAULT 'inactive',
  config JSON,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (tenant_id) REFERENCES tenants(id)
);

admin_users

CREATE TABLE admin_users (
  id INT PRIMARY KEY AUTO_INCREMENT,
  username VARCHAR(100) UNIQUE NOT NULL,
  password_hash VARCHAR(255) NOT NULL,
  email VARCHAR(255),
  is_active BOOLEAN DEFAULT TRUE,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  last_login TIMESTAMP NULL
);

customers

CREATE TABLE customers (
  id INT PRIMARY KEY AUTO_INCREMENT,
  tenant_id INT NOT NULL,
  email VARCHAR(255) UNIQUE NOT NULL,
  password_hash VARCHAR(255) NOT NULL,
  name VARCHAR(255),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (tenant_id) REFERENCES tenants(id)
);

Database Connection

Host: mariadb (Docker network)
Port: 3306
Database: chatbot
User: root
Password: [stored in docker-compose.yml]

Backup Strategy

  • Automated: Daily backups via cron
  • Manual: Use mysqldump command
  • Retention: 30 days
Technical

Deployment Guide

Last updated: January 7, 2025

Current Deployment

  • Server: Linux (Ubuntu/Debian)
  • Domain: conveaux.io
  • SSL: Let's Encrypt (auto-renewal)
  • Container Runtime: Docker + Docker Compose

Directory Structure

/srv/chatbot/              # Main application directory
├── app/                   # Node.js application
│   ├── server.js
│   ├── public/           # Static files
│   └── node_modules/
├── docker-compose.yml    # Container orchestration
├── nginx/                # Nginx configuration
└── data/                 # Persistent data volumes

/var/www/public/          # Nginx web root
├── static/               # Admin pages
└── portal/               # Customer portal

Deployment Process

1. Update Application Code:

# Edit files in /srv/chatbot/app/
# Then copy to web root
sudo cp /srv/chatbot/app/public/*.html /var/www/public/static/

2. Restart Services:

# Restart Node.js app
sudo docker restart app

# Restart all services
cd /srv/chatbot
sudo docker-compose restart

# Rebuild and restart
sudo docker-compose up -d --build

3. View Logs:

# Application logs
sudo docker logs app -f

# All service logs
sudo docker-compose logs -f

# Specific service
sudo docker logs mariadb -f

Environment Variables

Stored in docker-compose.yml:

  • Database credentials
  • Redis configuration
  • N8N settings
  • MinIO access keys

SSL Certificate Renewal

# Certbot auto-renews via cron
# Manual renewal:
sudo certbot renew
sudo docker restart nginx

Backup Procedures

Database Backup:

sudo docker exec mariadb mysqldump -u root -p chatbot > backup.sql

Application Backup:

tar -czf chatbot-backup.tar.gz /srv/chatbot/app

Full System Backup:

tar -czf full-backup.tar.gz /srv/chatbot /var/www/public
Feature

Chat Logging & History

Last updated: January 7, 2025

Overview

The chat logging system automatically records all conversations between users and the AI chatbot. This provides valuable insights, enables customer support, and helps monitor chatbot performance.

What Gets Logged

Session Information:

  • Session ID: Unique identifier for each conversation
  • Tenant ID: Which client the conversation belongs to
  • User Identifier: Anonymous guest ID
  • User Agent: Browser and device information
  • IP Address: User's IP (for security/analytics)
  • Referrer URL: Page where chat was initiated
  • Message Count: Total messages in session
  • Start Time: When conversation began

Message Information:

  • Role: user, assistant, or error
  • Content: Full message text
  • Timestamp: When message was sent
  • Model Used: AI model that generated response
  • Response Time: How long it took to respond
  • RAG Usage: Whether knowledge base was used
  • RAG Sources: Which documents were referenced

Viewing Chat Logs

For Admins:

  1. Go to Chat Logs page from sidebar
  2. Select tenant from dropdown
  3. Optionally set date range
  4. Click Load Logs
  5. Click View Messages on any session

For Customers:

Customers can view their own chat logs through their portal dashboard.

Exporting Chat Logs

CSV Export:

  1. Select tenant and load logs
  2. Click Export CSV
  3. File downloads with format: TenantName_chat_logs_TIMESTAMP.csv

JSON Export:

  1. Select tenant and load logs
  2. Click Export JSON
  3. File downloads with complete data structure

Database Tables

chat_sessions:

CREATE TABLE chat_sessions (
  id INT AUTO_INCREMENT PRIMARY KEY,
  session_id VARCHAR(255) UNIQUE NOT NULL,
  tenant_id INT NOT NULL,
  user_identifier VARCHAR(255),
  user_agent TEXT,
  ip_address VARCHAR(45),
  referrer_url TEXT,
  message_count INT DEFAULT 0,
  total_tokens_used INT DEFAULT 0,
  started_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  last_activity_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

chat_messages:

CREATE TABLE chat_messages (
  id INT AUTO_INCREMENT PRIMARY KEY,
  session_id VARCHAR(255) NOT NULL,
  tenant_id INT NOT NULL,
  role VARCHAR(20) NOT NULL,
  content TEXT NOT NULL,
  metadata JSON,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

API Endpoints

GET /api/admin/chat-logs/:tenantId/sessions
GET /api/admin/chat-logs/:tenantId/sessions/:sessionId/messages
GET /api/admin/chat-logs/:tenantId/export/csv
GET /api/admin/chat-logs/:tenantId/export/json

Privacy & Compliance

💡 Privacy Note: Chat logs contain user conversations. Ensure compliance with privacy regulations (GDPR, CCPA, etc.) when storing and accessing this data.

Best Practices:

  • Inform users that conversations are logged
  • Provide data deletion upon request
  • Secure access to chat logs (admin only)
  • Regular data retention policy
  • Encrypt sensitive information

Troubleshooting

No Logs Appearing:

  • Verify tenant has had chat activity
  • Check date range filters
  • Ensure chat logging is enabled (check server.js)
  • Verify database tables exist

Check Database:

sudo docker exec mariadb mariadb -u root -p chatbot -e "SELECT tenant_id, COUNT(*) FROM chat_sessions GROUP BY tenant_id;"

Analytics Usage

Chat logs feed into the analytics dashboard to provide:

  • Total conversation count
  • Average response time
  • RAG effectiveness metrics
  • Peak usage times
  • Common questions/topics
Administration

Password Changes & Resets

Last updated: January 7, 2025

Overview

This guide covers how to change passwords for admin users and customer accounts.

Admin User Passwords

Reset Admin Password:

  1. Go to User Management page
  2. Find the admin user
  3. Click Reset Password button
  4. Enter new password
  5. Confirm password
  6. Click Save

Via API:

PUT /api/admin-users/:id/password
Content-Type: application/json

{
  "password": "new_password_here"
}

Via Database (Emergency):

# Generate password hash first (use bcrypt)
# Then update database:
sudo docker exec mariadb mariadb -u root -p chatbot -e "UPDATE admin_users SET password_hash='HASH_HERE' WHERE username='admin';"
⚠️ Security Note: Currently, passwords are stored as plain text for development. In production, ensure bcrypt hashing is enabled.

Customer Passwords

Admin Reset Customer Password:

  1. Go to User Management or customer portal
  2. Find customer account
  3. Click Reset Password
  4. Enter new password
  5. Customer will be notified (if email configured)

Via API:

POST /api/admin/customers/:customerId/reset-password
Content-Type: application/json

{
  "password": "new_password_here"
}

Customer Self-Service (Future):

Customers can reset their own passwords via:

  • Forgot password link on login page
  • Email verification link
  • Security questions

Password Requirements

Recommended Policy:

  • Minimum Length: 8 characters
  • Complexity: Mix of uppercase, lowercase, numbers, symbols
  • No Common Passwords: Avoid "password123", "admin", etc.
  • Expiration: Change every 90 days (optional)
  • History: Don't reuse last 5 passwords

Database Schema

Admin Users:

admin_users table:
- id
- username
- password_hash (VARCHAR 255)
- email
- is_active
- last_login
- created_at
- updated_at

Customers:

customers table:
- id
- tenant_id
- email
- password_hash (VARCHAR 255)
- name
- created_at
- updated_at

Security Best Practices

  1. Use Strong Passwords: Minimum 12 characters with complexity
  2. Enable 2FA: Two-factor authentication (future enhancement)
  3. Password Hashing: Always use bcrypt with salt
  4. Secure Transmission: Always use HTTPS
  5. Rate Limiting: Prevent brute force attacks
  6. Account Lockout: After 5 failed attempts
  7. Password Reset Tokens: Expire after 1 hour
  8. Audit Logging: Track all password changes

Troubleshooting

Can't Login After Password Change:

  • Verify password was saved correctly
  • Check for extra spaces in password
  • Ensure account is active: is_active = TRUE
  • Clear browser cache and cookies

Reset Admin Password (Emergency):

# Set password to "admin123" for testing
sudo docker exec mariadb mariadb -u root -p chatbot -e "UPDATE admin_users SET password_hash='admin123' WHERE username='admin';"
⚠️ Important: Change this immediately after regaining access!
Administration

Email Updates & Management

Last updated: January 7, 2025

Overview

This guide covers how to update email addresses for admin users, customers, and tenants.

Admin User Emails

Update Admin Email:

  1. Go to User Management page
  2. Find the admin user
  3. Click Edit button
  4. Update email field
  5. Click Save

Via API:

PUT /api/admin-users/:id
Content-Type: application/json

{
  "username": "admin",
  "email": "new.email@example.com",
  "is_active": true
}

Via Database:

sudo docker exec mariadb mariadb -u root -p chatbot -e "UPDATE admin_users SET email='new@example.com' WHERE username='admin';"

Customer Emails

Update Customer Email:

  1. Go to customer management
  2. Find customer account
  3. Click Edit
  4. Update email (must be unique)
  5. Save changes
⚠️ Important: Email addresses must be unique across all customers. The system will reject duplicate emails.

Via API:

PUT /api/customers/:id
Content-Type: application/json

{
  "email": "customer@example.com",
  "name": "Customer Name"
}

Tenant Emails

Update Tenant Email:

  1. Go to Tenants page
  2. Click Edit on tenant
  3. Update email field
  4. Click Save

Via API:

PUT /api/tenants/:id
Content-Type: application/json

{
  "name": "Company Name",
  "email": "contact@company.com"
}

Email Verification

Current Status:

Email verification is not currently enforced. Users can set any email address.

Future Enhancement:

  • Send verification email with token
  • User clicks link to verify
  • Account marked as verified
  • Resend verification option

Email Notifications

System Emails:

  • Welcome Email: When account created
  • Password Reset: When password changed
  • Email Change: Confirmation of email update
  • Security Alerts: Unusual login activity

Integration Emails:

Emails can be sent via N8N workflows when chat events occur. See N8N Workflows documentation.

Email Configuration

SMTP Settings (Future):

SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
SMTP_FROM=noreply@conveaux.io

Email Templates:

Email templates can be customized per tenant for:

  • Welcome messages
  • Password resets
  • Notifications
  • Reports

Troubleshooting

Email Already Exists Error:

  • Check if email is used by another user
  • Search database: SELECT * FROM customers WHERE email='email@example.com';
  • Use different email or delete duplicate

Emails Not Sending:

  • Verify SMTP configuration
  • Check spam folder
  • Verify email address is valid
  • Check server logs for errors

Find User by Email:

# Admin users
sudo docker exec mariadb mariadb -u root -p chatbot -e "SELECT * FROM admin_users WHERE email='email@example.com';"

# Customers
sudo docker exec mariadb mariadb -u root -p chatbot -e "SELECT * FROM customers WHERE email='email@example.com';"

# Tenants
sudo docker exec mariadb mariadb -u root -p chatbot -e "SELECT * FROM tenants WHERE email='email@example.com';"

Best Practices

  1. Use Business Emails: Avoid personal emails for admin accounts
  2. Keep Updated: Ensure contact emails are current
  3. Verify Ownership: Send verification emails
  4. Unique Emails: One email per account
  5. Backup Contact: Have secondary contact method
  6. Email Aliases: Use + addressing for testing (user+test@example.com)
Technical

Troubleshooting Guide

Last updated: January 7, 2025

Common Issues

1. Chatbot Widget Not Appearing

Symptoms:

Widget doesn't show on client website

Solutions:

  • Check embed code is correct
  • Verify tenant ID and public key
  • Check browser console for errors
  • Clear browser cache (Ctrl+Shift+R)
  • Verify widget.js is loading: curl https://conveaux.io/widget.js

2. Template Not Saving

Symptoms:

Changes don't persist after clicking Save

Solutions:

  • Check browser console for errors
  • Verify public key is correct
  • Test API endpoint: curl -X PUT "https://conveaux.io/api/template?pk=PUBLIC_KEY"
  • Check database connection

3. Integrations Not Working

Symptoms:

Slack/Email/Sheets not receiving messages

Solutions:

  • Verify workflow is marked as "active" in database
  • Check webhook URL is correct
  • Test webhook manually with curl
  • Check n8n workflow status: http://localhost:5678
  • Verify n8n container is running: sudo docker ps | grep n8n

4. Rate Limit Errors (429)

Symptoms:

"Too many requests" error

Solutions:

  • Wait 15 minutes for rate limit to reset
  • Restart app to clear limits: sudo docker restart app
  • Increase rate limits in server.js if needed

5. Database Connection Errors

Symptoms:

Cannot connect to database

Solutions:

  • Check MariaDB is running: sudo docker ps | grep mariadb
  • Restart database: sudo docker restart mariadb
  • Check logs: sudo docker logs mariadb
  • Verify credentials in docker-compose.yml

6. N8N Workflows Not Creating

Symptoms:

Workflows show as "mock_" IDs

Solutions:

  • Check n8n is accessible: curl http://localhost:5678/healthz
  • Create workflows manually in n8n UI
  • Update database with real workflow IDs

Service Restart Commands

# Restart single service
sudo docker restart app
sudo docker restart nginx
sudo docker restart mariadb

# Restart all services
cd /srv/chatbot
sudo docker-compose restart

# Stop and start
sudo docker-compose down
sudo docker-compose up -d

Log Locations

# Docker logs
sudo docker logs app
sudo docker logs nginx
sudo docker logs mariadb

# System logs
/var/log/nginx/access.log
/var/log/nginx/error.log

# Application logs
sudo docker logs app --tail 100 -f

Health Checks

# Application health
curl https://conveaux.io/healthz

# N8N health
curl http://localhost:5678/healthz

# Database health
sudo docker exec mariadb mysqladmin ping -p

# Redis health
sudo docker exec redis redis-cli ping
💡 Tip: Always check the System Monitor page first for a quick overview of all service statuses.