v2026.1.24

How Clawdbot Works

Deep Technical Analysis ยท For Everyone

This document takes you deep inside Clawdbot's internal workings. Whether you're a regular user wanting to understand the basics, or a developer looking to dive into the code, you'll find what you need here.

Simple Explanation: What is Clawdbot?

Understanding Clawdbot's core features in plain language

๐Ÿค–

Your Personal AI Assistant

Imagine having a super-smart assistant that you can chat with through WhatsApp, Telegram, Discord, and other messaging apps you already use. Just send messages like you would to a friend, and it helps you with all kinds of tasks.

๐Ÿ’ป

An AI That Actually Does Things

Unlike regular chatbots, Clawdbot can execute real actions on your computer: run commands, process files, send emails, control smart home devices, and more. It doesn't just "talk"โ€”it "does."

๐Ÿ”’

Runs Entirely Locally

Your data never leaves your device. Clawdbot runs locally on your computer, keeping your private data away from third-party servers. You have complete control over your data.

๐Ÿ”—

Multi-Platform Connection

Whether you're using WhatsApp, Telegram, or Discord, you can talk to the same AI assistant. Messages sync automatically, so you can get help anytime, anywhere.

Supported Platforms

Use your AI assistant on the platforms you already know

๐Ÿ’ฌ WhatsApp
โœˆ๏ธ Telegram
๐ŸŽฎ Discord
๐Ÿ’ผ Slack
๐Ÿ“ฑ iMessage
๐Ÿ” Signal
๐Ÿข MS Teams
๐ŸŒ WebChat

System Architecture Overview

Understanding how Clawdbot's core components work together

๐Ÿ‘ค User

Sends message

โ†’

๐Ÿ“ฑ Chat Platform

WhatsApp/Telegram/...

โ†’

๐ŸŒ WebSocket Gateway

Message Routing Hub

โ†’

๐Ÿง  Claude AI Agent

Intelligence Engine

โ†”

๐Ÿ› ๏ธ Tool System

Command/File Operations

โ†’

๐Ÿ“ค Reply Delivery

Multi-channel Broadcast

โ†’

๐Ÿ‘ค User

Receives reply

WebSocket Gateway

The central hub for all messages. No matter which platform messages come from, they arrive here first, then get processed and distributed. Supports real-time bidirectional communication.

Claude AI Agent

The brain. Uses Anthropic's Claude model to understand your intent, decide what actions to take, and generate intelligent responses.

Tool System

The "hands" that execute actual operations. Can run shell commands, read/write files, call APIs, control browsers, and more. Runs in a secure sandbox.

Channel Adapters

Converts unified message format to platform-specific formats. Each chat platform has a dedicated adapter handling connections and message exchange.

Core Modules Deep Dive

Understanding Clawdbot's technical implementation

โŒจ๏ธ
CLI System
/src/cli/

Command-line interface entry point with 100+ subcommands for configuring and managing Clawdbot.

  • Built with Commander.js command structure
  • Supports gateway, channels, agents command groups
  • Interactive configuration wizard (clack/prompts)
  • Auto-update detection and version management
๐ŸŒ
WebSocket Gateway
/src/gateway/

Core communication hub handling all client connections and message routing.

  • WebSocket real-time bidirectional communication
  • RPC-style method calls (chat.send, chat.history)
  • Message deduplication and idempotency
  • Device authentication and session management
  • Hot reload configuration support
๐Ÿง 
Agent Runtime
/src/agents/

AI agent execution engine integrating Anthropic Claude API and tool systems.

  • Pi Agent framework integration (297 files)
  • Multi-model support (Claude/GPT/Ollama)
  • OAuth token management and rotation
  • Usage tracking and quota management
  • Docker sandbox execution environment
๐Ÿ“ก
Channel System
/src/channels/

Multi-platform message routing supporting 9+ built-in channels and 20+ extension plugins.

  • Unified message format normalization
  • Plugin-based channel driver architecture
  • Message allowlists and access control
  • Outbound message broadcast and delivery
  • User onboarding and configuration wizards
โš™๏ธ
Configuration System
/src/config/

JSON5 format configuration management with Zod type validation.

  • 119 configuration-related files
  • Complete Zod Schema runtime validation
  • Version migration and backward compatibility
  • Session and model configuration management
  • Multi-environment configuration support
๐ŸŽจ
Web UI
/ui/src/

Control panel frontend built with Lit Web Components.

  • @customElement custom components
  • Reactive state management (@state)
  • Real-time chat stream rendering
  • Tool call visualization
  • Dark/light theme switching

Code Structure Navigation

How 390,000 lines of code across 3,015 files are organized

clawdbot-main/
โ”œโ”€โ”€ src/# Core source code (68 subdirectories)
โ”œโ”€โ”€ cli/# Command-line interface
โ”œโ”€โ”€ gateway/# WebSocket gateway service
โ”œโ”€โ”€ agents/# AI agent runtime (297 files)
โ”œโ”€โ”€ channels/# Multi-platform channel adapters
โ”œโ”€โ”€ config/# Configuration management (119 files)
โ”œโ”€โ”€ web/# WhatsApp Web integration
โ”œโ”€โ”€ tools/# Tool definitions and execution
โ”œโ”€โ”€ infra/# Infrastructure (144 files)
โ””โ”€โ”€ commands/# Command handlers (174 files)
โ”œโ”€โ”€ ui/# Control panel frontend (Lit Components)
โ”œโ”€โ”€ apps/# Platform native apps
โ”œโ”€โ”€ ios/# iOS app (Swift)
โ”œโ”€โ”€ android/# Android app (Kotlin)
โ””โ”€โ”€ macos/# macOS menu bar app
โ”œโ”€โ”€ extensions/# 54 optional plugins
โ”œโ”€โ”€ skills/# 54 skill modules
โ”œโ”€โ”€ scripts/# 64 build scripts
โ””โ”€โ”€ docs/# Documentation (Mintlify)
Key File Description Responsibility
/src/entry.ts CLI Entry Point Node.js execution entry, environment initialization
/src/gateway/server.impl.ts Gateway Server WebSocket connection management, RPC handling
/src/agents/pi-embedded-runner.ts Agent Runner AI agent execution engine, tool scheduling
/src/web/auto-reply.impl.ts Auto Reply Message monitoring, reply generation and delivery
/src/channels/dock.ts Channel Registry Channel lifecycle management, start/stop
/ui/src/ui/app.ts Frontend Main Component Lit app entry, state management
/src/gateway/server-methods/chat.ts Chat RPC Chat message processing, history retrieval

Message Processing Flow

The complete journey from sending a message to receiving a reply

1

User Sends Message

User sends a message through WhatsApp, Telegram, or other platforms. Messages can be text, images, voice, and other formats.

WhatsApp โ†’ Baileys library โ†’ Message event triggered
2

Message Enters Gateway

Channel adapter converts platform-specific message format to unified format, sends to gateway server via WebSocket.

channels/plugins/normalize/whatsapp.ts โ†’ gateway/server.ts
3

RPC Call Processing

Gateway's chat.send method validates message, processes attachments, loads session state, then starts Agent execution.

gateway/server-methods/chat.ts โ†’ Parameter validation โ†’ AbortController creation
4

AI Agent Execution

Pi Agent runtime calls Claude API, understands user intent, decides whether to invoke tools, generates response content.

agents/pi-embedded-runner.ts โ†’ Anthropic API โ†’ Tool calls โ†’ Response stream
5

Tool Execution (Optional)

If AI decides to perform operations, tool system runs commands, reads/writes files, or calls APIs in a secure sandbox.

agents/bash-tools.exec.ts โ†’ PTY execution โ†’ Results returned
6

Response Streaming

AI response streams in real-time, gateway broadcasts delta events, frontend progressively displays reply content.

broadcastChatDelta() โ†’ WebSocket โ†’ UI update
7

Reply Delivery

Final reply sent back to original platform via channel adapter, user receives reply in WhatsApp/Telegram app.

web/auto-reply/deliver-reply.ts โ†’ outbound.ts โ†’ Platform API

Technology Stack

Technologies and tools used to build Clawdbot

๐Ÿ–ฅ๏ธ Backend Runtime

  • Node.js 22+ (ESM)
  • TypeScript 5.9
  • Hono 4.11 (Web Framework)
  • Express 5.2 (HTTP Server)
  • ws 8.19 (WebSocket)

๐ŸŽจ Frontend Framework

  • Lit 3.3 (Web Components)
  • Vite 7.3 (Build Tool)
  • DOMPurify (Secure Rendering)
  • Marked (Markdown Parsing)

๐Ÿค– AI Integration

  • Anthropic Claude (Primary)
  • OpenAI GPT-4
  • Google Gemini
  • Ollama (Local Models)
  • AWS Bedrock

๐Ÿ“ฑ Channel Support

  • Baileys (WhatsApp Web)
  • grammY (Telegram)
  • discord.js (Discord)
  • Slack SDK
  • Signal/Matrix/iMessage

๐Ÿ› ๏ธ Development Tools

  • pnpm 10.23 (Package Manager)
  • Vitest 4.0 (Test Framework)
  • Oxlint (Code Linting)
  • Oxfmt (Code Formatting)

๐Ÿ“ฆ Other Dependencies

  • Sharp (Image Processing)
  • pdfjs-dist (PDF Processing)
  • Chromium BDI (Browser Automation)
  • node-edge-tts (Text-to-Speech)
390K+
Lines of Code
3,015
TypeScript Files
54
Extension Plugins
54
Skill Modules
9+
Built-in Channels
70%
Test Coverage