📄 todo-cloudflare-email.md 3,900 bytes Apr 23, 2026 📋 Raw

TODO: Cloudflare Email Routing — GET EMAIL FLOWING

Created: 2026-04-23 14:49 UTC
Updated: 2026-04-23 23:37 UTC
Owner: Wadsworth 📋
Goal: Receive emails at assistant@hoffdesk.com → Webhook → Pipeline


Current State

Component Status Notes
DNS (hook.hoffdesk.com) ✅ Fixed Socrates corrected tunnel ID, Error 1033 resolved
Cloudflare Tunnel ✅ Active Cloudflared running on Beelink
Webhook endpoint ✅ Reachable https://hook.hoffdesk.com/health responds
Email Pipeline v2 ✅ Complete 4-class classifier tested, ready for payload
Worker script ❓ Unknown May exist, needs verification
Email routing ❌ Not configured assistant@hoffdesk.com has no route

Phase 1: Verify/Deploy Worker Script

Step 1.1 — Check if worker exists

Cloudflare Dashboard: Workers & Pages → Your Workers

Question Action
Is there a worker for email? Note the name (e.g., email-worker or hoffdesk-email)
No worker found? We'll need to create one (see Step 1.2)

Step 1.2 — Worker requirements (if creating/updating)

The worker must:
- Receive email events from Cloudflare Email Routing
- POST to https://hook.hoffdesk.com/email or your webhook URL
- Include headers: Content-Type: application/json
- Handle auth (shared secret or none if tunnel is sufficient)

Minimal worker script:

export default {
  async email(message, env, ctx) {
    const webhookUrl = "https://hook.hoffdesk.com/email";

    const payload = {
      from: message.from,
      to: message.to,
      subject: message.headers.get("subject") || "",
      text: await message.text(),
      headers: Object.fromEntries(message.headers)
    };

    await fetch(webhookUrl, {
      method: "POST",
      headers: { 
        "Content-Type": "application/json",
        "X-Webhook-Secret": env.WEBHOOK_SECRET || ""
      },
      body: JSON.stringify(payload)
    });
  }
};

Phase 2: Activate Email Routing

Step 2.1 — Enable Email Routing (if not already)

Cloudflare Dashboard: Domain → Email → Email Routing → Overview

Action Status
Click "Start configuring" or "Settings"
Verify MX records are set
Enable "Email Routing"

Step 2.2 — Create Route

Cloudflare Dashboard: Email → Email Routing → Routes

Field Value
Custom address assistant@hoffdesk.com
Action Send to a Worker
Worker [Select your email worker]
Catch-all ❌ No (specific address only for now)

Step 2.3 — Verify DNS Records

Cloudflare should auto-create:
- MX records for email routing
- SPF/DMARC (optional but recommended)


Phase 3: Test End-to-End

Step 3.1 — Quick verification

# Check webhook is ready
curl -s https://hook.hoffdesk.com/health

# Expected: {"status":"ok"} or similar

Step 3.2 — Send test email

Send email to: assistant@hoffdesk.com

Expected flow:
1. Email arrives at Cloudflare
2. Worker triggered
3. POST to webhook
4. Pipeline classifies (appointment/newsletter/family/other)
5. Telegram notification sent

Step 3.3 — Monitor

# Check webhook logs (if available)
tail -f ~/.openclaw/logs/webhook.log 2>/dev/null || echo "Check your webhook service logs"

Quick Reference: Cloudflare Login

  • URL: https://dash.cloudflare.com
  • Domain: hoffdesk.com

Pre-Flight Checklist

Before you start:
- [ ] Cloudflare dashboard access confirmed
- [ ] Domain: hoffdesk.com selected
- [ ] 15-20 minutes available


Questions to answer during setup:
1. Does a worker already exist for email?
2. What webhook URL does it POST to?
3. Is there a shared secret for auth?

Report back with findings — I'll guide next steps.