Preface: Why Would You Even Do This
Full disclosure — this started as a hackathon fever dream at 1am. I wanted to ask Claude Code questions from my phone while it was running on my laptop. Not through some elaborate cloud setup. Just… from WhatsApp. To my laptop. Like sending a note to your roommate, except the roommate is an AI that can read your screen.
What I built is weird. It involves a Python script that reads a SQLite database that OpenClaw writes to, pipes the output through a WhatsApp bot, gets interpreted by Claude Code via its tool-use API, and sends the result back.
Disclaimer: This is a proof-of-concept. I've packaged the entire thing into a ready-made setup you can run in 10 minutes — scroll to the bottom for that.
The Stack
- OpenClaw — runs on my Mac, controls everything
- WhatsApp — via WhatsApp Business API
- Claude Code — does the actual AI reasoning
- Python 3 — the glue
- SQLite — the message queue
Step 1: Set Up the SQLite Queue
OpenClaw writes conversations to a SQLite database. I wrote a small Python library that reads from that DB:
import sqlite3
from pathlib import Path
DB_PATH = Path.home() / ".openclaw" / "memory" / "conversations.db"
def get_pending_tasks():
conn = sqlite3.connect(DB_PATH)
cur = conn.cursor()
cur.execute("SELECT id, prompt, status FROM tasks WHERE status = 'pending' ORDER BY created_at LIMIT 1")
return cur.fetchone()
def complete(task_id, result):
conn = sqlite3.connect(DB_PATH)
cur = conn.cursor()
cur.execute("UPDATE tasks SET status = 'done', result = ? WHERE id = ?", (result, task_id))
conn.commit()
Step 2: Poll and Pipe to Claude Code
#!/usr/bin/env python3
import subprocess, json, time
from queue_lib import get_pending_tasks, complete
def poll_and_process():
task = get_pending_tasks()
if not task:
return
task_id, prompt = task[0], task[1]
result = subprocess.run(
["claude", "--print", "-p", prompt],
capture_output=True, text=True
)
complete(task_id, result.stdout)
while True:
poll_and_process()
time.sleep(30)
Step 3: WhatsApp Integration
I used the Twilio WhatsApp API to receive messages and write them to the SQLite queue, then had the poller script pick them up and send them to Claude Code. The response comes back as a WhatsApp message.
Does It Actually Work?
Yes. Scarily well. The latency is 30-60 seconds (polling interval + Claude response time), but for non-urgent queries it's perfect. I can ask Claude Code to review code, write emails, research topics — all from WhatsApp while I'm on the go.