Skip to Content
Legacy Self-HostedCloudflare Workers

Cloudflare Workers Deployment

Deploy OpenClaw on Cloudflare’s edge network using the moltworker container runtime.

Overview

ItemValue
Repositorygithub.com/strataga/moltworkerΒ 
Monthly Cost~$5 (Workers) + API costs
Setup Time5-10 minutes
Control UI/_admin/

We recommend the strataga/moltworker fork instead of the official cloudflare/moltworker. The fork adds the public webhook routes and control-plane fixes used by these deployment examples.

Architecture

Cloudflare Workers β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Hono Router │───▢│ Public Routes (no auth) β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ - /slack/events β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ - /slack/interactions β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ - /discord/interactions β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ - /telegram-webhook β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ │───▢│ Protected Routes (CF Access)β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ - /_admin/* β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ - /api/* β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β–Ό β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Sandbox Containerβ”‚ β”‚ β”‚ β”‚ (OpenClaw Gateway)β”‚ β”‚ β”‚ β”‚ Port 18789 β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Prerequisites

  • Cloudflare account with Workers Paid plan ($5/mo)
  • BYOK provider key
  • Bun installed locally
  • Wrangler CLI (bun add -g wrangler)

Deployment Steps

Clone the Repository

git clone https://github.com/strataga/moltworker.git cd moltworker bun install

Configure Worker Name

Edit wrangler.jsonc to set your worker name:

{ "name": "your-worker-name", // Change this // ... rest of config }

Build and Deploy

bun run build bunx wrangler deploy

Configure Secrets

Required secrets:

bunx wrangler secret put OPENROUTER_API_KEY bunx wrangler secret put MOLTBOT_GATEWAY_TOKEN bunx wrangler secret put CF_ACCESS_TEAM_DOMAIN bunx wrangler secret put CF_ACCESS_AUD

Set Up Cloudflare Access

  1. Go to Zero Trust DashboardΒ 
  2. Create an Access Application for your worker
  3. Set path to /_admin/* (NOT /)
  4. Configure authentication (email OTP is simplest)
  5. Note the Application Audience (AUD) tag
  6. Add the AUD to secrets: CF_ACCESS_AUD

Messaging Integrations

Slack (Coming Soon for Hosted OpenClaw VPS)

For the current public product path, start with web chat or Telegram. If you are experimenting with self-managed Workers, Slack uses HTTP Mode (not Socket Mode).

Create Slack App

  1. Go to api.slack.com/appsΒ 
  2. Create a new app from scratch
  3. Select your workspace

Enable Event Subscriptions

  • Request URL: https://YOUR-WORKER.workers.dev/slack/events
  • Subscribe to bot events:
    • message.channels
    • message.im
    • app_mention

Enable Interactivity

  • Request URL: https://YOUR-WORKER.workers.dev/slack/interactions

Add OAuth Scopes

Under β€œOAuth & Permissions”, add:

  • chat:write
  • channels:history
  • im:history
  • users:read

Install and Configure

  1. Install app to workspace
  2. Copy Bot Token (starts with xoxb-)
  3. Add to Worker secrets:
bunx wrangler secret put SLACK_BOT_TOKEN

Discord

Discord is still coming soon for the hosted public flow. If you are experimenting with self-managed Workers, the manual steps below are the starting point.

Create Discord Application

  1. Go to discord.com/developersΒ 
  2. Create a new application

Configure Interactions Endpoint

  • URL: https://YOUR-WORKER.workers.dev/discord/interactions

Add Bot to Server

  1. Generate OAuth2 URL with bot scope
  2. Select required permissions
  3. Authorize in your server

Add Secret

bunx wrangler secret put DISCORD_BOT_TOKEN

Telegram (Limited Support)

Telegram has fundamental limitations on Cloudflare Workers due to container hibernation. For reliable Telegram support, use VPS deployment.

Why Telegram is unreliable:

  1. OpenClaw uses long-polling by default for Telegram
  2. Cloudflare containers hibernate when idle
  3. Hibernated containers can’t receive poll responses
  4. New messages can’t wake the container

If you must use Telegram:

Set the webhook manually:

curl -X POST "https://api.telegram.org/bot<TOKEN>/setWebhook" \ -H "Content-Type: application/json" \ -d '{"url": "https://YOUR-WORKER.workers.dev/telegram-webhook"}'

Do NOT set TELEGRAM_DM_POLICY - it causes gateway crashes.

Environment Variables

Required

VariableDescription
OPENROUTER_API_KEYBYOK provider API key
MOLTBOT_GATEWAY_TOKENToken for Control UI access
CF_ACCESS_TEAM_DOMAINCloudflare Access team domain
CF_ACCESS_AUDCloudflare Access application audience

Optional

VariableDescription
SLACK_BOT_TOKENSlack bot token (xoxb-…)
DISCORD_BOT_TOKENDiscord bot token
TELEGRAM_BOT_TOKENTelegram bot token (limited support)
DEV_MODESet to β€˜true’ to skip auth (local dev only)
SANDBOX_SLEEP_AFTERDuration before sleep (β€˜never’, β€˜10m’, β€˜1h’)

Cost Breakdown

ItemMonthly Cost
Cloudflare Workers (Paid plan)$5
Provider API usage$10-50 (usage-based)
R2 Storage (optional)~$0.015/GB
Total~$15-55/mo

Need Help?

Contact our teamΒ  if you run into any issues.