A configurable webhook-to-Bark notification proxy service that allows you to transform incoming webhook payloads into Bark app notifications using customizable rules.
Bark Proxy is a Cloudflare Workers service that:
- 📥 Receives webhook payloads from various services
- 🔄 Transforms them based on predefined rules
- 📤 Forwards them to the Bark notification app
- 💾 Stores rules persistently in Cloudflare KV storage
- Node.js (14.x or later)
- A Cloudflare account
- Wrangler CLI (
npm install -g wrangler)
-
Clone this repository:
git clone https://github.com/Jimmy-Bots/bark_proxy.git cd bark_proxy -
Install dependencies:
npm install
-
Create Cloudflare KV namespaces:
wrangler kv namespace create "bark_proxy_rule" -
Update wrangler.toml with your KV namespace IDs:
[[kv_namespaces]] binding = "bark_proxy_rule" id = "YOUR_KV_NAMESPACE_ID" # Replace with actual ID
-
Deploy to Cloudflare Workers:
# Deploy to production wrangler deploy
POST /rules
Request body:
{
"id": "github-issues",
"name": "GitHub Issues",
"mapping": {
"title": "Issue: ${issue.title}",
"body": "Created by ${sender.login}\n\n${issue.body}",
"group": "GitHub",
"url": "${issue.html_url}",
"sound": "alarm"
},
"barkUrl": "https://api.day.app/YOUR_BARK_KEY"
}Required fields:
id: Unique identifier for the rulename: Human-readable namemapping: Template mapping with requiredtitleandbodyfieldsbarkUrl: Your Bark URL with key
Beta Feature: The template mapping supports basic ternary operations like
${condition ? trueValue : falseValue}. This feature is experimental and may contain bugs.
GET /rules
Returns an array of all configured rules.
GET /rules/:id
Returns a specific rule by its ID.
DELETE /rules/:id
Deletes a rule by its ID.
POST /push
Request body can be in one of these formats:
- With explicit rule ID:
{
"ruleId": "github-issues",
"payload": {
"issue": {
"title": "Example issue",
"body": "This is a test issue",
"html_url": "https://github.com/user/repo/issues/1"
},
"sender": {
"login": "username"
}
}
}- With rule ID in query parameter:
POST /push?ruleId=github-issues
with the webhook payload in the request body.
Templates use the ${path.to.value} syntax to extract values from the webhook payload:
${issue.title}will be replaced with the value frompayload.issue.title${sender.login}will be replaced with the value frompayload.sender.login
{
"id": "github-issue",
"name": "GitHub Issue Notification",
"mapping": {
"title": "GitHub: ${repository.name} - Issue #${issue.number}",
"body": "${issue.title}\n\nOpened by: ${issue.user.login}\n${issue.body}",
"group": "GitHub",
"url": "${issue.html_url}",
"sound": "minuet"
},
"barkUrl": "https://api.day.app/YOUR_BARK_KEY"
}{
"id": "jenkins-build",
"name": "Jenkins Build Status",
"mapping": {
"title": "Build ${build.status}",
"body": "${build.fullDisplayName}\n\nResult: ${build.result}\nDuration: ${build.durationString}",
"group": "Jenkins",
"icon": "${build.status === 'SUCCESS' ? 'https://example.com/success.png' : 'https://example.com/fail.png'}",
"sound": "${build.status === 'SUCCESS' ? 'succeed' : 'warning'}"
},
"barkUrl": "https://api.day.app/YOUR_BARK_KEY"
}-
Start the local development server:
wrangler dev
-
Test your endpoints:
curl -X POST http://host:port/rules -H "Content-Type: application/json" -d '{"id":"test","name":"Test Rule","mapping":{"title":"Test Title","body":"Test Body"},"barkUrl":"https://api.day.app/YOUR_KEY"}'
This project is licensed under the MIT License - see the LICENSE file for details.
- Bark - iOS notification service
- Hono - Ultrafast web framework for Cloudflare Workers
- Cloudflare Workers - Serverless execution environment