Proactive Inbox: Turning Your Agent into a Personal Email Assistant

2026-02-11Mintu

We've all been there: drowning in a sea of newsletters, notifications, and "quick questions." Most AI assistants are reactive—they wait for you to ask them a question. But with OpenClaw, your agent can become proactive.

In this guide, we'll walk through one of OpenClaw's most powerful (and slightly advanced) features: Gmail Integration via Google Pub/Sub. By the end of this, your agent will be able to watch your inbox, summarize new arrivals, and ping you on WhatsApp or Discord the moment something important lands.

Why Proactive Email?

Imagine being in a meeting or out for a walk and receiving a message like this:

Agent: Hey Aadarsh, you just got an email from the AWS Billing team. Your monthly invoice is 20% higher than last month. Want me to look into the details?

This isn't just a notification; it's a context-aware assistant looking out for you.

How It Works

The architecture involves a few moving parts, but OpenClaw's built-in tools make it manageable:

  1. Gmail API: Sends a "push" notification when your inbox changes.
  2. Google Cloud Pub/Sub: Receives that notification and forwards it to a webhook.
  3. Tailscale Funnel: (Optional but recommended) Provides a secure public endpoint for Google to talk to your local OpenClaw instance.
  4. Gogcli: A lightweight helper that bridges Gmail to OpenClaw.

Setting It Up

1. The Easy Way: The OpenClaw Wizard

If you're on macOS (or have the dependencies ready on Linux), OpenClaw provides a helper command to wire everything together:

openclaw webhooks gmail setup --account your-email@gmail.com

This wizard handles the heavy lifting, including setting up the necessary Google Cloud resources and configuring your local hooks settings.

2. Manual Configuration (The "Power User" Way)

To truly master your inbox, you'll want to configure how the agent handles these emails in your openclaw.json. Here’s a snippet that tells OpenClaw to summarize new emails using a specific model:

{
  hooks: {
    enabled: true,
    presets: ["gmail"],
    mappings: [
      {
        match: { path: "gmail" },
        action: "agent",
        wakeMode: "now",
        name: "Gmail Assistant",
        sessionKey: "hook:gmail:{{messages[0].id}}",
        messageTemplate: "New email from {{messages[0].from}}\nSubject: {{messages[0].subject}}\nSummary: {{messages[0].snippet}}",
        model: "openai/gpt-5-mini", // Use a cheaper model for summaries
        deliver: true, // Send the summary to your chat app
        channel: "last", // Send it back to wherever you last chatted
      },
    ],
  },
}

Security & Privacy

Since you're giving an agent access to your emails, security is paramount. OpenClaw follows several "Safety First" principles:

  • External Content Boundaries: By default, email content is wrapped in <EXTERNAL_UNTRUSTED_CONTENT> tags. This prevents "prompt injection" where a malicious email might try to trick your agent into deleting files or sending sensitive data.
  • Local Processing: Your agent logic and session history stay on your machine. Only the summary (and whatever you ask the agent to do) goes to the LLM provider.
  • Tailscale Integration: Instead of opening ports on your router, OpenClaw supports Tailscale Funnel. This creates an encrypted, authenticated tunnel specifically for the Gmail webhook.

Pro Tip: Filtering the Noise

You don't want your agent pinging you for every "20% off" coupon. You can refine your gog watch command to only look at specific labels or skip the noise:

gog gmail watch start \
  --account your-email@gmail.com \
  --label INBOX \
  --topic projects/your-project-id/topics/gog-gmail-watch

You can even add a "triage" step in your agent's system prompt: "Only notify me if the email is from a human, related to a project I'm working on, or looks like an urgent billing issue. Ignore all marketing."

Conclusion

Integrating Gmail transforms OpenClaw from a "chatbot" into a "digital executive assistant." It’s the difference between using AI and living with AI.

Ready to get started? Check out the full documentation at https://docs.openclaw.ai/automation/gmail-pubsub and reclaim your inbox.