A Cloudflare Email Worker that forwards incoming emails to OpenClaw webhooks. OpenClaw handles the email and responds to the sender via their preferred IM channel.
Tell your OpenClaw 🦞 to enable the webhook and generate a token. Then,
- A Cloudflare account with Email Routing enabled on your domain
- An OpenClaw 🦞 with webhook enabled.
pnpm install-
Edit
wrangler.tomland set your OpenClaw webhook URL:[vars] OPENCLAW_WEBHOOK_URL = "https://your-instance.openclaw.ai/hooks/agent" ALLOWED_SENDER = "you@example.com" OPENCLAW_CHANNEL = "last"
ALLOWED_SENDER— only emails from this address will be processed; all others are silently ignored.OPENCLAW_CHANNEL— IM channel for delivery. One of:last,whatsapp,telegram,discord,slack,mattermost,signal,imessage,msteams. Defaults tolast.
-
Set the API token as a secret:
pnpm wrangler secret put OPENCLAW_API_TOKEN
pnpm uploadIn the Cloudflare dashboard:
- Go to your domain > Email > Email Routing
- Ensure Email Routing is enabled (MX/SPF/DKIM records configured)
- Go to the Email Workers tab
- Create a route: set a custom address (e.g.
agent@yourdomain.com) and selectfwd2clawas the destination
pnpm dev # start local dev server
pnpm typecheck # run TypeScript type checkingMonitor deployed logs:
pnpm wrangler tailsrc/
index.ts # Entry point — exports email handler
email-handler.ts # Core handler orchestration
openclaw.ts # OpenClaw webhook client + payload formatting
parse-email.ts # Email parsing via postal-mime
types.ts # Shared TypeScript interfaces
MIT