30 Minutes to Build Private AI Customer Service with OpenClaw + VPS

💡 AD: DigitalOcean $200 Free Credit (60 Days) Claim via Our Link →

When I helped a cross-border e-commerce team evaluate their customer service options, the SaaS platform they were using charged over $20 per agent seat—and stored all conversation data on third-party servers. For a business handling customer order information and after-sales records, that data compliance exposure may seem minor until it isn't.

They switched to a self-hosted VPS solution and monthly costs dropped to around $15. All data stays on their own server, answer style is fully customizable, and the system connects directly to their internal tools. This guide walks through the complete deployment process—you can be up and running in under 30 minutes.


Why self-host instead of using a SaaS customer service platform

Three core reasons drive this decision.

Data security comes first. All conversation data in a self-hosted setup is stored locally, log policies are fully configurable, and sensitive deployments can be restricted to an internal network entirely. No data sitting on a third-party platform.

The cost difference is significant. Traditional customer service SaaS platforms charge per seat—three to five agents typically runs $60–100/month before AI features. A self-hosted VPS plan costs $2–10/month, with pay-as-you-go API usage. Total monthly cost usually stays under $25.

Flexibility is complete. Connect to your CRM, ticketing system, WeCom, or DingTalk. Customize prompt behavior to match your brand voice. Change anything without waiting for a platform vendor to support it.


1. Preparation (approximately 5 minutes)

VPS requirements

ParameterMinimumRecommended
CPU1 core2 cores
RAM2GB4GB
OSUbuntu 22.04Ubuntu 22.04

2GB RAM is sufficient for API mode (connecting to OpenAI, Claude, or similar). Running a local model via Ollama requires 8GB or more.

After connecting via SSH, install the base environment:

sudo apt update && sudo apt upgrade -y
sudo apt install -y docker.io docker-compose git curl
sudo systemctl enable docker
sudo systemctl start docker

Choose your AI model approach

For most users starting out, API mode is the right call—connect to OpenAI or OpenRouter, deploy quickly, and let the API handle the compute. GPT-4o-mini costs are very low for typical customer service volumes.

If data privacy is a hard requirement and your server has sufficient RAM, running a local model via Ollama (Llama3, Qwen) means conversation data never leaves the server.


2. Deploy OpenClaw (approximately 15 minutes)

Step 1: Clone the project

git clone https://github.com/openclaw/openclaw.git
cd openclaw

Step 2: Configure environment variables

cp .env.example .env
nano .env

For API mode:

OPENAI_API_KEY=your_API_KEY
MODEL_NAME=gpt-4o-mini
PORT=3000

For OpenRouter (supports multiple models—recommended):

OPENAI_API_KEY=your_OpenRouter_KEY
OPENAI_BASE_URL=https://openrouter.ai/api/v1
MODEL_NAME=openai/gpt-4o-mini
PORT=3000

For a local model:

MODEL_NAME=ollama/llama3
OLLAMA_BASE_URL=http://localhost:11434
PORT=3000

Step 3: Start the service

docker-compose up -d

Check startup status:

docker-compose ps
docker-compose logs -f

Once the service status shows Up, open http://your_server_IP:3000 in a browser. If the chat interface loads, deployment was successful.


3. Connect your business knowledge base

Without business-specific data, you have a general chatbot—not a customer service system. This step is what makes the difference.

Option 1: Import FAQ documents

Organize product descriptions, return policies, and FAQs into Markdown or TXT files and upload them through the OpenClaw backend. Works well for smaller, clearly structured knowledge bases.

Option 2: RAG — retrieval-augmented generation (recommended)

RAG lets the AI retrieve relevant content from the knowledge base through vector search before generating a response. Accuracy is substantially better than direct document injection, and it significantly reduces the risk of the AI fabricating information that isn't in the knowledge base.

Enable RAG in .env:

ENABLE_RAG=true
EMBEDDING_MODEL=text-embedding-3-small

Option 3: System prompt constraints

Define clear boundaries in the system prompt to prevent the AI from going off-script:

You are the customer service assistant for [Company Name]. Only answer questions based on the provided knowledge base.
For anything not covered in the knowledge base, direct the user to contact human support.
Do not fabricate or guess information. Keep responses concise and professional.

4. Website integration

Simplest option: iframe embed

<iframe
  src="https://your_domain"
  width="400"
  height="600"
  style="border:none; border-radius:8px;">
</iframe>

Recommended: floating chat widget

Add a floating chat button in the bottom-right corner of your site by including the following before the closing </body> tag:

<script>
  window.OpenClawConfig = {
    serverUrl: 'https://your_domain',
    title: 'Customer Support',
    primaryColor: '#0066FF'
  };
</script>
<script src="https://your_domain/widget.js"></script>

Channel integration via API

Telegram, WeCom, and DingTalk are all supported. Add the relevant Bot Token in the OpenClaw backend channel configuration to activate each channel.


5. Security configuration (non-negotiable)

Exposing the service directly to the public internet without authentication is a serious security risk. Complete these steps before going live.

Install Nginx and Certbot:

apt install nginx certbot python3-certbot-nginx -y

Nginx configuration:

server {
    listen 80;
    server_name your_domain;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name your_domain;

    ssl_certificate /etc/letsencrypt/live/your_domain/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your_domain/privkey.pem;

    location / {
        auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/.htpasswd;
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Apply for an SSL certificate:

certbot --nginx -d your_domain

Set up access authentication:

apt install apache2-utils -y
htpasswd -c /etc/nginx/.htpasswd admin
systemctl restart nginx

Configure the firewall to block direct access to port 3000:

ufw allow 80/tcp
ufw allow 443/tcp
ufw deny 3000/tcp
ufw enable

6. Performance optimization

Enable Redis caching to reduce redundant API calls:

docker run -d --name redis --restart always redis:alpine

Configure in .env:

REDIS_URL=redis://localhost:6379
CACHE_TTL=3600

Limit context length to control API costs:

MAX_CONTEXT_LENGTH=10
MAX_TOKENS=1000

Add rate limiting to prevent API quota abuse:

RATE_LIMIT_WINDOW=60000
RATE_LIMIT_MAX=20

7. Cost reference

ItemMonthly cost
VPS (2 cores / 2GB RAM)$5–10
API usage (gpt-4o-mini, ~100 conversations/day)$1–5
Total$6–15

API costs scale with traffic. Setting a daily call limit keeps spending predictable. Using OpenRouter to route routine queries to a cheaper model and reserving a premium model for complex issues can reduce costs further.


Who this solution is right for

Independent websites and cross-border e-commerce stores with high inquiry volume, strong data privacy requirements, and the need to integrate with order management systems. SaaS startup teams that need to launch customer service quickly on a limited budget with room to scale. Technical small and medium-sized businesses that want complete control over their data and infrastructure. Organizations in regulated industries—finance, healthcare, legal—where self-hosting sensitive user data is materially more secure than a SaaS platform.


After completing this setup, you'll have an AI customer service system where all data is yours, the behavior is fully customizable, and the monthly cost stays under $15. Compared to a SaaS subscription, the initial configuration takes an extra hour or two—but in terms of long-term cost and control, the difference compounds significantly over time.

← Previous
5 things that novices are advised to do after getting a VPS

💬 Comments

150 characters left

No comments yet. Be the first!

← Back to Articles