Skip to content

Conversation

@yomna-shousha
Copy link
Contributor

Summary

Adds a template for receiving Workers Builds notifications via Slack, Discord, or any webhook using Queue Event Subscriptions.

Features

  • Real-time notifications for build success, failure, and cancellation
  • Works with Slack, Discord, or custom webhook endpoints
  • Includes build details: project name, status, duration, commit info
  • Optional build logs and preview/live URLs fetched via Cloudflare API

Preview Image

Included at workers-builds-notifications-template/preview.png — please upload and provide the preview_image_url for package.json.

Checklist

  • Template Metadata
    • template directory ends with -template
    • "cloudflare" section of package.json is populated
    • template preview image uploaded to Images (included as preview.png — needs upload by team)
    • README is populated and uses <!-- dash-content-start --> and <!-- dash-content-end --> to designate the Dash readme preview
    • .gitignore file exists
    • package.json contains a deploy command
    • package.json contains private: true and no version field

# Cloudflare API token
# Create at: https://dash.cloudflare.com/profile/api-tokens
# Select:
# - **Edit Cloudflare Workers** template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need all of the permissions that this grants? Ex: write permissions

(going through setting this up now - I like the guidance in comments)


> **Important:** The queue must be created before deploying the worker.

### 1. Create a Queue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mia303 @jonesphillip if Queues was one of the things that "just worked" like R2/KV/D1:

https://developers.cloudflare.com/changelog/2025-10-24-automatic-resource-provisioning/

Then you could just run wrangler deploy or have this just work with Deploy to Cloudflare.

Today given:

  "queues": {
    "consumers": [
      {
        "queue": "builds-event-subscriptions",
        "max_batch_size": 10,
        "max_batch_timeout": 30,
        "max_retries": 3
      }
    ]
  }

You'll get:

✘ [ERROR] Queue "builds-event-subscriptions" does not exist. To create it, run: wrangler queues create builds-event-subscriptions

But seems entirely feasible to just go create the queue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We even do this flavor of "automatically make a Queue for me" in event subscriptions UI:

Screenshot 2025-12-19 at 5 17 24 PM


```bash
wrangler queues subscription create builds-event-subscriptions \
--source workers-builds \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--source workers-builds \
--source workersBuilds.worker \

```bash
wrangler queues subscription create builds-event-subscriptions \
--source workers-builds \
--events build.started,build.succeeded,build.failed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need Worker name?

✘ [ERROR] --worker-name is required when using source 'workersBuilds.worker'

@irvinebroque
Copy link
Contributor

Take a look at: https://github.com/cloudflare/templates/compare/main...irvinebroque:templates:bib/cleanup-notifications?expand=1

Think with bit more we can present these notifications in a way where your eye goes to the right place and it's intuitive:

Screenshot 2025-12-19 at 5 58 18 PM

^ very quick and not perfect

And think about designing future of what we want a more first-class built in feature to be — what content should get sent to Slack, how should it get presented etc.

@deloreyj deloreyj force-pushed the add-workers-builds-notifications-template branch from 6658fc9 to 37fabec Compare January 7, 2026 13:17
- Add @cloudflare/vitest-pool-workers for proper Workers runtime testing
- Refactor src/index.ts to export testable helper functions
- Rewrite tests with 34 comprehensive unit and integration tests
- Add test/env.d.ts for cloudflare:test type augmentation
- Update tsconfig.json to include test files and proper types
- Configure vitest.config.ts for queue consumer testing
- Add upload_source_maps to wrangler.jsonc
- Update README with detailed setup instructions
- Add preview_image_url for templates gallery
@deloreyj deloreyj force-pushed the add-workers-builds-notifications-template branch from 37fabec to 8d84a2e Compare January 7, 2026 13:19
Reverts accidental whitespace changes (tabs to spaces) that were
introduced during the rebase onto main.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

template name version latestVersion isDevDependency
workers-builds-notifications-template @cloudflare/vitest-pool-workers ^0.11.1 0.12.0 true
workers-builds-notifications-template @cloudflare/workers-types ^4.20241230.0 4.20260103.0 true
workers-builds-notifications-template typescript ^5.5.2 5.9.3 true
workers-builds-notifications-template vitest ~3.0.0 4.0.16 true
workers-builds-notifications-template wrangler ^4.45.0 4.57.0 true

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Preview link not generated: you must be on a branch, not on a fork.
Collaborators may enable previews for this pull request by attaching the allow preview label.
If you are already a collaborator, please create a branch rather than forking.

@deloreyj deloreyj added the allow preview allows for preview links on forks label Jan 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Dashboard preview link

Changed from /queues/configuration/event-subscriptions/ to
/queues/event-subscriptions/
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Dashboard preview link

@deloreyj deloreyj merged commit 63b13f6 into cloudflare:main Jan 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow preview allows for preview links on forks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants