Running an autonomous AI agent that executes real world tasks sounds complex. With Clawdbot (OpenClaw), you can have a powerful, self-hosted assistant running in under 10 minutes.
This comprehensive guide covers everything you need to set up Clawdbot (OpenClaw) and get it running—whether on your local machine for development, a $5/month VPS for 24/7 automation, or a scalable cloud server for teams.
We will also cover Telegram bot integration, Discord webhook setup, and essential security best practices to keep your self-hosted AI agent safe.
Table of Contents
- What Is OpenClaw (Clawdbot)?
- Why Setup a Self-Hosted AI Agent?
- Prerequisites for Installation
- Method 1: Local Installation (Mac/Linux/Windows)
- Method 2: Deploy Clawdbot on a $5 VPS
- Method 3: Enterprise Cloud Deployment
- Connecting Messaging Apps (Telegram & Discord)
- Common Installation Errors & Fixes
- Security & Performance Optimization
- FAQ
- Conclusion
What Is OpenClaw (Clawdbot)?
Clawdbot, now officially maintained as OpenClaw, is an open-source autonomous AI agent framework. It bridges the gap between powerful LLMs (like Claude 3.5 Sonnet or GPT-4o) and your local system.
Unlike a standard chatbot that just talks, a self-hosted OpenClaw instance can:
- Browse the web for real-time data.
- Execute shell commands on your server.
- Manage files and git repositories.
- Trigger APIs and webhooks autonomously.
It runs entirely on your hardware, ensuring your data remains private and under your control.
Why Setup a Self-Hosted AI Agent?
Switching from a SaaS tool to a self-hosted AI bot offers three critical advantages:
- Privacy First: Your conversation history, API keys, and task logs never leave your server. You aren’t training someone else’s model.
- Cost Efficiency: Instead of a $20/month subscription, you pay only for the API tokens you use. A $5 VPS handles the hosting easily.
- Unrestricted Automation: You can install custom skills (JavaScript/Node.js) that interact with your private internal APIs, databases, or smart home devices—things a cloud chatbot can’t touch.
Prerequisites for Installation
Before starting the OpenClaw installation, ensure your environment meets these requirements:
- Node.js 22+: Required for the latest OpenClaw runtime. Check with
node -v. - Hardware: 1 CPU core, 1GB RAM minimum (2GB recommended for stable npm builds).
- Storage: 20GB SSD is sufficient for the OS alongside OpenClaw.
- Ports: Port
18789must be open for the web-based Control UI. - API Keys: An Anthropic (Claude) or OpenAI (GPT-4) API key.
- OS: macOS, Linux (Ubuntu/Debian), or Windows via WSL2.
Method 1: Local Installation (Mac/Linux/Windows)
This is the fastest method to run Clawdbot locally for testing and development.
Step 1: Install via npm
Open your terminal and run the official installer:
npm install -g openclaw@latest
Note: You can also use pnpm or bun if preferred.
Step 2: Run the Onboarding Wizard
Initialize your instance with the setup wizard:
openclaw onboard --install-daemon
This command:
- Verifies your Node.js environment.
- Prompts you for your LLM API key.
- Installs the system daemon so OpenClaw runs in the background automatically on boot.
Step 3: Verify the Setup
Open your browser and navigate to http://localhost:18789. You should see the OpenClaw Control Panel, confirming your local agent is active.
Method 2: Deploy Clawdbot on a $5 VPS
For a 24/7 AI assistant that works while your computer is off, deploying to a Virtual Private Server (VPS) is the best option. Providers like DigitalOcean, Hetzner, or Vultr offer suitable droplets for ~$5/month.
Step 1: Prepare the Server
SSH into your Ubuntu server:
ssh root@your-server-ip
Step 2: Install Node.js 22 LTS
Ubuntu repositories often have older Node versions. Install v22 explicitly:
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs build-essential
Step 3: Install & Start OpenClaw
npm install -g openclaw@latest
openclaw onboard --install-daemon
Step 4: Configure Process Management (PM2)
Use PM2 to ensure your AI bot restarts automatically if the server reboots or crashes.
npm install -g pm2
pm2 start "openclaw start" --name openclaw
pm2 save
pm2 startup
Step 5: Secure with UFW Firewall
Only allow necessary traffic. Block everything else.
sudo ufw allow 22/tcp # SSH Access
sudo ufw allow 18789/tcp # Control UI (Restrict to your IP if possible)
sudo ufw enable
Pro Tip: For production security, set up an Nginx reverse proxy with SSL (Let’s Encrypt) so you access the UI via https://agent.yourdomain.com instead of a raw IP and port.
Method 3: Enterprise Cloud Deployment
For teams installing OpenClaw on AWS, Google Cloud, or Azure, follow these DevOps best practices:
- Environment Variables: Never hardcode API keys. Inject them via your cloud provider’s secrets manager (e.g.,
CLAUDE_API_KEY). - Persistent Storage: Mount an EBS volume (AWS) or Persistent Disk (GCP) to
/var/lib/openclawto ensure agent memory survives container restarts. - Docker: While official Docker images are in progress, you can build a simple
Dockerfilebased onnode:22-alpineto containerize your agent for Kubernetes clusters.
Connecting Messaging Apps (Telegram & Discord)
Make your agent accessible from anywhere by connecting it to a Telegram bot or Discord webhook.
Telegram Integration Guide
- Open Telegram and message @BotFather.
- Send
/newbot, name your bot, and copy the HTTP API Token. - Message @userinfobot to get your personal Telegram User ID.
- In the OpenClaw UI -> Settings -> Telegram:
- Paste the Bot Token.
- Add your User ID to the “Allowed Users” list.
- Message your key bot
/startto begin.
Discord Bot Setup
- Go to the Discord Developer Portal and create a “New Application”.
- Under Bot, click “Add Bot” and copy the Token.
- Enable Message Content Intent under “Privileged Gateway Intents”.
- Generate an OAuth2 invite link with scopes:
botand permissions:Send Messages,Read Message History. - In OpenClaw UI -> Settings -> Discord, paste the token and your Server ID.
Common Installation Errors & Fixes
Error: node: command not found
- Fix: Node.js path isn’t in your
$PATH. Reinstall using thecurlcommand in Method 2 or usenvm alias default 22.
Error: EADDRINUSE 18789
- Fix: The port is taken. Find the process with
lsof -i :18789and kill it, or change the OpenClaw port in the config file.
Error: 401 Unauthorized in Telegram
- Fix: You likely forgot to add your Telegram User ID to the allowed list. The bot ignores messages from unknown users by default.
Security & Performance Optimization
API Key Security
Always check if your OpenAI/Anthropic keys have usage limits configured. An infinite loop in an autonomous agent could drain your wallet. Set a hard cap (e.g., $50/month) in the provider’s dashboard.
Preventing “Hallucinations”
In the system prompt settings, explicitly instruct the agent: “If you are unsure of a command, ask for user confirmation before executing.” This prevents accidental data loss from unchecked shell commands.
Performance Tuning
If running on a 1GB VPS, disable memory-heavy features like “local embedding generation” and rely on cloud APIs instead. Use a swap file to prevent out-of-memory crashes:
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
FAQ
Can I run Clawdbot (OpenClaw) on Windows?
Yes, using WSL2 (Windows Subsystem for Linux). Install Ubuntu from the Microsoft Store, open the WSL terminal, and follow the Linux installation steps. Native Windows support is experimental.
Is OpenClaw free to use?
The software is 100% open-source and free. You only pay for the VPS hosting (~$5/mo) and the LLM API tokens you consume.
Does it support local LLMs like Ollama?
Yes! You can configure OpenClaw to point to a local Ollama instance (e.g., http://localhost:11434) running Llama 3 or Mistral. This makes the agent completely free to run, though it requires a more powerful GPU/CPU.
How do I update my installation?
Run npm install -g openclaw@latest followed by pm2 restart openclaw. The agent preserves your database and memory across updates.
Is it safe to expose the Control UI to the internet?
Only if secured with HTTPS and strong authentication. For most users, we recommend using an SSH tunnel (ssh -L 18789:localhost:18789 user@host) to access the UI securely without opening firewall ports.
Can I install custom skills?
Yes. OpenClaw skills are written in JavaScript. You can drop .js files into the /skills directory to add custom capabilities like controlling your smart lights or querying your internal database.
Conclusion
Setting up Clawdbot (OpenClaw) transforms a standard server into an intelligent, active member of your team. Whether you choose a local setup for development or a VPS deployment for 24/7 automation, the process is straightforward and powerful.
Once your agent is running, the real fun begins: building custom skills.
If you are writing custom JavaScript skills for OpenClaw, use PlayboxJS to prototype and test your logic instantly in the browser before deploying.
Essential Tools for OpenClaw Developers:
- JSON Formatter — Debug deeply nested API responses from your agent.
- Regex Tester — Perfect your agent’s text parsing logic.
- JavaScript Minifier — Optimize your custom skill files.
- Diff Checker — Track changes in your agent’s configuration files.