Skip to content

sichengchen/fwd2claw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fwd2claw

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.

Quick Start

Tell your OpenClaw 🦞 to enable the webhook and generate a token. Then,

Deploy to Cloudflare

Setup

Prerequisites

Install

pnpm install

Configure

  1. Edit wrangler.toml and 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 to last.
  2. Set the API token as a secret:

    pnpm wrangler secret put OPENCLAW_API_TOKEN

Deploy

pnpm upload

Enable email routing

In the Cloudflare dashboard:

  1. Go to your domain > Email > Email Routing
  2. Ensure Email Routing is enabled (MX/SPF/DKIM records configured)
  3. Go to the Email Workers tab
  4. Create a route: set a custom address (e.g. agent@yourdomain.com) and select fwd2claw as the destination

Development

pnpm dev          # start local dev server
pnpm typecheck    # run TypeScript type checking

Monitor deployed logs:

pnpm wrangler tail

Project structure

src/
  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

License

MIT

About

Cloudflare Email Worker 📧 -> OpenClaw webhook 🦞

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors