How to build a self-hosted WhatsApp AI bot in 2026
A practical walkthrough of pairing WhatsApp to a self-hosted AI agent powered by Claude or GPT — using openclawOS, no Meta Business API, no cloud SaaS in the middle.
- tutorial
- claude
- gpt
WhatsApp is the world’s biggest messenger. Self-hosting a WhatsApp AI bot used to require a small army: the Business API, a verified Meta account, a webhook URL, a “messaging conversation” pricing model, and a bunch of paperwork.
In 2026, you don’t need any of that. Here’s how to wire a self-hosted AI agent into your own WhatsApp number using openclawOS — install to first message in about five minutes.
What you’ll end up with
A WhatsApp number that, when messaged, replies with an AI agent of your choice (Claude, GPT, Gemini, anything OpenAI-compatible). The agent has memory, can use tools (file system, browser, vector recall), and stays consistent across sessions. The Gateway runs on a machine you own. WhatsApp messages decrypt only inside your network. The LLM call is the only outbound traffic.
What you need
- A computer to run the Gateway. A $5 VPS, a Raspberry Pi 4, a Mac mini — anything with Node 22+.
- A spare phone number for the bot. A second SIM is cleanest; a Twilio number works too.
- An API key for your LLM of choice. Anthropic’s Claude Opus 4.6 is what we recommend; GPT-4o or Gemini also work.
Step 1: Install openclawOS
npm install -g openclawos@latest
openclawos onboard --install-daemon
This installs the binary, registers a service, and opens the Control UI on http://localhost:7777.
For Docker:
docker run -d --name openclawos \
-p 7777:7777 \
-v openclawos-data:/data \
ghcr.io/neullabs/openclawos:latest
Step 2: Add your LLM provider
In the Control UI, open the Providers tab. Paste your API key. Claude Opus 4.6 is the default; pick whichever you like.
This key never leaves your Gateway — it’s encrypted at rest using your OS keychain.
Step 3: Pair WhatsApp
openclaw apps install whatsapp
A QR code appears in your terminal. On the phone you’re pairing:
- Open WhatsApp.
- Settings → Linked Devices → Link a Device.
- Scan the QR.
That’s it. The Gateway is now a “linked device” on your WhatsApp account — the same way your laptop or web client would be.
If you want to keep your personal number personal, pair a second number on a different phone (or use a dual-SIM phone), and link that one instead.
Step 4: Open a binding
By default, the WhatsApp binding routes 1:1 DMs to Pi and ignores groups. To adjust, edit ~/.openclaw/bindings/whatsapp.yaml:
trigger:
channel: whatsapp
scope: any
match:
not:
isGroup: true
agent: pi
session:
scope: user
isolation: strict
Want Pi in a specific group? Add groupId to scope. Want it to listen only when @-mentioned? Add mentions: ["@yourbot"].
Bindings hot-reload — save the file and changes apply immediately, no restart.
Step 5: Message it
From any other WhatsApp account, message the paired number. Pi responds within a second or two depending on the LLM you picked.
Try:
- “What’s the weather in Berlin?” (Pi uses its web tool)
- “Remember that I prefer Postgres over MySQL.” (Pi writes to vector memory)
- Send a photo of a receipt. (Pi sees it via vision and itemises)
Common adjustments
Voice notes are transcribed by default via Whisper. If you want a local Whisper, point ~/.openclaw/config.yaml at a local endpoint:
transcription:
provider: local
endpoint: http://localhost:8080/transcribe
Reactions — Pi can react instead of reply (useful for “acked” UX). Toggle in the binding:
behavior:
reactBeforeReply: "👀"
Multiple bots — pair more numbers, give each its own binding. One can be a “coding Pi”, another a “personal Pi”.
Cost reality
Heavy use: ~$30/month in Claude tokens for a chatty user. Light use: ~$5. Server: $5/month VPS or zero if you’re on hardware you already own. The economics are dramatically better than any hosted “WhatsApp AI” SaaS — they all markup LLM tokens 3-10×.
Privacy reality
Your messages decrypt only inside your Gateway. There is no openclawOS telemetry. The only outbound traffic is the LLM call. If you trust WhatsApp’s E2E and trust your LLM vendor, you have full privacy.
What’s next
Pair Telegram, Discord and iMessage with the same Gateway. Move identity-link to a single profile so when you write to Pi in WhatsApp the conversation continues on iMessage when you’re at your Mac. Add a cron binding so Pi sends you a morning brief. The whole stack composes — that’s the point.
Frequently asked
Personal-volume usage (tens to a couple of hundred messages per day) is well within normal limits. The Baileys library mimics the WhatsApp Web protocol — the same protocol your laptop uses. Heavy commercial volumes should graduate to the official Cloud API.
Related reading
The complete guide to self-hosted AI gateways in 2026
What a self-hosted AI gateway is, why it matters, how openclawOS implements one, and a practical setup walkthrough — from zero to multi-channel agent in an afternoon.
Home automation via WhatsApp — Pi, Grafana, Roborock and a Bambu printer
A real-world setup: openclawOS Pi running on a Mac mini, taking commands via WhatsApp to control a Roborock, monitor a Bambu print, and query Grafana.
Telegram AI bot with Claude — a 5-minute self-hosted setup
Build a Telegram bot powered by Claude (or any LLM) without a SaaS in the middle. Step-by-step setup with openclawOS, @BotFather, and Pi.