Get notified when your Workers Builds complete, fail, or are cancelled. This template uses Queue Event Subscriptions to consume Workers Builds events and forward them to any webhook — Slack, Discord, or your own endpoint.
- 🔔 Real-time notifications for build success, failure, and cancellation
- 🔗 Works with any webhook (Slack, Discord, custom endpoints)
- 📋 Includes build details: project name, branch, commit, and author
- 📜 Smart error extraction for failed builds, preview URL and live deployment URL for successful builds
- Workers Builds emits events to a Cloudflare Queue
- This Worker consumes those events via Queue Event Subscriptions
- Build details are formatted and sent to your configured webhook
Outside of this repo, you can start a new project with this template using C3 (the create-cloudflare CLI):
npm create cloudflare@latest -- --template=cloudflare/templates/workers-builds-notifications-templateImportant: The queue must be created before deploying the worker.
- Go to Queues
- Click Create Queue
- Name it
builds-event-subscriptions(or your preferred name) - Click Create
wrangler queues create builds-event-subscriptionsNote: The queue name must match what's in
wrangler.jsonc:If you use a different queue name, update
wrangler.jsoncbefore deploying.
- Go to Workers & Pages → Create → Import a repository
- Connect your GitHub/GitLab and select this repository
- Deploy
git clone https://github.com/cloudflare/templates.git
cd templates/workers-builds-notifications-template
npm install
wrangler deploy- Go to Slack Apps → Create New App → From scratch
- Name it (e.g., "Workers Builds Notifications") and select your workspace
- Go to Incoming Webhooks → Toggle On
- Click Add New Webhook to Workspace → Select your channel
- Copy the webhook URL
- Go to your Discord server → Server Settings → Integrations → Webhooks
- Click New Webhook → Select your channel
- Copy the webhook URL
- Append
/slackto the URL (Discord supports Slack-formatted payloads)
Modify the payload format in src/index.ts to match your webhook's expected format.
- Go to Cloudflare API Tokens
- Click Create Token → Create Custom Token
- Add the following permissions:
- Workers Builds Configuration: Read
- Workers Scripts: Read
- Click Continue to summary → Create Token
- Copy the token
- Go to Workers & Pages
- Select your deployed worker
- Go to Settings → Variables and Secrets
- Add:
SLACK_WEBHOOK_URL→ Your webhook URLCLOUDFLARE_API_TOKEN→ Your API token
wrangler secret put SLACK_WEBHOOK_URL
# Paste your webhook URL
wrangler secret put CLOUDFLARE_API_TOKEN
# Paste your API tokenSubscribe your queue to Workers Builds events.
- Go to Queues
- Select your queue (
builds-event-subscriptions) - Go to the Subscriptions tab
- Click Subscribe to events
- Select source: Workers Builds
- Select events: All (or specific ones)
- Click Subscribe
wrangler queues subscription create builds-event-subscriptions \
--source workersBuilds.worker \
--events build.succeeded,build.failed \
--worker-name <YOUR_CONSUMER_WORKER_NAME>For more details, see Event Subscriptions Documentation
Trigger a build on any worker in your account. You should see a notification in your channel within seconds!
┌─────────────────┐ ┌─────────────┐ ┌──────────────────┐ ┌─────────┐
│ Workers Builds │────▶│ Queue │────▶│ This Consumer │────▶│ Webhook │
│ (any worker) │ │ │ │ Worker │ │ │
└─────────────────┘ └─────────────┘ └──────────────────┘ └─────────┘
- Any worker in your account triggers a build
- Workers Builds publishes an event to your Queue
- This consumer worker processes the event and sends a notification to your webhook
| Event | Notification |
|---|---|
| ✅ Build succeeded (production) | Live Worker URL |
| ✅ Build succeeded (preview) | Preview URL |
| ❌ Build failed | Error message |
| Cancellation note |
Note: Build started/queued events are acknowledged but do not send notifications.
{
"type": "cf.workersBuilds.worker.build.succeeded",
"source": {
"type": "workersBuilds.worker",
"workerName": "my-worker"
},
"payload": {
"buildUuid": "build-12345678-90ab-cdef-1234-567890abcdef",
"status": "stopped",
"buildOutcome": "success",
"createdAt": "2025-05-01T02:48:57.132Z",
"stoppedAt": "2025-05-01T02:50:15.132Z",
"buildTriggerMetadata": {
"buildTriggerSource": "push_event",
"branch": "main",
"commitHash": "abc123def456",
"commitMessage": "Fix bug in authentication",
"author": "[email protected]",
"repoName": "my-worker-repo",
"providerType": "github"
}
},
"metadata": {
"accountId": "your-account-id",
"eventTimestamp": "2025-05-01T02:48:57.132Z"
}
}| Event Type | Description |
|---|---|
cf.workersBuilds.worker.build.started |
Build has started |
cf.workersBuilds.worker.build.succeeded |
Build completed successfully |
cf.workersBuilds.worker.build.failed |
Build failed |
cf.workersBuilds.worker.build.failed + buildOutcome: "cancelled" |
Build was cancelled |
| Variable | Description |
|---|---|
SLACK_WEBHOOK_URL |
Webhook URL (Slack, Discord, or custom) |
CLOUDFLARE_API_TOKEN |
API token with Workers Builds Configuration: Read and Workers Scripts: Read |
| Setting | Default | Description |
|---|---|---|
max_batch_size |
10 | Messages per batch |
max_batch_timeout |
30 | Seconds to wait for full batch |
max_retries |
3 | Retry attempts for failed processing |
The queue must be created before deploying. See Step 1: Create a Queue.
- Check the queue: Dashboard → Queues → Your queue (are messages arriving?)
- Check worker logs: Dashboard → Workers → Your consumer worker → Logs
- Verify subscription: Dashboard → Queues → Your queue → Subscriptions tab
- Verify
CLOUDFLARE_API_TOKENis set in worker settings - Ensure token has correct permissions (Workers Builds Configuration: Read, Workers Scripts: Read)
- Preview URL missing: Build was for main/master branch (shows Live URL instead)
- Live URL missing: Check token has correct permissions