AI TOOLS11 min read

How to Build a Custom AI Assistant with OpenClaw

Josep

Josep

Co-Founder, Lead Automation Engineer · March 24, 2026

In this guide, you'll build a custom AI assistant for your business step by step using OpenClaw. By the end, you'll have an assistant accessible from WhatsApp or Telegram that can manage your calendar, handle emails, update tasks in your project manager, and answer questions about internal company documents, all running on your own infrastructure.

This guide assumes basic Linux terminal and Docker knowledge. If you prefer a managed solution without server management, I'll cover when that makes more sense at the end.

What you'll build

By the end of this tutorial you'll have:

• An AI assistant deployed on your server (local or VPS) • Accessible from WhatsApp and/or Telegram • Connected to Google Calendar, Gmail, and your task management tool • Able to answer questions about your internal company documents • Extensible with plugins for any additional service

The basic architecture is straightforward: OpenClaw listens to your messages on whichever channel you choose, processes them using a language model (GPT-4, Claude 3, or a local model), and executes the necessary actions through its integrations.

All code and conversations stay on your server. No information passes through third-party servers (except calls to the language model API, which you can avoid by using a local model like Ollama with Llama 3).

Prerequisites

You'll need the following before starting:

Hardware. A Linux server (Ubuntu 22.04 LTS recommended) or VPS with at least 2 CPU cores and 4 GB RAM. For running a local language model without an external API, you'll need at least 16 GB RAM.

Software. Docker 24+ and Docker Compose v2 installed.

Accounts and credentials. An OpenAI API key (GPT-4) or Anthropic API key (Claude 3). Alternatively, an Ollama installation with your model of choice. For Google integrations (Calendar, Gmail), you'll need a Google Cloud Console project with the relevant APIs enabled.

Messaging channel. A Telegram account (easiest to set up) or a WhatsApp Business number. WhatsApp requires either access to the official Meta API or a third-party bridge solution.

Domain or IP. To receive WhatsApp webhooks you need a public HTTPS URL. For Telegram you can use either a public URL or long polling (simpler to start).

Installation

Clone the repository and prepare the base configuration:

```bash git clone https://github.com/openclaw/openclaw cd openclaw cp .env.example .env ```

Edit the `.env` file with your credentials. The key fields:

```env # Language model LLM_PROVIDER=openai # openai | anthropic | ollama OPENAI_API_KEY=sk-...

# Database (PostgreSQL included in Docker Compose) DB_HOST=postgres DB_NAME=openclaw DB_USER=openclaw DB_PASSWORD=change_this_password

# Security SECRET_KEY=generate_a_long_random_key ALLOWED_HOSTS=your-domain.com,localhost ```

Start the services:

```bash docker compose up -d ```

Check that all containers are running with `docker compose ps`. You should see `web`, `worker`, `postgres`, and `redis` in `running` state.

Connect Telegram (fastest option)

Telegram is the easiest channel to set up because it doesn't require a public IP or complex webhook configuration.

Step 1: Create the bot. Talk to @BotFather on Telegram, use `/newbot`, choose a name and username. You'll get a token in the format `1234567890:ABCDEF...`.

Step 2: Add the token to your `.env`:

```env TELEGRAM_BOT_TOKEN=1234567890:ABCDEF... TELEGRAM_ALLOWED_USERS=your_telegram_id # optional, for restricted access ```

Step 3: Restart the services:

```bash docker compose restart web worker ```

Step 4: Test it. Find your bot on Telegram by the username you created, send `/start`, and you should receive OpenClaw's welcome message.

To give access to your whole team, add each person's Telegram ID to `TELEGRAM_ALLOWED_USERS`, comma-separated. Find your ID by messaging @userinfobot on Telegram.

Connect services: Google Calendar and Gmail

To connect Google Calendar and Gmail, you need a Google Cloud Console project with the APIs enabled and OAuth 2.0 credentials.

Step 1: Create a Google Cloud project. 1. Go to console.cloud.google.com and create a new project 2. Enable Google Calendar API and Gmail API 3. Under "Credentials", create OAuth 2.0 credentials of type "Web application" 4. Add your redirect URI: `https://your-domain.com/integrations/google/callback` 5. Download the `credentials.json` file

Step 2: Add the credentials to your configuration:

```env GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=GOCSPX-... GOOGLE_REDIRECT_URI=https://your-domain.com/integrations/google/callback ```

Step 3: Authorize access. Go to the OpenClaw admin panel at `https://your-domain.com/admin`, navigate to Integrations, and follow the OAuth flow to connect your Google account.

Once connected, test from Telegram:

> "Do I have any meetings tomorrow?" > "Create an event on Friday at 11am with the marketing team" > "Check if there are unread emails from [client name]"

Adding internal documents: the knowledge base

One of OpenClaw's most useful features for businesses is answering questions about internal documents: manuals, processes, FAQs, product catalogs.

OpenClaw uses a vector database to index documents and perform semantic search. The process:

Step 1: Upload your documents. From the admin panel, go to "Knowledge Base" and upload PDFs, text files, or Word documents. OpenClaw splits them into chunks and generates embeddings automatically.

Step 2: Set permissions. You can define which users or channels have access to which documents. For example, the HR handbook accessible only on the HR Slack channel.

Step 3: Test queries. From Telegram:

> "What's the return policy?" > "What warranty do products in line X come with?" > "Summarize the onboarding process for new employees"

OpenClaw searches the indexed documents, extracts the relevant fragment, and generates a natural language response citing the source.

Building custom plugins

If OpenClaw's 50+ native services don't cover a specific system (a proprietary ERP, a custom CRM, an internal API), you can write plugins in Python.

Basic plugin structure:

```python from openclaw.plugins import Plugin, tool

class MyERP(Plugin): name = "my_erp" description = "Queries stock and orders from our ERP"

@tool def check_stock(self, reference: str) -> dict: """Returns current stock for a product by reference""" response = requests.get( f"{ERP_BASE_URL}/stock/{reference}", headers={"Authorization": f"Bearer {ERP_API_KEY}"} ) return response.json()

@tool def order_status(self, order_number: str) -> dict: """Returns current status of an order""" # ... query logic pass ```

Place the file in the `plugins/` folder of your OpenClaw installation and restart the worker. The system detects new plugins automatically and makes them available to the assistant.

From that point you can ask:

> "How many units of reference ABC-123 are left?" > "What's the status of order 9847?"

Production considerations

If you're deploying OpenClaw for a real team, address these security and stability points before opening access.

Authentication. Configure `TELEGRAM_ALLOWED_USERS` or the WhatsApp equivalent to restrict access. Without this, anyone who finds your bot can use it.

HTTPS. Use a valid SSL certificate. Let's Encrypt (free) with Certbot is the standard option. WhatsApp webhooks require it.

Database backups. Indexed documents and conversation history live in PostgreSQL. Set up daily automated backups with `pg_dump` and store them off the main server.

Rate limits. Configure `RATE_LIMIT_PER_USER` to prevent excessive language model API consumption if you have many active users.

Monitoring. Enable `WARNING` level logs in production and connect an error tracking service (Sentry works well) to catch issues before users notice them.

Updates. Subscribe to OpenClaw's GitHub repository releases to get notified about security updates.

When a custom solution makes more sense

OpenClaw is a strong option for companies with technical staff, but there are situations where a purpose-built solution is the better call:

Deep conversational customization. OpenClaw is designed as a general-purpose assistant. If you need very specific conversation flows (a sales qualification agent following a precise process, or a support assistant with complex escalation logic), building from scratch gives you more control.

Deep proprietary integrations. If your company uses heavily customized internal systems, OpenClaw's plugin system can be limiting. A native integration designed for your specific architecture will perform better.

No technical team. Installation and maintenance requires familiarity with servers, Docker, and system configuration. If you don't have that profile internally, the real cost is higher than it appears.

Strict compliance requirements. In sectors like healthcare or finance, you may need additional data controls, audit trails, and documentation that go beyond what OpenClaw provides out of the box.

In all these cases, building a custom solution from the start produces a system more precisely matched to your needs, lower long-term maintenance cost, and no technical debt from adapting a codebase not designed for your use case.

Key Takeaway

OpenClaw is one of the most accessible entry points for companies that want a fully controlled AI assistant. The setup curve exists, but once running, the system is stable and extensible.

If after reading this guide the configuration process is beyond what your team can handle, or if your requirements are more complex than OpenClaw handles out of the box, at 91 Agency we implement and customize it, or design a custom solution from scratch.

Josep

Josep

Co-Founder, Lead Automation Engineer

Josep is co-founder and lead engineer at 91 Agency with 4+ years building and scaling tech startups. He architects production-grade automation systems and custom tools. His motto: if you do it twice, you're doing it wrong.

EXPLORE THIS SERVICE

Custom AI Software

Ready to implement what you've learned? See how we can help.

[ VIEW_SERVICE ]

[STATUS] LIVE_IN_48H

Your assistant live in 48 hours, without touching a server

You now know exactly how OpenClaw works. We deploy it, connect your integrations, and train your team. Your assistant goes live in 48 hours. You focus on using it.

[ GET SET UP IN 48H ]