roundtable-cloudflare-bot-gate
v0.1.7
Published
Roundtable bot-gate for Cloudflare Pages
Readme
Roundtable × Cloudflare Pages — Bot‑Gate Drop‑In (Beta)
Adds Roundtable's auto‑block gate to any existing Cloudflare Pages project. The block‑list lives in Cloudflare KV, so a hot lookup adds only ~1 ms of latency.
Setup should take 15 minutes max.
1. Embed the Roundtable tracker
<script
src="https://cdn.roundtable.ai/v1/rt.js"
data-site-key="YOUR_SITE_KEY"
data-auto-block="true" <!-- **required** so the gate can call /rt-block -->
data-user-id="OPTIONAL_USER_ID">
</script>Get YOUR_SITE_KEY at https://accounts.roundtable.ai/account/keys. The full tracker docs are available at https://docs.roundtable.ai.
2. Install & initialize
# Add dev dependency
npm i -D roundtable-cloudflare-bot-gate
# Scaffold functions and generate token
npx roundtable-cloudflare-bot-gate initinit does two things:
- Adds
functions/_middleware.jsandfunctions/rt-block.js. - Generates a 64‑char
RT_WEBHOOK_TOKENand prints it.
3. Store the secret in Cloudflare
echo <RT_WEBHOOK_TOKEN> | wrangler secret put RT_WEBHOOK_TOKENUse the token printed by init.
4. Create KV namespaces & add binding
Create the namespaces and copy the generated IDs:
wrangler kv namespace create RT_BLOCKED # copy the production ID
wrangler kv namespace create RT_BLOCKED --preview # copy the preview IDThen add the binding to your Wrangler config:
For wrangler.jsonc:
{
"kv_namespaces": [
{
"binding": "RT_BLOCKED",
"id": "abcd1234...", // paste production ID here
"preview_id": "wxyz5678..." // paste preview ID here
}
]
}For wrangler.toml:
[[kv_namespaces]]
binding = "RT_BLOCKED"
id = "abcd1234..." # paste production ID here
preview_id = "wxyz5678..." # paste preview ID here5. Email your token + webhook URL (beta step)
Send the token printed in step 2 and your webhook endpoint to [email protected] so we can enable blocking for your site.
Endpoint: https://<your‑domain>/rt-block
Token: <RT_WEBHOOK_TOKEN>6. Deploy
wrangler pages deployRoundtable will now write sid:<id> into RT_BLOCKED when it detects fraud; the middleware returns 403 on the very next request.
Need help?
Email [email protected] or open an issue.
