Back to Home

Cloudflare Worker Setup

One-click deployment via the AgentFi dashboard using a Cloudflare API Token.

Prefer not to share credentials? You can deploy the Worker manually instead. See the Manual Worker Setup guide. Both methods result in the same Worker.

Prerequisites

  • A Cloudflare account with an active domain (zone).
  • The domain must be using Cloudflare DNS (orange-clouded).
  • A free Cloudflare Workers plan is sufficient.
  • An AgentFi account with at least one site added and crawled.

Step 1: Create a Cloudflare API Token

  1. Go to the Cloudflare API Tokens page.
  2. Click "Create Token".
  3. Find the "Edit Cloudflare Workers" template and click "Use template".
  4. Under Account Resources, select the account that contains the domain you want to integrate.
  5. Under Zone Resources, you can either select "All zones" or restrict to the specific zone for your domain.
  6. Click "Continue to summary", review the permissions, then click "Create Token".
  7. Copy the token immediately — it will only be shown once. Store it in a safe place.

Step 2: Connect in the AgentFi Dashboard

  1. Navigate to Dashboard → AIO → [Your Site] → Integration.
  2. Make sure the "Automatic (API Token)" tab is selected.
  3. Paste your Cloudflare API Token into the token field and click "Connect".
  4. AgentFi will validate the token and retrieve your account information. The status will show "Cloudflare account connected."

Step 3: Deploy the Worker

  1. After connecting, your Cloudflare zones (domains) will be listed in a dropdown. Select the zone matching your site domain.
  2. Click "Deploy Worker". AgentFi will:
    • Upload a Cloudflare Worker script to your account.
    • Create a route binding so the Worker handles requests on your domain.
    • Run an automatic verification to confirm the Worker is responding.
  3. Once deployed, the status card will show "Verified" and a health check schedule will start monitoring your integration every 10 minutes.

What the Worker Does

The AgentFi Cloudflare Worker acts as a transparent proxy on your domain. It intercepts requests to specific paths and proxies them to the AgentFi API:

PathDescription
/llms.txtAI-optimized discovery file
/llms-full.txtFull context discovery file
/sitemap.xmlGenerated sitemap with optimized pages
/robots.txtDynamic robots.txt with AI agent directives
/.well-known/ucpUnified Commerce Protocol profile
/agentfi/pages/*AI-optimized page versions
/agentfi/healthIntegration health check endpoint

All other requests pass through to your origin server unchanged. The Worker also tracks AI bot visits (GPTBot, ClaudeBot, PerplexityBot, etc.) for analytics in the AgentFi dashboard.

Security

  • Your API token is stored securely and is only used to manage Worker scripts and routes on your Cloudflare account.
  • The "Edit Cloudflare Workers" template grants the minimum permissions needed: Workers script write and route write access.
  • You can revoke the token at any time from the Cloudflare API Tokens page. Note that revoking will prevent AgentFi from redeploying or updating the Worker.
  • You can also disconnect Cloudflare from the Integration page at any time, which will remove the Worker from your account.

Health Monitoring

Once deployed and verified, AgentFi automatically monitors your integration every 10 minutes. If the Worker becomes unreachable (e.g., deleted or route changed), the dashboard will show a warning and the integration will be paused until the issue is resolved.

You can re-deploy the Worker at any time from the Integration page by clicking "Redeploy Worker."