Jun 28, 2026
How to Build a Self-Hosted Telegram AI Bot with DeepSeek-R1 (2026)
Learn how to build and self-host your own privacy-focused Telegram AI bot using DeepSeek-R1, Ollama, …
In 2026, the rise of autonomous AI agents has completely transformed how we interact with technology. Instead of juggling dozens of web interfaces and command-line terminals, developers and power users are moving toward unified interfaces. At the forefront of this shift is OpenClaw, a trending open-source AI agent gateway that bridges the gap between large language models (LLMs) and messaging platforms. By self-hosting OpenClaw and connecting it to Telegram, you can build a personal AI companion capable of reading files, executing shell commands, browsing the web, and running tasks in the background. In this detailed, step-by-step guide, we will walk you through deploying OpenClaw on your own server or VPS, configuring its multi-model capabilities with Claude and DeepSeek, and setting up the Telegram integration in 2026.
To deploy OpenClaw on Telegram: 1) Generate a bot token from Telegram's @BotFather, 2) Configure the open-source OpenClaw settings with your LLM API keys (DeepSeek, Claude, or local Ollama), and 3) Launch the gateway via Docker or Python. For verified active bots and utilities, check out Telekit's Science & Technology Directory.
OpenClaw is an open-source gateway designed to turn advanced AI models into proactive agents. Unlike traditional chatbots that only respond to user prompts, OpenClaw runs in the background and can execute scheduled tasks (known as heartbeat cron jobs), monitor files, and interact with external systems.
By connecting OpenClaw to Telegram, you create an end-to-end mobile command center. You can chat with your bot to query database statistics, run bash scripts, or check the status of server services. Self-hosting OpenClaw ensures that your API keys and data remain completely under your control, avoiding third-party hosting fees.
Before launching the installation process, ensure your environment meets the following minimum requirements:
The first step is to register a new bot on the Telegram platform. This bot will serve as your frontend interface to interact with OpenClaw.
Open Telegram and search for the official @BotFather account. Send the following commands to create your bot:
/newbot to initiate the setup process.My Personal Claw Agent).my_custom_openclaw_bot).123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ. Keep this token secret.To prevent unauthorized access to your server via the bot, make sure to find your personal Telegram user ID (using bots like @userinfobot) so you can restrict access to yourself in the configuration file.
Using Docker is the cleanest way to host OpenClaw. It isolates the execution environment, which is crucial because the agent can run shell commands on your system.
Create a dedicated directory for your OpenClaw deployment and navigate into it:
mkdir ~/openclaw-deploy
cd ~/openclaw-deploy
Now, create a docker-compose.yml file in this folder using your preferred text editor:
version: '3.8'
services:
openclaw:
image: openclaw/gateway:latest
container_name: openclaw_gateway
restart: unless-stopped
volumes:
- ./config:/app/config
- ./data:/app/data
environment:
- DEEPSEEK_API_KEY=your_deepseek_api_key_here
- ANTHROPIC_API_KEY=your_anthropic_api_key_here
- GEMINI_API_KEY=your_gemini_api_key_here
ports:
- "8080:8080"
This configuration mounts local directories for persistent storage of configuration files and database logs, and exposes the optional web interface port.
If you prefer a direct Python installation on a VPS or local machine, you can set it up inside a sandboxed virtual environment. This method is useful if you are developing custom tools or need direct access to local system utilities.
Run the following commands to set up the environment and install OpenClaw:
# Clone the repository
git clone https://github.com/openclaw/openclaw.git
cd openclaw
# Set up Python virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies and the OpenClaw package
pip install --upgrade pip
pip install -r requirements.txt
pip install .
For Windows systems, use the following commands to activate the environment:
venv\Scripts\activate
OpenClaw relies on a central configuration file, typically named config.yaml, to handle model settings, agent behaviors, and communication channels. Create a new folder named config inside your deployment directory and save the following settings as config/config.yaml:
# OpenClaw Settings Configuration
system:
log_level: "info"
data_dir: "./data"
llm:
provider: "deepseek" # Options: deepseek, anthropic, openai, gemini, ollama
model: "deepseek-chat"
temperature: 0.2
channels:
telegram:
enabled: true
bot_token: "123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ" # Your @BotFather token
allowed_user_ids:
- 987654321 # Your personal Telegram user ID to block unauthorized access
commands:
enabled: true
allow_shell: true # WARNING: Enable only if you restricted allowed_user_ids
agents:
memory:
enabled: true
storage: "sqlite" # Persistent SQLite database
max_history_tokens: 4096
tools:
- name: "web_search"
enabled: true
- name: "file_manager"
enabled: true
This configuration defines DeepSeek as the primary AI provider, sets up SQLite for persistent context memory, and specifies your Telegram credentials. The allowed_user_ids list is crucial to prevent strangers from messaging your bot and triggering terminal commands.
Once your docker configuration or python dependencies are in place, you can start OpenClaw. If using Docker, run the following command:
docker-compose up -d
If you opted for a raw Python setup, launch the service directly from the terminal:
openclaw --config config/config.yaml
Check the startup logs using docker logs openclaw_gateway to confirm that the gateway has successfully established connection with the Telegram API. Once running, open your Telegram app, search for your bot's username, and click "Start" or send the message /start. If the setup is correct, your bot will respond with a welcome message and indicate that it is ready to execute agentic workflows.
Because OpenClaw can execute system terminal commands, securing the deployment is of paramount importance. If you plan to scale the bot to handle business processes, always follow these essential safety guidelines:
Yes. OpenClaw supports switching between multiple API providers like Anthropic (Claude), DeepSeek, OpenAI, Google Gemini, and even local instances using Ollama. You can define backup models and routing rules in the config.yaml file.
OpenClaw stores conversation threads and context data in a local SQLite database. This ensures that the bot remembers previous interactions, project details, and user preferences even after restarting the service or system.
Yes. The OpenClaw configuration allows you to set up periodic trigger intervals (heartbeat jobs). The agent will wake up, run designated check tasks (like monitoring a log file or checking website availability), and send notification alerts directly to your Telegram chat.
First, verify that your bot token is correct and your system is connected to the internet. Second, check the Docker logs using docker logs openclaw_gateway to see if there are API authentication errors or firewall blocks.
Deploying OpenClaw as your Telegram agent gateway is a major step toward personal automation in 2026. With persistent memory and command-line execution, you gain full control of your infrastructure from a secure chat box. Always prioritize whitelisting allowed user IDs and sandbox your container deployments. Start building your custom AI agent and automate your workflows today!
Pick your interests and we'll show you the best communities first.
Stay updated with the latest Telegram groups and channels
Or scan the QR code
Loading community stats...
No active reviews. Be the first to add one!