Skip to main content
AI bot traffic detection — Cloudflare Worker intercepts AI crawler requests at the edge

How It Works

A Cloudflare Worker sits in front of your entire website. Every request passes through it before reaching your origin server. When an AI bot is detected by User-Agent, the Worker logs it to the traffic-ingest-service as a non-blocking background task (ctx.waitUntil), then passes the request through to your origin unchanged. Your real visitors never notice any difference.

Setup

1

Install the Wrangler CLI

Wrangler is Cloudflare’s official CLI for deploying Workers.
Then log in to your Cloudflare account:
2

Create your Worker project

Create a new directory for the Worker (or use the cloudflare-wroker folder from the downloaded files):
3

Create the Worker files

worker.js — Copy the code below into this file:
worker.js
wrangler.toml — Worker configuration:
wrangler.toml
Replace yourdomain.com with your actual domain. The Worker will intercept all traffic matching this pattern.
4

Fill in your credentials

In wrangler.toml under [vars], replace:Also replace yourdomain.com in the routes block with your actual domain.
You can customise the AI_BOT_PATTERNS variable in wrangler.toml to add or remove bots without touching worker.js.
5

Deploy the Worker

From the Worker directory, run:
Wrangler will upload the Worker to Cloudflare’s edge network and activate the route. You should see output like:

Verifying It Works

After deploying, simulate an AI bot request to confirm events flow through:
Check the Traffic section of the Siftly dashboard within a few minutes. You should see an entry for the simulated GPTBot visit.

Updating the Worker

To change the endpoint URL or Organisation ID later:
  1. Edit worker.js with the new values.
  2. Run wrangler deploy again.
Changes propagate globally within seconds.

Troubleshooting

  1. Confirm the route in wrangler.toml matches your domain exactly.
  2. Visit dash.cloudflare.comWorkers & Pages → your worker → Logs to see real-time request logs.
  3. Check the LOG_ENDPOINT URL is correct and the service is reachable.
  4. Test with curl -A "GPTBot/1.0" https://yourdomain.com from a terminal.
The Worker calls return fetch(request) at the end, which proxies the request to your origin unchanged. If something looks wrong, check that you haven’t modified this line.You can also add specific paths to an allowlist or denylist using the matcher pattern in wrangler.toml.
Add multiple route entries to wrangler.toml:
Each domain must be in your Cloudflare account.