OpenClaw Gmail Integration for a Company Inbox
How OpenClaw reads Gmail through Pub/Sub, the restricted reader setup that keeps hostile emails harmless, a token cost worked example and what managed hosting takes over.
OpenClaw reads Gmail through Google Pub/Sub. A watcher called gog gmail watch serve receives the push notification and forwards each new email to the OpenClaw Gateway over an HTTP hook. That works well on a personal machine. For a company inbox it raises three questions nobody wants to answer after an incident: what can the agent do with an email that contains hostile instructions, who keeps the watcher alive, and what does the model bill look like on a busy day.
This article is for the person deciding whether to let an OpenClaw agent triage a shared inbox such as support@ or sales@. It lays out what the official setup requires, the safe configuration the OpenClaw docs recommend, a worked cost example, and where managed hosting removes work and where it does not.
How does the OpenClaw Gmail integration work?
Gmail does not call OpenClaw directly. The path has four parts, and each one can fail on its own:
- Gmail watch.
gog gmail watch startasks Gmail to publish INBOX changes to a Pub/Sub topic. The watch expires and has to be renewed. - Pub/Sub topic and push. You create the topic in a Google Cloud project, enable the Gmail and Pub/Sub APIs, and grant
gmail-api-push@system.gserviceaccount.comthe publisher role. - A reachable HTTPS endpoint. Pub/Sub needs a public address to push to. The docs default to Tailscale Funnel, and you can pass your own endpoint instead.
- The Gateway hook. The watcher forwards the email to OpenClaw with a hook token sent in a header. Two separate tokens are involved, a push token and a hook token, and query-string tokens are rejected.
With hooks enabled and a Gmail account configured, the Gateway starts the watcher at boot and renews the watch automatically. The OpenClaw documentation for Gmail Pub/Sub triggers is the source for these steps. If you do not use Gmail, the same page points to an IMAP email trigger plugin that needs no Pub/Sub and no public webhook.
Is it safe to let an AI agent read a company inbox?
Only if the agent that reads mail cannot do much. An email is untrusted text written by a stranger, and an agent with file, shell or browser access can be talked into using them. The OpenClaw docs recommend a restricted reader and spell out how:
| Setting | What it does | Why it matters |
|---|---|---|
Dedicated mail_reader agent | Gmail never runs on your main agent | A bad email cannot reach the agent that holds your real tools |
| Sandbox per session, no workspace access | Each email runs isolated | One message cannot read files left by another |
| Minimal tool profile | Only session_status allowed, filesystem, runtime, web, browser, cron and gateway tools denied | The reader can summarize but not act |
deliver: false by default | Results are logged, not announced | Nothing leaves until you validate the reader |
allowedAgentIds on the hook | The hook can only start mail_reader | The hook token cannot be used to start another agent |
The docs also give a boundary test: send yourself an email with an inert instruction and confirm the run is sandboxed, uses mail_reader and only summarizes. If it visits a link, writes a file or runs a command, the boundary failed. For untrusted inboxes the docs recommend the best model tier you can afford, because stronger models resist injected instructions better.
The same thinking applies to every tool an agent touches, and our OpenClaw security checklist for companies walks through the rest.
What does a triage agent cost on a busy day?
Token cost scales with email volume and message length, so estimate it before you connect the inbox. Here is a worked example with assumptions you can replace with your own.
| Assumption | Value |
|---|---|
| Emails per business day | 150 |
| Average input per email (body, thread context, instructions) | 2,500 tokens |
| Average summary and classification output | 300 tokens |
| Daily input | 375,000 tokens |
| Daily output | 45,000 tokens |
| Over 22 working days | 8.25 million input and 0.99 million output tokens |
Multiply those token counts by the per-million prices your model provider publishes, because prices change and differ by tier. The point of the exercise is the shape: a quiet inbox is cheap, but a newsletter wave or a reply-all storm can multiply input tokens in a day. That is why a daily cap per agent matters more here than on almost any other channel. On ClawEngine every plan is bring your own key, tokens are billed directly by your provider, and daily and monthly budgets stop the agent at its limit. Our guide to controlling OpenClaw model costs covers how to set them.
What does the agent do with the email?
Keep the first version boring. Reading and sorting is a good job for an inbox agent, and sending is a job for a person until you trust the results.
- Classify and label: sales lead, support request, invoice, newsletter, spam that slipped through.
- Summarize long threads into three lines posted to Slack or Microsoft Teams for the owner of that mailbox.
- Draft replies that a person approves. On Business and higher plans, external emails can wait for approval before they go out.
- Pull out the next step. A meeting request becomes a task for whoever books time, for example in a tool such as Schedulemeeting, instead of an agent that guesses at a calendar.
What breaks when you run it yourself?
Most of the failures are operational, not clever. The Gmail watch needs renewing, and the docs describe the Gateway doing that on a schedule. If the listener port is busy the watcher retries after 5, 10 and 20 seconds, then logs an error and stops restarting. A server that sleeps, reboots after an update or loses its public endpoint stops receiving mail, and nobody notices until a customer asks why nobody answered. A batch can carry up to 200 emails, and very large batches can still hit body-size limits.
| Concern | Self-hosted VPS | ClawEngine managed |
|---|---|---|
| Instance uptime and restarts | Your monitoring and your on-call | Monitoring, automatic restart and alerts to Slack or email |
| Isolation | Docker and sandbox you configure | Isolated container with hard RAM and CPU limits per instance |
| Model spend | Provider dashboard and a reminder | Per-agent daily and monthly caps with an automatic stop |
| Recovery | Your backup script | Daily backups with point-in-time restore |
| Risky actions | Whatever you built | Approvals on Business and higher plans |
Managed hosting does not rewrite your Google Cloud project or decide your mail policy. You still choose what the agent may read and send, and someone on your team still owns the Google side. What changes is that the always-on part has an operator. If you want the longer comparison, read OpenClaw Docker versus managed hosting, and the OpenClaw backup page covers recovery.
Which ClawEngine plan fits an inbox agent?
- Team at $24 a month billed yearly ($288 a year), or $49 a month, fits one inbox agent with up to 3 agents and 3 seats. Daily backups are kept 7 days.
- Business at $99.50 a month billed yearly, or $199 a month, adds action approvals, which is the plan to pick when the agent drafts external replies, and keeps backups 30 days.
Compare them on the pricing page, or see how the same agent answers in Microsoft Teams and Slack.
Frequently asked questions
Does OpenClaw work with Gmail?
Yes. OpenClaw receives Gmail events through Google Pub/Sub using the gog watcher, which forwards each new email to the Gateway over an HTTP hook. It needs the gcloud CLI, gog, enabled hooks and a public HTTPS push endpoint. An IMAP email trigger plugin exists for non-Gmail mailboxes.
How do I connect OpenClaw to Gmail?
Run openclaw webhooks gmail setup --account your@address, enable the Gmail and Pub/Sub APIs in a Google Cloud project, create the topic, grant the Gmail push service account publisher rights and start the watch. The Gateway then starts the watcher at boot and renews the watch automatically.
Is it safe to give an AI agent access to my email?
It is safe when the agent reading mail is restricted. Use a dedicated reader agent, sandbox each run, allow only a minimal tool set and keep delivery off until you have tested it with an inert instruction in an email. Never run Gmail on an agent that also has shell or file access.
Can the agent reply to emails by itself?
Technically yes, but start with summaries and drafts. On ClawEngine Business and higher plans, external emails can require human approval before sending, so a person confirms each reply while you build trust in the results.
How much does an OpenClaw email agent cost to run?
The hosting plan starts at $24 a month billed yearly on Team, and model tokens are billed by your own provider. Estimate tokens as emails per day times average input and output size, then set a daily cap so a spike cannot overrun the month.
Build the agent you just read about
Describe the job on our home page and get its workspace files, its first reply and the instance we would host for it.
Build your agent