Deploy OpenClaw (Moltbot) to Cloudflare Workers: Step By Step Guide
Chapters12
This chapter introduces building Claudebot, Moldbot, and Open Cloud on Cloudflare workers, and outlines prerequisites such as an Anthropic API key and a Worker plan ($5/month). By the end, you’ll have a running Cloudbot/OpenCloud with backups to R2.
A practical, step-by-step guide to deploying OpenClaw (Moltbot) on Cloudflare Workers with R2 backups and Cloudflare Access.
Summary
Cloudflare Developers walk through deploying OpenClaw (Moltbot) to Cloudflare Workers, including creating a private Git repo, provisioning an R2 bucket, and configuring an Anthropik/Claw API key. The host demonstrates how to wire up a Moldbot gateway token, connect through Cloudflare Access, and pair the device UI with the deployed worker. You'll see how to set environment secrets (AUD and team domain), redeploy after secrets, and finally configure R2 storage so conversations persist. The tutorial emphasizes securing access, pairing the gateway, and validating a working instance that backs up data to R2. The presenter also highlights cost-saving tweaks like enabling sandbox sleep and choosing a smaller instance type. By the end, OpenClaw runs on Cloudflare Workers with backup persistence and a guarded entry point. Expect a 10–15 minute setup in practice, plus a 5-minute pairing flow for the UI. — narrated by the Cloudflare Developers team with live CLI commands, token handling, and UI steps.
Key Takeaways
- You need an Anthropik API key, a Cloudflare Worker Standard plan, and a Moldbot gateway token to start the deployment.
- Create an R2 bucket named moldbot data and note the account ID for Wrangler and secret configuration.
- Enable Cloudflare Access (Aud and team domain) to protect the deployed worker before user interaction.
- Pair the Moldbot gateway token with the deployed domain via the control UI to complete the setup.
- Configure R2 storage with an API token (read/write) to ensure backups persist across container restarts.
- A small instance type (Standard 2) and a sandbox sleep setting can drastically reduce costs on the 5-dollar plan.
- Deployment timing: initial build and deploy can take ~4–5 minutes, with redeploys occurring after secret updates.
Who Is This For?
Essential viewing for Cloudflare developers and AI/automation engineers who want a hands-on guide to deploying OpenClaw on Cloudflare Workers, including secure access, token management, and persistent backups via R2.
Notable Quotes
"Oh my god, you are running Cloudflare workers. Pretty neat."
—Introline establishing excitement about the deployment on Cloudflare Workers.
"We need an anthropic API key. I'll link in the description, but we are going to platform.claw.com."
—Highlighting required API key setup and where to obtain it.
"Cloudflare Access has been enabled. And if I refresh this page, it will ask me to log in."
—Shows securing the deployment with Cloudflare Access before use.
"R2 storage not configured. So that's what we're going to do next."
—Signals transition to configuring persistent backups.
"We've backed up our data."
—Confirms successful data backup configuration after R2 setup.
Questions This Video Answers
- How do I deploy OpenClaw (Moltbot) to Cloudflare Workers with R2 backups?
- What secrets and tokens are required to run OpenClaw on Cloudflare Workers?
- How can I reduce Cloudflare Workers costs when running OpenClaw full-time?
- How do I enable Cloudflare Access and Zero Trust for a Worker deployment?
- What are the steps to configure R2 storage for a Cloudflare Workers project?
Cloudflare WorkersOpenClawMoldbotMoltbotR2 storageWranglerCloudflare AccessZero TrustAPI keysAI assistant deployment
Full Transcript
Oh my god, you are running Cloudflare workers. Pretty neat. Today we'll be setting up Claudebot, Moldbot, Open Cloud, the personal AI assistant. For this tutorial, you don't need to have any prerequisite knowledge, but we'll do need an anthropic key that we'll set up in the video, a worker standard plan account, and it's five bucks a month. And then by the end of this video, you will have a running Cloudbot, OpenCloud, that will make regular backups to R2 and fully running on Cloudflare workers. Let's go. We'll start on this repository and I'll link it in the description, of course.
And what we'll do is we'll click this deploy on Cloudflare, deploy to Cloudflare button. Okay, now we're in the create an application screen or create a worker screen. I have my GitHub already connected and create a new Git repository. I'm going to make it private. And I'm going to call this moldbox moldbot demo. We need an R2. Create new. And we'll call it moldbot data. And since I'm in eastern North America, select this. Okay. Next, we need an anthropic API key. I'll link in the description, but we are going to platform.claw.com. And once you log in, you can click get API key.
Click create key. open claw key add. All right, it's going to show me my API key only once. Copy it, paste it inside of this field here. Now, we need a moldbot gateway token. It's a token that you can use to access your Moldbot web interface. We have an example here that says OpenSSL run hex32. I'll use something like this, but you could also use something like generate token. you know, there's a token generator and and you can use this token. Just make sure it doesn't have any symbols in it, but I'm going to use this because it's in the readme.
So, inside the demo, I'm going to paste this, but you'll see when I paste this, it's going to be a pretty long token. Honestly, it's a little too long for my liking. So, I'm just going to make it a little shorter. Copy this token. Go back to the Mold Moldbot gateway token and paste. It's also smart for you to write these down in a note file or wherever you keep your notes. We'll leave this the same. Click create and deploy. This is going to build and deploy and it will take up to 5 minutes. As you can see, it says cloning git repository.
So, if we go to GitHub, I should now have a repo called mold moldbot demo. Moldbot demo repository with all the required files. Deploying to cloud fashion network will take about four to five minutes and then we'll come back. While this is working, I'm actually going to clone this repository. So inside of my GitHub, the mold demo that was just created, copy this clone URL and inside of my terminal, get clone moldbot demo mold. And inside of there, I can look at the configuration. So this is the mold demo. These are the static assets. This is already set up automatically for us.
This is the build command. Here's the container. And what's [snorts] important is we have the instance type here. The instance type is pretty important because that's what you what you will be build on. We're going to use one instance of the standard type for there's a mobile bucket. The chrome triggers at every 5 minutes the data will be synced to R2. Some browser rendering. And here's more details that we don't need right now. We'll get to this in a second. Go back to the build. See if it's completed yet. Okay, this is looking good. It's deploying now.
Success. Okay, so it took a few minutes and as you can see, it deployed the worker and the worker is now available at this URL. You'll have your own URL, of course. And let me see what happens if I open it. Oops, I'm getting a configuration error. Well, first things first, we need to enable Cloudflare access so that not anybody can just interact with your Modbot. So, I'm going to settings and under this workers.dev, enable Cloudflare access. It's enabled and notice this audience tag here. AUD. I want you to copy this and also make a note of it because it will be important later.
Dismiss. Okay. So now you can see Cloudfare access has been enabled. And if I refresh this page, it will ask me to log in. Now I can log in with my Cloudfare account. Type my email and this will send me a code. So if I open up my Gmail, there will be an email with the access code. Copy it. Go back. Paste. Sign in. Okay. So now at least it's guarded by Cloudflare Access. But as you can see, it's missing two variables. the Cloudfl access team domain and the access AUD. We just copied the access AUD.
So inside of the repository that we cloned inside of my worker, do MPX wrangler secret put cfax AUD. Yep. And the value paste my AUD. I just copied it earlier, so it's not my onetime password. Now I've set this. I need a Cloudflare access team domain. back to my dashboard and we'll be looking for zero trust. You can look here on the side or you can of course do command K and type zero trust. Then under settings it will show you your team domain. For me it's yellow cf atcloudflac.com. Copy that. Now we are going to go back to our terminal again and instead of saying cfax AUD paste the cfax team domain and the team domain copy it again paste enter success uploaded the secret.
Now it will do a quick redeploy. So if I go back to my account I go back to my compute workers and pages moldbot demo. If I go to deployments, you can see it manually deployed 25 seconds ago. Uh that's because I set a new environment variable. So now if I refresh this page, waiting for mold worker to load. We're making progress. Mold worker is ready. And we're greeted with this error. It says invalid or missing token. And that's because we need to pair the gateway. Remember the token we generated earlier? That's the one we need.
So you can say you can see here it says token equals replace with your token. Copy my token again and from here change the URL to question mark token equals paste a token. Another [clears throat] error but a different one. This is good. It says pairing required. Visit this domain. Copy this domain and paste. This looks scary but let's load the devices. After the device list is loaded, you'll see there's a new pairing request and the control UI. So that's our our interface we saw earlier. Approve this. And this can take a couple seconds. Great.
Paired devices. So now it should work. Note that we have this alert R2 storage not configured. So all our conversations will be lost when the container restarts and we don't want that. So we'll set up in a second. But first, let's see if it works. Back to the main page. And we got it working. We have a working Cloud in about 10 minutes. Probably less cuz I fast forward the video. Oh my god, you are running Cloudflare workers. Pretty neat. We set up Cloudbot or Open Cloud. It says Cloudbot control here still. But now the final step before we do anything else is to set up our backup storage.
So remember if we go to this admin panel, it's a hey storage not configured. So that's what we're going to do next. We need these three variables. Go back to my dashboard and under storage there's going to be an R2. So I'm click overview and in here we can find our mold mold pot data. Remember this is what we chose earlier. And another thing that's important that we'll do first is down here you can see your account details. Copy my account ID. Take a note of this account ID. And I might as well also set this secret.
Right. So, CF account ID. So, I open up my terminal. MPX wrangler series. CF account ID. Paste the account ID. Beautiful. Okay, that's one of the three. Now, we need an access key and a secret access key. [snorts] So, still here under account details, click manage. Create a user API demo. Create user API token. And we'll call this R2 open claw. This will have object read and write. We want the credentials to read from this bucket and write to this bucket. For specified buckets only apply to multiple data. This token will be active forever and it can be accessed anywhere.
Create API token. Okay. Successfully created. And when you scroll down, there's two credentials. The access key ID and the secret access key. Let's go back to the admin R2 to access key ID. Let me copy it. So go up here, paste R2 access key ID, copy and paste the R2 access key. Success. Then the other one I need is the secret access key. So let's go back put our two secret access key paste. Okay, great. Now let's go back to our compute and AI workers and pages moldbot demo deployments. Just going to wait for the deployment to be done.
Ah a few seconds ago it's done. So now let me refresh the admin page. R2 storage is configured. Your data will persist across container restart, but it's not backed up. Let's see if I can click backup now. Success. We've backed up our data. So, we now have a fully working open claw instance and we're ready to roll. Awesome. So, there's a few things you need to keep in mind before I end this video is that while it's working on the $5 plan, you do pay for the containers if you keep them running 24/7. So, there's two optimizations you can make.
One is by setting, sorry, I'm scrolling too fast. One is by setting a sandbox sleep after time. So that just means that your mold bot or open clot will go to sleep and then when you need it, it will wake up and it will just take a minute. So that's a great way to save co costs. So I'm going to set for example if I'm not using my bot then sleep after 30 minutes. And also an important thing is the instance type. So if I go to Cloudflare containers and there should be a pricing somewhere pricing these are so currently it's running on the the most expensive the biggest container.
We probably don't need this large instance. So, for example, to save even more money, you can say use the standard two. So, I'm going to open up Wrangler and it uses standard 4 here, right on instance type standard 2. Okay, I need to run npm install and npm run deploy. This will deploy the worker. This will deploy the instance with a less expensive instance. We set up Cloudbot or OpenClaw in about 15 minutes. And now I have my AI assistance running in the cloud without owning any VPS's, any servers, all on Cloudflare's infrastructure. Well done.
Good job. We did it. This was fun. And yeah, let me know in the comments what you want to see next. Peace.
More from Cloudflare Developers
Get daily recaps from
Cloudflare Developers
AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.









