Skip to main content
Tutorial 12 min read

OpenClaw AI Assistant Setup Guide for Developers

Step-by-step guide to deploying OpenClaw AI assistant via self-hosting or managed service. Execute commands, manage files, automate tasks from Telegram.

Originally published:

Dev.to by Jack Pascoe

Introduction

OpenClaw (formerly Clawdbot/Moltbot) represents a new paradigm in AI assistants: an autonomous agent that doesn't just chat, but executes commands, manages files, and performs research directly from your messaging app. Unlike traditional LLM interfaces that simply respond to queries, OpenClaw operates as a loop-based agent with perception, action, and feedback capabilities.

This tutorial walks you through two deployment paths: self-hosting for maximum control and privacy, or using a managed service for instant setup. By the end, you'll have your own AI assistant responding to commands via Telegram, capable of running code, managing files, and automating tasks remotely.

Learning Objectives

  • Understand OpenClaw's architecture and how loop-based agents differ from standard chatbots
  • Deploy OpenClaw using either self-hosted or managed approaches
  • Configure secure access controls and sandboxing
  • Integrate with telegram Bot API safely
  • Implement real-world automation workflows
  • Troubleshoot common deployment and runtime issues

Prerequisites

Technical Requirements

For the managed path (5-minute setup), you need:

  • A Telegram account
  • Basic familiarity with bot creation via BotFather
  • Credit card for managed service subscription (~$29/month)

For the self-hosted path (2+ hour setup), you need:

  • A Linux VPS with minimum 2 vCPU, 4GB RAM (Hetzner CX22 recommended at €4.50/month)
  • SSH access to your server
  • Basic command-line proficiency
  • OpenAI API key or compatible OpenClaw Inspector: LLM API Traffic Monitor provider
  • Understanding of Docker containers and systemd services
  • Budget for AI token usage (~$20-100/month depending on usage)

Knowledge Prerequisites

  • Basic: Telegram bot creation, JSON configuration
  • Intermediate (self-hosted): Linux system administration, Docker basics, environment variables
  • Understanding: How AI agents differ from simple chatbots (covered below)

Understanding OpenClaw Architecture

Before deployment, understanding how OpenClaw works helps you configure it properly and troubleshoot issues effectively.

The Loop-Based Agent Pattern

Traditional chatbots follow a simple request-response model. OpenClaw implements a three-phase loop:

  1. Perception Phase: Analyzes your message and inventories available tools (filesystem access, terminal commands, web browser, code execution environment)
  2. Action Phase: Spins up isolated Docker containers to execute Python/Node.js code or shell commands. This sandboxing prevents the agent from damaging your host system
  3. Feedback Phase: Reviews command output. If the initial approach fails, the agent debugs itself and iterates until task completion or maximum attempts reached

Security Model

OpenClaw's power requires careful security configuration:

  • Allowlist Enforcement: Only specified Telegram user IDs can issue commands
  • Container Isolation: All code execution happens in ephemeral Docker containers with limited filesystem access
  • Confirmation Gates: Destructive operations (file deletion, system modifications) require explicit user approval via Telegram
  • Credential Management: API keys stored in environment variables, never in message history

Step-by-Step Guide: Managed Deployment

The managed path via EasyClawd gets you running in under 5 minutes with zero server maintenance.

Step 1: Create Your Telegram Bot

Open Telegram and message @BotFather. Follow this sequence:

  1. Send /newbot
  2. Choose a display name (e.g., "My OpenClaw Assistant")
  3. Choose a unique username ending in "bot" (e.g., "myopenclaw_bot")
  4. BotFather responds with your bot token: 1234567890:ABCdefGHIjklMNOpqrsTUVwxyz

Store this token securely—it's your bot's authentication credential.

Step 2: Get Your Telegram User ID

Message @userinfobot on Telegram. It immediately replies with your numeric user ID (e.g., 987654321). This ID locks your bot so only you can control it.

Step 3: Deploy via EasyClawd

  1. Visit easyclawd.com and create an account
  2. Navigate to "New Deployment"
  3. Paste your bot token in the "Telegram Token" field
  4. Paste your user ID in the "Allowed Users" field
  5. Select your preferred AI model (GPT-4 recommended for best results)
  6. Click "Deploy" and wait 60-90 seconds for provisioning

Once deployed, message your bot on Telegram: "Hello, are you online?" It should respond within seconds, confirming successful deployment.

Step 4: Test Core Capabilities

Verify your deployment with these test commands:

  • File Management: "Create a file called test.txt with the content 'Hello World'"
  • Code Execution: "Run a Python script that calculates the first 10 Fibonacci numbers"
  • Web Research: "Search for the current price of Bitcoin on CoinGecko and format it nicely"

Each command should complete successfully, with the agent showing its work process in real-time messages.

Step-by-Step Guide: Self-Hosted Deployment

Self-hosting provides maximum control, privacy, and cost optimization for high-volume users.

Step 1: Provision Your Server

For this tutorial, we use Hetzner Cloud, but any VPS provider works:

  1. Create a CX22 instance (2 vCPU, 4GB RAM, €4.50/month)
  2. Select Ubuntu 22.04 LTS as the operating system
  3. Add your SSH key during setup
  4. Note the assigned public IP address

SSH into your server: ssh root@your.server.ip

Step 2: Run the OpenClaw Installer

OpenClaw provides an automated installer that handles dependencies:

curl -fsSL https://openclaw.io/install.sh | bash

This script performs the following:

  • Installs Node.js 22 via NodeSource repositories
  • Installs pnpm package manager
  • Installs Docker and Docker Compose
  • Clones the OpenClaw repository
  • Sets up the OpenClaw CLI in /usr/bin/openclaw

Installation takes 3-5 minutes. Verify with: openclaw --version

Step 3: Create Configuration File

OpenClaw reads configuration from ~/.openclaw/openclaw.json. Create this directory and file:

mkdir -p ~/.openclaw
cat > ~/.openclaw/openclaw.json <<'EOF'

EOF

Replace placeholders with your actual credentials. The allowFrom array should contain only your Telegram user ID (from @userinfobot).

Step 4: Configure Environment Variables

For additional security, store sensitive keys as environment variables:

cat >> ~/.bashrc <<'EOF'
export OPENCLAW_OPENAI_KEY="sk-your-key-here"
export OPENCLAW_TELEGRAM_TOKEN="your:bot:token"
EOF
source ~/.bashrc

Modify your config to reference these variables:

"apiKey": "${OPENCLAW_OPENAI_KEY}",
"token": "${OPENCLAW_TELEGRAM_TOKEN}"

Step 5: Test Manual Launch

Before creating a service, test manual startup:

openclaw gateway

You should see output indicating successful Telegram connection and Docker initialization. Message your bot on Telegram—it should respond. Press Ctrl+C to stop.

Step 6: Create Systemd Service

Make OpenClaw start automatically on boot and restart on crashes:

sudo tee /etc/systemd/system/openclaw.service <<'EOF'
[Unit]
Description=OpenClaw AI Assistant
After=network.target docker.service
Requires=docker.service

[Service]
Type=simple
User=root
WorkingDirectory=/root
ExecStart=/usr/bin/openclaw gateway
Restart=always
RestartSec=10
Environment=NODE_ENV=production
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target
EOF

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable openclaw
sudo systemctl start openclaw

Check status: sudo systemctl status openclaw. You should see "active (running)" in green.

Step 7: Monitor Logs

View real-time logs to ensure proper operation:

sudo journalctl -u openclaw -f

Send a test message to your bot and watch the logs for the processing sequence: message received, LLM query, container spawn, execution, response.

Real-World Workflow Examples

Data Scraping and Analysis

Send to your bot: "Find the current price of Bitcoin on CoinGecko, Binance, and Kraken. Calculate the average and tell me if any exchange has a price more than 2% away from the average."

OpenClaw's process:

  1. Writes a Python script using requests to query each API
  2. Executes in a container with network access
  3. Parses JSON responses
  4. Performs statistical calculations
  5. Formats results in a readable message

This replaces manual API testing, data collection, and spreadsheet work.

DevOps Emergency Response

You're away from your desk when monitoring alerts fire. Send: "Check CPU and memory usage on all Docker containers. If any container uses more than 80% memory, restart it and notify me."

OpenClaw executes: docker stats, parses output, identifies problematic containers, runs docker restart, and sends a summary. Crisis managed from your phone.

Document Processing

Attach a Word document and send: "Extract all headings and bullet points from this document. Create a Markdown summary and email it to project-team@company.com."

OpenClaw uses pandoc for conversion, formats the output, and integrates with an email service (configured via additional plugins). Complex document workflows become single-message operations.

Troubleshooting Common Issues

Bot Doesn't Respond to Messages

Symptom: Messages sent to bot receive no reply.
Diagnosis:

  1. Check service status: sudo systemctl status openclaw
  2. Verify bot token is correct in config
  3. Ensure your user ID is in the allowFrom list
  4. Check logs: sudo journalctl -u openclaw -n 50

Solution: Most commonly, user ID mismatch. Re-message @userinfobot to confirm your ID, update config, and restart: sudo systemctl restart openclaw

Docker Container Spawn Failures

Symptom: Bot responds but says "Failed to execute command" or times out.
Diagnosis:

  1. Verify Docker is running: sudo systemctl status docker
  2. Check available disk space: df -h
  3. Ensure OpenClaw user has Docker permissions: sudo usermod -aG docker root

Solution: If disk space is low (<10% free), clean up Docker: docker system prune -a -f. This removes unused images and containers.

High API Costs

Symptom: OpenAI bill is unexpectedly high.
Diagnosis: Check how often the agent iterates in feedback loops. View logs for repeated failed attempts.
Solution:

  • Set "maxIterations": 5 in config to cap retry loops
  • Switch to a cheaper model for simple tasks: "model": "gpt-3.5-turbo"
  • Implement rate limiting: "rateLimit": {"maxRequestsPerHour": 100}

Telegram Bot Ban Concerns

Symptom: Worried about account bans when using WhatsApp integration.
Solution: Don't use WhatsApp. Seriously. telegram has an official Bot API that is completely safe and approved by Telegram. WhatsApp relies on reverse-engineered libraries that violate Meta's terms of service. Multiple users report permanent phone number bans. Stick to Telegram unless you're prepared to lose your WhatsApp account.

Best Practices and Security

Access Control

Never deploy without an allowlist. Add this to your config:

"allowFrom": [123456789],
"denyUnknownUsers": true

For team deployments, add multiple user IDs but implement role-based restrictions:

"roles": {
"admin": [123456789],
"readonly": [987654321]
}

Rate Limiting and Cost Control

Implement spending guardrails:

"billing": {
"monthlyLimit": 100,
"alertThreshold": 80,
"alertRecipient": "admin@company.com"
}

This stops the agent when 80% of your $100 monthly budget is reached and sends an alert.

Audit Logging

For compliance or debugging, enable detailed logs:

"logging": {
"level": "info",
"logFile": "/var/log/openclaw/audit.log",
"includeExecutedCommands": true,
"includeModelResponses": true
}

Rotate logs weekly to prevent disk space issues:

sudo tee /etc/logrotate.d/openclaw <<'EOF'
/var/log/openclaw/.log {
weekly
rotate 4
compress
missingok
}
EOF

Backup and Recovery

Your OpenClaw configuration and conversation history are critical. Back up weekly:

#!/bin/bash
tar -czf openclaw-backup-$(date +%Y%m%d).tar.gz
~/.openclaw/openclaw.json
/var/log/openclaw/
~/.openclaw/history/
scp openclaw-backup-
.tar.gz backup-server:/backups/

Schedule via cron: 0 2 * * 0 /root/backup-openclaw.sh (runs Sundays at 2 AM).

Network Security

If your OpenClaw server needs to access internal company resources, use a VPN or SSH tunnel rather than exposing internal services to the internet. Configure OpenClaw Worker: Railway Docker Deployment network policies to restrict container internet access when not needed:

"sandbox": {
"networkMode": "internal",
"allowInternetAccess": false
}

Override per-task when web access is required.

Advanced Configuration

Custom Tool Integration

OpenClaw supports custom tools via plugins. Example: integrating with your company's internal API:

"tools": 

Now your agent can respond to: "Check if we have SKU-12345 in stock at the Dallas warehouse."

Multi-Model Strategies

Use different models for different task types to optimize costs:

"models": ,
"taskRouting": {
"simple": "fast",
"analysis": "powerful",
"codeGeneration": "coding"
}

OpenClaw automatically routes tasks to appropriate models based on complexity detection.

Performance Optimization

Container Caching

Reduce container spawn time by pre-building common environments:

docker pull openclaw/python-base:latest
docker pull openclaw/node-base:latest

Configure OpenClaw to reuse containers for sequential commands from the same conversation:

"sandbox": {
"reuseContainers": true,
"containerTTL": 3600
}

This keeps containers alive for 1 hour, dramatically improving response times for multi-step workflows.

Resource Limits

Prevent runaway processes from consuming all server resources:

"sandbox": {
"maxMemory": "2g",
"maxCPU": "2",
"timeout": 300,
"maxProcesses": 50
}

These limits ensure one task can't crash your entire server.

Monitoring and Maintenance

Health Checks

Implement automated monitoring using a simple bash script:

#!/bin/bash
if ! systemctl is-active --quiet openclaw; then
systemctl restart openclaw
curl -X POST https://hooks.slack.com/services/YOUR/WEBHOOK
-d '{"text":"OpenClaw restarted on server"}'
fi

Run via cron every 5 minutes: */5 * * * * /root/check-openclaw.sh

Metrics Collection

For production deployments, integrate with Prometheus:

"metrics": {
"enabled": true,
"port": 9090,
"endpoint": "/metrics"
}

Track request counts, average response times, error rates, and token consumption. Set up Grafana dashboards for visualization.

Cost Analysis

Self-Hosted Economics

Based on moderate usage (50 requests/day, average 1,500 tokens per request):

  • Server: Hetzner CX22 = €4.50/month
  • AI Tokens: ~1.5M tokens/month = $30/month (GPT-4 Turbo pricing)
  • Bandwidth: Typically included with VPS
  • Total: ~$35/month

For heavy users (200+ requests/day), costs scale primarily with token usage. Consider volume discounts from OpenAI or switching to self-hosted llama models to eliminate per-token costs.

Managed Service Economics

  • Base Plan: $29/month includes 50k tokens/day
  • Pro Plan: $79/month includes 200k tokens/day
  • Enterprise: Custom pricing with dedicated resources

Break-even point: If you exceed 50k tokens/day consistently, self-hosting becomes more cost-effective despite the time investment.

Next Steps and Learning Path

After completing this tutorial, expand your OpenClaw capabilities:

  1. Build Custom Tools: Create plugins for your specific workflows (database queries, CI/CD triggers, monitoring integrations)
  2. Explore Alternative Models: Test Anthropic's Claude, Google's Gemini, or self-hosted Llama 3 for cost and performance comparisons
  3. Multi-Channel Deployment: Add Slack, Discord, or Matrix channels alongside Telegram for team-wide access
  4. Voice Integration: Connect OpenClaw to Telegram voice messages using speech-to-text preprocessing
  5. Workflow Automation: Create saved "macros" for complex multi-step operations you perform frequently

Community Resources

  • Join the OpenClaw Discord community for troubleshooting and sharing workflows
  • Contribute to the GitHub repository with custom tools and improvements
  • Read the official documentation for advanced configuration options
  • Follow the OpenClaw blog for case studies and optimization techniques

Conclusion

OpenClaw transforms messaging apps into powerful remote terminals for your entire digital infrastructure. Whether you choose the 5-minute managed deployment or the 2-hour self-hosted path, you now have an AI assistant capable of executing real work—not just generating text.

The key differentiator is the feedback loop architecture. Unlike simple chatbots, OpenClaw iterates on failures, debugs its own code, and persists until tasks complete. This resilience makes it suitable for production workflows, not just experimentation.

Remember the security fundamentals: always use allowlists, enable sandbox isolation, require confirmations for destructive operations, and stick to Telegram's official Bot API. With these guardrails in place, OpenClaw becomes a force multiplier for developers, enabling genuine productivity from anywhere.

Article based on the DEV Community tutorial by Jack Pascoe, published February 2026. Visit the original at DEV.to for community discussion.

Share:

Original Source

https://dev.to/jack_pascoe/getting-started-with-openclaw-clawdbotmoltbot-a-developers-guide-to-ai-assistants-3coi

View Original

Last updated: