If you spend more time in Gmail than in your editor, you’ve probably typed the same phrases hundreds of times. I finally gave my wrists a break by teaching OpenClaw to draft emails that sound like me, not like a GPT press release. Below is the exact setup I’m running in production. No hand-wavy marketing, just the commands, config files, and gotchas.
Why teach OpenClaw your email voice at all?
Email automation isn’t new. But most tools spit out generic corporate mush. OpenClaw’s persistent memory (Redis or Postgres under the hood) means the agent actually remembers the way you phrase things and the context of past threads. After two weeks of use my daily email output dropped from ~35 drafted manually to ~5 edited drafts. That’s a real number pulled from RescueTime.
- Less typing: average 6.1k fewer keystrokes per day.
- Consistent tone: every “Sorry for the delay” now carries my usual self-deprecating joke.
- Still in control: nothing leaves my outbox without an explicit
approvecommand.
Prerequisites: Node 22+, GitHub login, and a Gmail API token
OpenClaw v1.9.3 requires Node 22 or newer. If that’s not on your machine yet:
# macOS or Linux
brew install nvm
nvm install 22
nvm use 22
Grab OpenClaw:
npm install -g openclaw@1.9.3 # 90 MB install, mostly model weights
openclaw --version # should print 1.9.3
If you don’t want to run local GPUs/CPUs, sign up for ClawCloud. The rest of the guide works unchanged—just replace file paths with the web UI.
For Gmail you need OAuth2 creds. Quickest path is Google Cloud’s “Desktop App” flow:
- Go to console.cloud.google.com, create a project called OpenClawMailer.
- Enable Gmail API.
- Create OAuth credentials → Desktop App. Download
client_secret.json. - The first time OpenClaw hits Gmail you’ll get the consent screen in your browser.
Loading example emails into persistent memory
OpenClaw learns better by example than by rules. I exported 200 sent mails as EML files and fed them straight in. Here’s the script:
# place EML files in ~/emails/sent/
openclaw memory import --format eml ~/emails/sent/
# 192 vectors written to redis://127.0.0.1:6379/0 (using text-embedding-ada-002)^1
Footnote 1: OpenClaw defaults to the OpenAI embedding model if your OPENAI_API_KEY is set. Swap in --embedding-model gte-small to stay fully local.
What if you don’t have a clean export? You can pipe from Gmail API:
openclaw gmail export --label SENT --max 500 | \
openclaw memory import --format jsonl -
The agent now has raw messages. Time to tell it what to pay attention to.
Defining your writing style in the persona config
OpenClaw’s persona lives in ~/.openclaw/persona.yaml (locally) or the Settings → Persona tab on ClawCloud. Mine looks like this:
name: Peter-Assistant
role: "Senior Engineer & Occasional Sarcasm Distributor"
tone:
- friendly
- concise
- slightly self-deprecating
rules:
- never apologise unless absolutely required
- avoid exclamation points
- prefer active voice
examples:
opening: |
Hey ,
Quick heads up on …
closing: |
Cheers,
Peter
sorry: |
Not ideal, and the delay’s on me. Here’s the fix:
The tone array seeds the system prompt. The rules appear in every generation request. examples get injected as few-shot prompts, which helps more than any amount of temperature tweaking.
Reload the agent after editing:
openclaw daemon restart
Drafting and iterating on emails via chat
The CLI flow
openclaw chat
> draft follow-up to ACME, mention we shipped 1.9.3, keep it under 120 words
# assistant reply …
> shorten subject line
# assistant: "1.9.3 Shipped – quick ACME note"
> replace "delighted" with "glad"
> approve
The approve verb triggers the Gmail integration. A draft appears in Drafts with labels OC_generated, needs_review. Nothing sends until you manually hit Send or run openclaw gmail send --label needs_review.
The Gateway web UI flow
If you prefer browsers:
- Run
openclaw gateway(or open your ClawCloud workspace). - Chat panel on the left, live draft preview on the right.
- Every time you type
/approvein chat the preview syncs to Gmail.
Power user tip: add cmd+enter as a custom shortcut for /approve under Settings → Shortcuts.
Approval-before-send workflow with Gmail integration
Nobody wants an agent firing off half-baked apologies at 2 a.m. Use the built-in guardrail middleware:
# ~/.openclaw/config.yaml
gmail:
mode: draft_only # 'draft_only' | 'send_on_approve' | 'auto'
label_prefix: OC_
reviewers:
- peter@company.com
required_labels:
- reviewed_by_human
Set mode to send_on_approve if you trust yourself, or auto if you trust the AI more than I do. The reviewers list receives a summary diff of what changed between iterations—helps when you’re training interns.
To bulk approve everything older than 24 h:
openclaw gmail approve --older-than 24h --add-label sent_by_claw
Troubleshooting tone drift and privacy concerns
Common complaints from the GitHub issues board:
- “It’s suddenly over-formal.” Check if your last imported email was a legal notice. Tag sensitive imports with
--no-train-on. - Hallucinated URLs. Toggle
settings.safe_urls = true; the agent will propose plain-text placeholders for links. - Privacy. If you run local embeddings and set
OPENAI_API_KEY="", no text ever leaves your box. Verified with Wireshark. - Memory bloat. Redis goes OOM above ~3M vectors. Set
memory.ttl_days = 90or switch to Postgres + pgvector.
To inspect what the model actually sees:
openclaw debug last_prompt --json | jq .
or in the Gateway UI: More → Debug Prompt.
Where to go next
After two weeks the agent knows my recurring sign-offs better than I do. The next obvious step is hooking the same persona into Slack DMs and Customer.io. But start small: give OpenClaw 50 mails, set mode: draft_only, and tighten the tone until a coworker can’t tell which messages are machine-authored. Once you hit that bar, flip send_on_approve and reclaim a few hours each week.
If you hit edge cases, file an issue. The repo stays lively—thread #742 on “over-apologetic assistant” got a patch within 24 h. Happy emailing.