Skip to main content
Tutorial 12 min read

ClawdBot Setup Guide: Self-Hosted AI Assistant Tutorial

Complete guide to setting up ClawdBot AI assistant: installation, workflows, security, and automation for professional developers. Self-hosted & powerful.

Originally published:

YouTube by Tech With Tim

Introduction

ClawdBot (also known as MoltBot) represents a breakthrough in personal AI automation—a self-hosted assistant that can manage your calendar, conduct research, draft documents, and execute complex workflows on your behalf. Unlike cloud-based solutions, ClawdBot runs on your own infrastructure, giving you complete control over your data and customization options.

This comprehensive tutorial walks you through setting up ClawdBot as a professional developer, covering everything from initial installation to advanced workflow automation. By the end, you'll have a powerful AI agent handling routine tasks while you focus on high-value development work.

Learning Objectives

By completing this tutorial, you will:

  • Deploy ClawdBot on a dedicated server or local machine with proper isolation
  • Configure secure authentication and API integrations
  • Set up practical workflows for calendar management, research automation, and document generation
  • Implement security best practices for self-hosted AI agents
  • Troubleshoot common installation and runtime issues
  • Optimize performance and reduce API costs

Prerequisites

Before beginning, ensure you have:

Technical Requirements

  • A dedicated Linux server (Ubuntu 22.04 LTS recommended) or powerful local machine
  • Minimum 8GB RAM, 50GB storage, stable internet connection
  • Root or sudo access to the server
  • Basic command-line proficiency and familiarity with Docker
  • Git installed on your system

Accounts and API Keys

  • Anthropic API account with Claude access (requires payment method)
  • Telegram account for bot interaction
  • Google Cloud account for calendar integration (optional but recommended)
  • GitHub account for accessing the ClawdBot repository

Estimated Time

Initial setup: 2-3 hours including dependency resolution. Advanced workflow configuration: Additional 1-2 hours per workflow.

Step 1: Preparing Your Environment

Choose Your Hosting Strategy

ClawdBot requires always-on infrastructure. You have three main options:

  • Dedicated home server: Lowest ongoing cost, full control, but requires static IP or dynamic DNS. Best for developers with existing homelab infrastructure.
  • Cloud VPS: Providers like DigitalOcean, Linode, or Hetzner offer $10-20/month instances. Reliable uptime, easier network configuration.
  • Spare laptop/desktop: Repurpose old hardware, but ensure it can run 24/7 without overheating. Install fresh Ubuntu Server for stability.

Initial Server Setup

Connect to your server via SSH and update the system:

sudo apt update && sudo apt upgrade -y
sudo apt install -y git docker.io docker-compose python3-pip python3-venv
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker $USER

Log out and back in for group changes to take effect. Verify Docker installation:

docker --version
docker-compose --version

Security Hardening

Create an isolated user account for ClawdBot:

sudo adduser clawdbot
sudo usermod -aG docker clawdbot
su - clawdbot

This isolation ensures that even if the bot is compromised, the damage is contained. Configure SSH key-only authentication and disable password login for production deployments.

Step 2: Installing ClawdBot

Clone the Repository

From the clawdbot user account:

cd ~
git clone https://github.com/anthropics/clawdbot.git
cd clawdbot

Examine the repository structure. Key directories include:

  • src/ - Core bot logic and workflow definitions
  • config/ - Configuration templates
  • docker/ - Container definitions for isolated execution

Configure Environment Variables

Copy the example environment file and edit it with your credentials:

cp .env.example .env
nano .env

Essential variables to configure:

ANTHROPIC_API_KEY=your_claude_api_key_here
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
TELEGRAM_ADMIN_USER_ID=your_telegram_user_id
ENCRYPTION_KEY=$(openssl rand -hex 32)
DATA_DIR=/home/clawdbot/data

The ENCRYPTION_KEY encrypts sensitive data at rest. Store this securely—losing it means losing access to encrypted credentials.

Obtain Telegram Bot Token

Open Telegram and message @BotFather:

  1. Send /newbot and follow the prompts
  2. Choose a name (displayed to users) and username (must end in 'bot')
  3. BotFather returns your token—paste it into TELEGRAM_BOT_TOKEN
  4. Send /mybots, select your bot, and disable "Group Privacy" to allow group interactions

To find your Telegram user ID, message @userinfobot and it will reply with your numeric ID. This ensures only you can control the bot.

Step 3: Configuring API Integrations

Anthropic Claude API Setup

Visit console.anthropic.com and create an API key. ClawdBot works best with Claude 3.5 Sonnet or Claude 3 Opus models for complex reasoning tasks. Budget approximately $20-50/month for moderate usage depending on workflow complexity.

Google Calendar Integration (Optional)

For calendar management workflows, you need OAuth credentials:

  1. Go to Google Cloud Console and create a new project
  2. Enable the Google Calendar API
  3. Create OAuth 2.0 credentials (Desktop app type)
  4. Download the credentials JSON and save it to config/google_credentials.json
  5. Run the initial authentication flow: python3 scripts/auth_google.py

This opens a browser for you to grant permissions. The refresh token is stored encrypted in your data directory.

Secure Credential Storage

Never commit credentials to version control. ClawdBot uses encrypted storage for API keys and tokens. Verify your .gitignore includes:

.env
*.json
data/
credentials/
__pycache__/

Step 4: Building and Running the Container

Docker Compose Deployment

ClawdBot uses Docker Compose for dependency management and isolation:

docker-compose build
docker-compose up -d

The -d flag runs containers in detached mode. Monitor initial startup logs:

docker-compose logs -f

Watch for successful initialization messages. The bot should report "Connected to Telegram" and "Ready to receive commands."

Dependency Troubleshooting

Common issues during first build:

  • Python version conflicts: ClawdBot requires Python 3.10+. If your system default is older, modify Dockerfile to use python:3.11-slim base image.
  • Missing system libraries: Add apt-get install -y build-essential libssl-dev to Dockerfile before pip install.
  • Network timeouts: Some dependencies are large. Increase Docker's timeout with COMPOSE_HTTP_TIMEOUT=200 environment variable.

Step 5: Testing Basic Functionality

First Interaction

Open Telegram and message your bot with /start. You should receive a welcome message and command list. Test basic capabilities:

  • /help - Display available commands
  • /status - Check bot health and API connectivity
  • What's the weather like today? - Test natural language understanding

ClawdBot uses Claude's natural language capabilities to interpret intent. You don't need to memorize rigid command syntax—just ask naturally.

Verify Logging

Check that logs are being written properly:

tail -f data/logs/clawdbot.log

Logs should show message processing, API calls, and response generation. This is crucial for debugging complex workflows later.

Step 6: Setting Up Calendar Management Workflow

The Permission Workaround

A clever security pattern: instead of granting ClawdBot full access to your primary calendar, it creates events on its own calendar and invites you. This limits the blast radius of potential bugs or security issues.

Configure the calendar workflow:

nano config/workflows/calendar.yaml

Example configuration:

calendar_workflow:
  enabled: true
  bot_calendar_id: clawdbot@yourproject.iam.gserviceaccount.com
  admin_email: your.email@gmail.com
  default_duration: 60
  working_hours:
    start: "09:00"
    end: "17:00"
  timezone: America/New_York

Voice Command Examples

Send these to your bot via Telegram:

  • "Schedule a 1-hour meeting with Sarah tomorrow at 2pm about Q1 planning"
  • "Block off next Friday afternoon for deep work"
  • "Find a 30-minute slot this week for a code review"

ClawdBot parses the natural language, checks your calendar for conflicts, creates the event, and sends you an invitation. You retain full control—accept or decline as needed.

Step 7: Configuring Research Automation

Reddit Market Research Workflow

This powerful workflow demonstrates ClawdBot's research capabilities. It can monitor Reddit for product feedback, synthesize discussions, and deliver actionable insights.

Install the Reddit integration:

pip install praw
cp config/integrations/reddit.yaml.example config/integrations/reddit.yaml

Create a Reddit app at reddit.com/prefs/apps to get API credentials. Configure:

reddit:
  client_id: your_client_id
  client_secret: your_client_secret
  user_agent: ClawdBot Research Agent v1.0
  subreddits:
    - programming
    - machinelearning
    - webdev

Defining Research Tasks

Create a research workflow with specific parameters:

python3 scripts/create_workflow.py research

This launches an interactive setup. Example configuration:

  • Research topic: "Developer sentiment about OpenClaw Inspector: LLM API Traffic Monitor code generation tools"
  • Time range: Past 7 days
  • Minimum post score: 10 upvotes
  • Output format: Email summary with key themes, representative quotes, and sentiment analysis

Triggering Research via Voice

Send to Telegram: "Research what developers are saying about AI code assistants on Reddit and email me a summary."

ClawdBot will:

  1. Query Reddit API for relevant discussions
  2. Extract key themes using Claude's analysis capabilities
  3. Identify representative quotes and sentiment patterns
  4. Synthesize findings into a coherent report
  5. Email you the results (requires SMTP configuration in .env)

Step 8: Document Generation Workflow

Automated Documentation

Configure ClawdBot to generate technical documentation from voice notes or brief prompts:

document_generation:
  enabled: true
  templates_dir: config/templates
  output_dir: data/generated_docs
  default_format: markdown

Example voice command: "Create API documentation for the user authentication endpoint. It accepts POST requests with email and password, returns a JWT token, and includes rate limiting at 5 requests per minute."

ClawdBot generates properly structured documentation with sections for endpoint description, request format, response format, error codes, and rate limiting details.

Troubleshooting Common Issues

Bot Not Responding

Check these systematically:

  1. Container status: docker-compose ps should show all services as "Up"
  2. Network connectivity: docker-compose exec clawdbot ping -c 3 api.telegram.org
  3. API credentials: Verify Telegram token with curl https://api.telegram.org/bot$TOKEN/getMe
  4. Logs: Check for authentication errors or rate limiting: docker-compose logs --tail=100

High API Costs

If Anthropic bills are unexpectedly high:

  • Review logs for infinite loops or repeated failed operations
  • Implement response caching for repeated queries
  • Switch to Claude 3 Haiku for simple tasks (10x cheaper than Opus)
  • Set hard limits in config/limits.yaml: max_tokens_per_day: 100000

Calendar Integration Failures

Google OAuth tokens expire. If calendar operations fail:

  1. Check token expiration: python3 scripts/check_google_auth.py
  2. Refresh manually if needed: python3 scripts/auth_google.py --refresh
  3. Verify calendar ID in configuration matches your service account

Performance and Latency

As mentioned in source material, self-hosted solutions have different latency characteristics than cloud services. Optimize with:

  • Local caching: Cache Claude responses for 24 hours for identical queries
  • Response streaming: Enable streaming mode for faster perceived response time
  • Regional API endpoints: Use the closest Anthropic API region if available

Best Practices for Production Use

Security Hardening

Once your bot is working, implement these security measures:

  • Firewall rules: Only expose necessary ports. Use UFW: sudo ufw allow 22/tcp && sudo ufw enable
  • Regular updates: Set up automatic security updates for the host OS
  • Backup encryption keys: Store ENCRYPTION_KEY in a password manager, not just .env
  • Audit logs: Enable detailed logging and review regularly for unauthorized access attempts
  • Network segmentation: Run ClawdBot on an isolated VLAN if possible

Monitoring and Maintenance

Set up basic monitoring with healthchecks.io or similar:

monitoring:
  healthcheck_url: https://hc-ping.com/your-uuid
  check_interval: 300  # seconds

ClawdBot pings this URL every 5 minutes. If pings stop, you receive an alert.

Backup Strategy

Critical data to back up regularly:

  • .env file (encrypted storage recommended)
  • data/ directory containing conversation history and cached responses
  • config/ directory with workflow definitions

Automate with a daily cron job:

0 2 * * * tar -czf ~/backups/clawdbot-$(date +\%Y\%m\%d).tar.gz ~/clawdbot/data ~/clawdbot/config

Cost Optimization

Reduce ongoing expenses:

  • Use Claude 3 Haiku for simple tasks like scheduling (save 90% vs Opus)
  • Implement intelligent task routing: simple queries to Haiku, complex research to Sonnet
  • Cache aggressively: identical queries shouldn't hit the API twice
  • Set up workflow scheduling: batch research tasks overnight when you're not waiting

Workflow Development Cycle

When creating new workflows:

  1. Start simple: Test basic functionality with minimal configuration
  2. Iterate gradually: Add complexity one feature at a time
  3. Test edge cases: What happens with invalid input? Network failures? API errors?
  4. Document thoroughly: Future you will thank present you
  5. Version control: Commit working configurations before major changes

Advanced Configuration Options

Custom Workflow Creation

ClawdBot's power comes from custom workflows. Create a new workflow template:

python3 scripts/create_workflow.py --template custom --name code_review

This generates a YAML skeleton. Define triggers, actions, and Claude prompts. Example workflow for automated code review:

code_review_workflow:
  trigger:
    type: file_watch
    path: ~/projects/*/pull_requests
  actions:
    - analyze_code:
        model: claude-3-sonnet
        prompt: "Review this code for bugs, security issues, and style consistency"
    - generate_report:
        format: markdown
    - notify:
        via: telegram
        include_summary: true

Multi-Agent Orchestration

For complex tasks, run multiple specialized agents:

  • Research agent: Gathers information from multiple sources
  • Analysis agent: Synthesizes research into insights
  • Writing agent: Formats findings into polished documents

Define in config/orchestration.yaml with task delegation logic.

Integration with Other Tools

ClawdBot can integrate with LangChain for enhanced capabilities, or connect to n8n for visual workflow design. These integrations expand ClawdBot's utility within your broader development ecosystem.

Performance Benchmarks and Expectations

Realistic performance expectations for a self-hosted ClawdBot instance on mid-range hardware:

  • Simple queries: 2-3 second response time
  • Complex research: 30-60 seconds for Reddit analysis across 100 posts
  • Document generation: 10-20 seconds for 2000-word technical documentation
  • Calendar operations: 5-10 seconds including conflict checking

Network latency to Anthropic's API typically accounts for 30-50% of total response time. Consider this when setting user expectations.

Next Steps and Further Learning

Expand Your Workflows

Now that you have a working ClawdBot installation, explore these advanced use cases:

  • Email automation: Integrate with IMAP to draft responses or summarize important threads
  • Project management: Connect to GitHub to automate issue triage and PR descriptions
  • Knowledge management: Build a personal knowledge base with automatic summarization and tagging
  • Team collaboration: Deploy multiple bot instances for different team functions

Community Resources

Join the ClawdBot community for support and inspiration:

  • Official GitHub repository: Issues and Discussions sections are active
  • Discord server: Real-time help from experienced users
  • YouTube tutorials: Visual walkthroughs of advanced configurations
  • Weekly community calls: Share your workflows and learn from others

Contributing Back

As you develop custom workflows, consider contributing them back to the project. The ClawdBot ecosystem thrives on shared templates and integration modules. Review the CONTRIBUTING.md file in the repository for guidelines.

Conclusion

ClawdBot represents a significant step forward in personal AI automation—combining the power of Claude's reasoning with the control and privacy of self-hosting. This tutorial has taken you from initial setup through advanced workflow configuration, equipping you to build a truly personal AI assistant.

The key advantages of this approach are clear: complete data sovereignty, unlimited customization potential, and cost control through intelligent model selection and caching. While self-hosting requires more setup effort than cloud solutions, the long-term benefits for professional developers are substantial.

Start with the basic workflows outlined here—calendar management and research automation provide immediate value. As you gain confidence, expand into custom workflows tailored to your unique development process. The investment in setup pays dividends through hundreds of hours saved on routine tasks.

Remember that ClawdBot is a tool, not a replacement for human judgment. Review its outputs, especially for critical decisions. Use it to augment your capabilities, handling the routine so you can focus on the creative and strategic aspects of development work.

Share:

Original Source

https://www.youtube.com/watch?v=NO-bOryZoTE

View Original

Last updated: