Skip to content

Open-source status page, incident response and uptime monitoring

πŸ”” ntfy.sh (#1218)

Thibault Le Ouay407c23a42652
diff --git a/apps/docs/src/content/docs/alerting/providers/ntfy.mdx b/apps/docs/src/content/docs/alerting/providers/ntfy.mdx
new file mode 100644
index 000000000..2f152cf9a
--- /dev/null
+++ b/apps/docs/src/content/docs/alerting/providers/ntfy.mdx
@@ -0,0 +1,13 @@
+---
+title: ntfy.sh
+description: "How to set up ntfy.sh notifications in OpenStatus to get alerts when your synthetic check fail"
+---
+
+[ntfy.sh](https://ntfy.sh/) is an open-source servicer that allows you to receive push notifications on your phone.
+
+
+
+
+Go to the Notifications Page . Select `ntfy.sh` from the list of available integrations.
+
+Enter your ntfy topic (required), your custom server URL, and your bearer token.
\ No newline at end of file
diff --git a/apps/docs/src/content/docs/alerting/providers/pagerduty.mdx b/apps/docs/src/content/docs/alerting/providers/pagerduty.mdx
index c28b7d3c5..258d6ee29 100644
--- a/apps/docs/src/content/docs/alerting/providers/pagerduty.mdx
+++ b/apps/docs/src/content/docs/alerting/providers/pagerduty.mdx
@@ -12,7 +12,7 @@ Get Notified on PagerDuty when we create an incident.
## How to connect PagerDuty
-Go to the Alerts Page . Select `PagerDuty` from the list of available integrations.
+Go to the Notifications Page . Select `PagerDuty` from the list of available integrations.
diff --git a/apps/web/package.json b/apps/web/package.json
index 100139f7c..f7f3ad5a3 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -25,6 +25,7 @@
"@openstatus/header-analysis": "workspace:*",
"@openstatus/notification-discord": "workspace:*",
"@openstatus/notification-emails": "workspace:*",
+ "@openstatus/notification-ntfy": "workspace:*",
"@openstatus/notification-pagerduty": "workspace:*",
"@openstatus/notification-slack": "workspace:*",
"@openstatus/notification-opsgenie": "workspace:*",
diff --git a/apps/web/public/assets/changelog/ntfy.png b/apps/web/public/assets/changelog/ntfy.png
new file mode 100644
index 000000000..842819bff
Binary files /dev/null and b/apps/web/public/assets/changelog/ntfy.png differ
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/(overview)/_components/channel-table.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/(overview)/_components/channel-table.tsx
index 3be127107..0cc464b80 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/(overview)/_components/channel-table.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/(overview)/_components/channel-table.tsx
@@ -1,6 +1,5 @@
import { env } from "@/env";
import type { Workspace } from "@openstatus/db/src/schema";
-import { getLimit } from "@openstatus/db/src/schema/plan/utils";
import { Button, Separator } from "@openstatus/ui";
import Link from "next/link";
@@ -32,6 +31,20 @@ export default function ChannelTable({ workspace, disabled }: ChannelTable) {
disabled={disabled}
/>
<Separator />
+ <Channel
+ title="ntfy.sh"
+ description="Send notifications by ntfy.sh."
+ href="./notifications/new/ntfy"
+ disabled={disabled}
+ />
+ <Separator />
+ <Channel
+ title="OpsGenie"
+ description="Send notifications to OpsGenie."
+ href="./notifications/new/opsgenie"
+ disabled={disabled || !workspace.limits.opsgenie}
+ />
+ <Separator />
<Channel
title="PagerDuty"
description="Send notifications to PagerDuty."
@@ -57,12 +70,6 @@ export default function ChannelTable({ workspace, disabled }: ChannelTable) {
disabled={disabled || !workspace.limits.sms}
/>
<Separator />
- <Channel
- title="OpsGenie"
- description="Send notifications to OpsGenie."
- href="./notifications/new/opsgenie"
- disabled={disabled || !workspace.limits.opsgenie}
- />
</div>
</div>
);
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/[channel]/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/[channel]/page.tsx
index b258b1d6e..81d3e3eb6 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/[channel]/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/notifications/new/[channel]/page.tsx
@@ -32,7 +32,6 @@ export default async function ChannelPage(props: {
if (isLimitReached) {
return <ProFeatureAlert feature="More notification channel" />;
}
-
return (
<NotificationForm
workspacePlan={workspace.plan}
diff --git a/apps/web/src/components/forms/notification/general.tsx b/apps/web/src/components/forms/notification/general.tsx
index a71f57f43..718c1e251 100644
--- a/apps/web/src/components/forms/notification/general.tsx
+++ b/apps/web/src/components/forms/notification/general.tsx
@@ -20,6 +20,7 @@ import {
import { SectionHeader } from "../shared/section-header";
import { SectionDiscord } from "./provider/section-discord";
import { SectionEmail } from "./provider/section-email";
+import { SectionNtfy } from "./provider/section-ntfy";
import { SectionOpsGenie } from "./provider/section-opsgenie";
import { SectionPagerDuty } from "./provider/section-pagerduty";
import { SectionSlack } from "./provider/section-slack";
@@ -32,6 +33,7 @@ const LABELS = {
pagerduty: "PagerDuty",
opsgenie: "OpsGenie",
email: "Email",
+ ntfy: "Ntfy.sh",
};
interface Props {
@@ -56,6 +58,8 @@ export function General({ form, plan }: Props) {
return <SectionOpsGenie form={form} plan={plan} />;
case "email":
return <SectionEmail form={form} />;
+ case "ntfy":
+ return <SectionNtfy form={form} />;
default:
return <div>No provider selected</div>;
}
diff --git a/apps/web/src/components/forms/notification/provider/actions.ts b/apps/web/src/components/forms/notification/provider/actions.ts
index ec0322c6f..300b90791 100644
--- a/apps/web/src/components/forms/notification/provider/actions.ts
+++ b/apps/web/src/components/forms/notification/provider/actions.ts
@@ -3,6 +3,8 @@
import { sendTest as sendOpsGenieAlert } from "@openstatus/notification-opsgenie";
import { sendTest as sendPagerDutyAlert } from "@openstatus/notification-pagerduty";
+
+import { sendTest as sendNtfyAlert } from "@openstatus/notification-ntfy";
export async function sendOpsGenieTestAlert(
apiKey: string,
region: "us" | "eu",
@@ -17,3 +19,16 @@ export async function sendPagerDutyTestAlert(integrationKey: string) {
});
return isSuccessfull;
}
+
+export async function sendNtfyTestAlert({
+ topic,
+ serverUrl,
+ token,
+}: {
+ topic: string;
+ serverUrl?: string;
+ token?: string;
+}) {
+ const isSuccessfull = await sendNtfyAlert({ topic, serverUrl, token });
+ return isSuccessfull;
+}
diff --git a/apps/web/src/components/forms/notification/provider/section-ntfy.tsx b/apps/web/src/components/forms/notification/provider/section-ntfy.tsx
new file mode 100644
index 000000000..289a48b36
--- /dev/null
+++ b/apps/web/src/components/forms/notification/provider/section-ntfy.tsx
@@ -0,0 +1,106 @@
+"use client";
+
+import { toastAction } from "@/lib/toast";
+import type { UseFormReturn } from "react-hook-form";
+
+import { LoadingAnimation } from "@/components/loading-animation";
+import type { InsertNotificationWithData } from "@openstatus/db/src/schema";
+import {
+ Button,
+ FormControl,
+ FormDescription,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+ Input,
+} from "@openstatus/ui";
+import { useTransition } from "react";
+import { sendNtfyTestAlert } from "./actions";
+
+interface Props {
+ form: UseFormReturn<InsertNotificationWithData>;
+}
+
+export function SectionNtfy({ form }: Props) {
+ const [isTestPending, startTestTransition] = useTransition();
+
+ const watchTopic = form.watch("data.ntfy.topic");
+ const watchUrl = form.watch("data.ntfy.serverUrl");
+ const watchToken = form.watch("data.ntfy.token");
+
+ async function sendTestAlert() {
+ if (!watchTopic) return;
+ startTestTransition(async () => {
+ const isSuccessfull = await sendNtfyTestAlert({
+ topic: watchTopic,
+ serverUrl: watchUrl || undefined,
+ token: watchToken || undefined,
+ });
+ if (isSuccessfull) {
+ toastAction("test-success");
+ } else {
+ toastAction("test-error");
+ }
+ });
+ }
+
+ return (
+ <>
+ <FormField
+ control={form.control}
+ name="data.ntfy.topic"
+ render={({ field }) => (
+ <FormItem className="sm:col-span-full">
+ <FormLabel>Topic</FormLabel>
+ <FormControl>
+ <Input type="text" placeholder="your-topic" required {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <FormField
+ control={form.control}
+ name="data.ntfy.serverUrl"
+ render={({ field }) => (
+ <FormItem className="sm:col-span-full">
+ <FormLabel>URL</FormLabel>
+ <FormControl>
+ <Input type="url" placeholder="https://ntfy.sh" {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <FormField
+ control={form.control}
+ name="data.ntfy.token"
+ render={({ field }) => (
+ <FormItem className="sm:col-span-full">
+ <FormLabel>Bearer Token</FormLabel>
+ <FormControl>
+ <Input type="url" placeholder="tk_iloveopenstatus" {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <div className="col-span-full text-right">
+ <Button
+ type="button"
+ variant="secondary"
+ className="w-full sm:w-auto"
+ disabled={isTestPending || !watchTopic}
+ onClick={sendTestAlert}
+ >
+ {!isTestPending ? (
+ "Test Webhook"
+ ) : (
+ <LoadingAnimation variant="inverse" />
+ )}
+ </Button>
+ </div>
+ </>
+ );
+}
diff --git a/apps/web/src/config/pricing-table.tsx b/apps/web/src/config/pricing-table.tsx
index a7fb49fbe..51ceff789 100644
--- a/apps/web/src/config/pricing-table.tsx
+++ b/apps/web/src/config/pricing-table.tsx
@@ -110,7 +110,7 @@ export const pricingTableConfig: Record<
features: [
{
value: "notifications",
- label: "Slack, Discord, Email",
+ label: "Slack, Discord, Email, ntfy.sh",
},
{
value: "sms",
diff --git a/apps/web/src/content/changelog/ntfh-sh-integration.mdx b/apps/web/src/content/changelog/ntfh-sh-integration.mdx
new file mode 100644
index 000000000..5fb856970
--- /dev/null
+++ b/apps/web/src/content/changelog/ntfh-sh-integration.mdx
@@ -0,0 +1,13 @@
+---
+title: ntfy.sh Integration
+description: Get notified via ntfy.sh if we detect an Incident.
+image: /assets/changelog/ntfy.png
+publishedAt: 2025-03-17
+---
+You can now receive notifications via ntfy.sh when we detect an incident.
+
+[ntfy.sh](https://ntfy.sh/) is an open-source servicer that allows you to receive push notifications on your phone.
+
+We love open source, so we've added this integration to our free plan.
+
+Open source FTW πŸš€
\ No newline at end of file
diff --git a/apps/workflows/Dockerfile b/apps/workflows/Dockerfile
index 386f582a4..18d816242 100644
--- a/apps/workflows/Dockerfile
+++ b/apps/workflows/Dockerfile
@@ -13,6 +13,7 @@ RUN \
--mount=type=bind,target=packages/emails/package.json,source=packages/emails/package.json \
--mount=type=bind,target=packages/notifications/discord/package.json,source=packages/notifications/discord/package.json \
--mount=type=bind,target=packages/notifications/email/package.json,source=packages/notifications/email/package.json \
+ --mount=type=bind,target=packages/notifications/ntfy/package.json,source=packages/notifications/ntfy/package.json \
--mount=type=bind,target=packages/notifications/opsgenie/package.json,source=packages/notifications/opsgenie/package.json \
--mount=type=bind,target=packages/notifications/pagerduty/package.json,source=packages/notifications/pagerduty/package.json \
--mount=type=bind,target=packages/notifications/slack/package.json,source=packages/notifications/slack/package.json \
diff --git a/apps/workflows/dofigen.lock b/apps/workflows/dofigen.lock
index 6c8264091..57730a092 100644
--- a/apps/workflows/dofigen.lock
+++ b/apps/workflows/dofigen.lock
@@ -51,6 +51,8 @@ effective: |
source: packages/notifications/discord/package.json
- target: packages/notifications/email/package.json
source: packages/notifications/email/package.json
+ - target: packages/notifications/ntfy/package.json
+ source: packages/notifications/ntfy/package.json
- target: packages/notifications/opsgenie/package.json
source: packages/notifications/opsgenie/package.json
- target: packages/notifications/pagerduty/package.json
@@ -92,7 +94,7 @@ images:
digest: sha256:e831d9a884d63734fe3dd9c491ed9a5a3d4c6a6d32c5b14f2067357c49b0b7e1
resources:
dofigen.yml:
- hash: 89efc794b70865f5718e42302021382f7ed0c0ea9459a7bd9a8047cdd28757ae
+ hash: 756c481a0bf4efc02d00ba1da6a9d84960b3424e625d492ef4c93ec841d075f6
content: |
ignore:
- node_modules
@@ -117,6 +119,7 @@ resources:
- packages/emails/package.json
- packages/notifications/discord/package.json
- packages/notifications/email/package.json
+ - packages/notifications/ntfy/package.json
- packages/notifications/opsgenie/package.json
- packages/notifications/pagerduty/package.json
- packages/notifications/slack/package.json
diff --git a/apps/workflows/dofigen.yml b/apps/workflows/dofigen.yml
index d78b81c04..0060e463d 100644
--- a/apps/workflows/dofigen.yml
+++ b/apps/workflows/dofigen.yml
@@ -21,6 +21,7 @@ builders:
- packages/emails/package.json
- packages/notifications/discord/package.json
- packages/notifications/email/package.json
+ - packages/notifications/ntfy/package.json
- packages/notifications/opsgenie/package.json
- packages/notifications/pagerduty/package.json
- packages/notifications/slack/package.json
diff --git a/apps/workflows/package.json b/apps/workflows/package.json
index 6358e7cf4..bdb378194 100644
--- a/apps/workflows/package.json
+++ b/apps/workflows/package.json
@@ -11,6 +11,7 @@
"@openstatus/emails": "workspace:*",
"@openstatus/notification-discord": "workspace:*",
"@openstatus/notification-emails": "workspace:*",
+ "@openstatus/notification-ntfy": "workspace:*",
"@openstatus/notification-opsgenie": "workspace:*",
"@openstatus/notification-pagerduty": "workspace:*",
"@openstatus/notification-slack": "workspace:*",
diff --git a/apps/workflows/src/checker/utils.ts b/apps/workflows/src/checker/utils.ts
index be6d123db..7af616926 100644
--- a/apps/workflows/src/checker/utils.ts
+++ b/apps/workflows/src/checker/utils.ts
@@ -13,6 +13,11 @@ import {
sendDegraded as sendEmailDegraded,
sendRecovery as sendEmailRecovery,
} from "@openstatus/notification-emails";
+import {
+ sendAlert as sendNtfyAlert,
+ sendDegraded as sendNtfyDegraded,
+ sendRecovery as sendNtfyRecovery,
+} from "@openstatus/notification-ntfy";
import {
sendAlert as sendSlackAlert,
sendDegraded as sendSlackDegraded,
@@ -32,6 +37,7 @@ import {
import type { Region } from "@openstatus/db/src/schema/constants";
import {
+ sendAlert,
sendAlert as sendOpsGenieAlert,
sendDegraded as sendOpsGenieDegraded,
sendRecovery as sendOpsGenieRecovery,
@@ -64,25 +70,20 @@ type Notif = {
};
export const providerToFunction = {
- email: {
- sendAlert: sendEmailAlert,
- sendRecovery: sendEmailRecovery,
- sendDegraded: sendEmailDegraded,
- },
- slack: {
- sendAlert: sendSlackAlert,
- sendRecovery: sendSlackRecovery,
- sendDegraded: sendSlackDegraded,
- },
discord: {
sendAlert: sendDiscordAlert,
sendRecovery: sendDiscordRecovery,
sendDegraded: sendDiscordDegraded,
},
- sms: {
- sendAlert: sendSmsAlert,
- sendRecovery: sendSmsRecovery,
- sendDegraded: sendSmsDegraded,
+ email: {
+ sendAlert: sendEmailAlert,
+ sendRecovery: sendEmailRecovery,
+ sendDegraded: sendEmailDegraded,
+ },
+ ntfy: {
+ sendAlert: sendNtfyAlert,
+ sendRecovery: sendNtfyRecovery,
+ sendDegraded: sendNtfyDegraded,
},
opsgenie: {
sendAlert: sendOpsGenieAlert,
@@ -94,4 +95,14 @@ export const providerToFunction = {
sendRecovery: sendPagerDutyRecovery,
sendDegraded: sendPagerDutyDegraded,
},
+ slack: {
+ sendAlert: sendSlackAlert,
+ sendRecovery: sendSlackRecovery,
+ sendDegraded: sendSlackDegraded,
+ },
+ sms: {
+ sendAlert: sendSmsAlert,
+ sendRecovery: sendSmsRecovery,
+ sendDegraded: sendSmsDegraded,
+ },
} satisfies Record<NotificationProvider, Notif>;
diff --git a/packages/db/src/schema/notifications/constants.ts b/packages/db/src/schema/notifications/constants.ts
index 6ca77d890..6aba6014b 100644
--- a/packages/db/src/schema/notifications/constants.ts
+++ b/packages/db/src/schema/notifications/constants.ts
@@ -1,8 +1,9 @@
export const notificationProvider = [
"email",
"discord",
- "slack",
- "sms",
+ "ntfy",
"pagerduty",
"opsgenie",
+ "slack",
+ "sms",
] as const;
diff --git a/packages/db/src/schema/notifications/validation.ts b/packages/db/src/schema/notifications/validation.ts
index 3c1563dae..bd391de55 100644
--- a/packages/db/src/schema/notifications/validation.ts
+++ b/packages/db/src/schema/notifications/validation.ts
@@ -36,6 +36,13 @@ export const phoneSchema = z.string().regex(phoneRegex, "Invalid Number!");
export const emailSchema = z.string().email();
export const urlSchema = z.string().url();
+export const ntfyDataSchema = z.object({
+ ntfy: z.object({
+ topic: z.string().default(""),
+ serverUrl: z.string().default("https://ntfy.sh"),
+ token: z.string().optional(),
+ }),
+});
export const webhookDataSchema = z.object({ webhook: urlSchema });
export const emailDataSchema = z.object({ email: emailSchema });
export const phoneDataSchema = z.object({ sms: phoneSchema });
@@ -61,6 +68,12 @@ export const NotificationDataSchema = z.union([
export const InsertNotificationWithDataSchema = z.discriminatedUnion(
"provider",
[
+ insertNotificationSchema.merge(
+ z.object({
+ provider: z.literal("discord"),
+ data: discordDataSchema,
+ }),
+ ),
insertNotificationSchema.merge(
z.object({
provider: z.literal("email"),
@@ -69,32 +82,32 @@ export const InsertNotificationWithDataSchema = z.discriminatedUnion(
),
insertNotificationSchema.merge(
z.object({
- provider: z.literal("sms"),
- data: phoneDataSchema,
+ provider: z.literal("ntfy"),
+ data: ntfyDataSchema,
}),
),
insertNotificationSchema.merge(
z.object({
- provider: z.literal("slack"),
- data: slackDataSchema,
+ provider: z.literal("pagerduty"),
+ data: pagerdutyDataSchema,
}),
),
insertNotificationSchema.merge(
z.object({
- provider: z.literal("discord"),
- data: discordDataSchema,
+ provider: z.literal("opsgenie"),
+ data: opsgenieDataSchema,
}),
),
insertNotificationSchema.merge(
z.object({
- provider: z.literal("pagerduty"),
- data: pagerdutyDataSchema,
+ provider: z.literal("sms"),
+ data: phoneDataSchema,
}),
),
insertNotificationSchema.merge(
z.object({
- provider: z.literal("opsgenie"),
- data: opsgenieDataSchema,
+ provider: z.literal("slack"),
+ data: slackDataSchema,
}),
),
],
diff --git a/packages/notifications/ntfy/.gitignore b/packages/notifications/ntfy/.gitignore
new file mode 100644
index 000000000..f81d56eaa
--- /dev/null
+++ b/packages/notifications/ntfy/.gitignore
@@ -0,0 +1,169 @@
+# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
+
+# Logs
+
+logs
+_.log
+npm-debug.log_
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+.pnpm-debug.log*
+
+# Diagnostic reports (https://nodejs.org/api/report.html)
+
+report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
+
+# Runtime data
+
+pids
+_.pid
+_.seed
+\*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+
+lib-cov
+
+# Coverage directory used by tools like istanbul
+
+coverage
+\*.lcov
+
+# nyc test coverage
+
+.nyc_output
+
+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
+
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+
+bower_components
+
+# node-waf configuration
+
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+
+build/Release
+
+# Dependency directories
+
+node_modules/
+jspm_packages/
+
+# Snowpack dependency directory (https://snowpack.dev/)
+
+web_modules/
+
+# TypeScript cache
+
+\*.tsbuildinfo
+
+# Optional npm cache directory
+
+.npm
+
+# Optional eslint cache
+
+.eslintcache
+
+# Optional stylelint cache
+
+.stylelintcache
+
+# Microbundle cache
+
+.rpt2_cache/
+.rts2_cache_cjs/
+.rts2_cache_es/
+.rts2_cache_umd/
+
+# Optional REPL history
+
+.node_repl_history
+
+# Output of 'npm pack'
+
+\*.tgz
+
+# Yarn Integrity file
+
+.yarn-integrity
+
+# dotenv environment variable files
+
+.env
+.env.development.local
+.env.test.local
+.env.production.local
+.env.local
+
+# parcel-bundler cache (https://parceljs.org/)
+
+.cache
+.parcel-cache
+
+# Next.js build output
+
+.next
+out
+
+# Nuxt.js build / generate output
+
+.nuxt
+dist
+
+# Gatsby files
+
+.cache/
+
+# Comment in the public line in if your project uses Gatsby and not Next.js
+
+# https://nextjs.org/blog/next-9-1#public-directory-support
+
+# public
+
+# vuepress build output
+
+.vuepress/dist
+
+# vuepress v2.x temp and cache directory
+
+.temp
+.cache
+
+# Docusaurus cache and generated files
+
+.docusaurus
+
+# Serverless directories
+
+.serverless/
+
+# FuseBox cache
+
+.fusebox/
+
+# DynamoDB Local files
+
+.dynamodb/
+
+# TernJS port file
+
+.tern-port
+
+# Stores VSCode versions used for testing VSCode extensions
+
+.vscode-test
+
+# yarn v2
+
+.yarn/cache
+.yarn/unplugged
+.yarn/build-state.yml
+.yarn/install-state.gz
+.pnp.\*
diff --git a/packages/notifications/ntfy/README.md b/packages/notifications/ntfy/README.md
new file mode 100644
index 000000000..f2b93f4c0
--- /dev/null
+++ b/packages/notifications/ntfy/README.md
@@ -0,0 +1,15 @@
+# @openstatus/notification-ntfy
+To install dependencies:
+
+```bash
+bun install
+```
+
+To run:
+
+```bash
+bun run src/index.ts
+```
+
+This project was created using `bun init` in bun v1.0.0. [Bun](https://bun.sh)
+is a fast all-in-one JavaScript runtime.
diff --git a/packages/notifications/ntfy/package.json b/packages/notifications/ntfy/package.json
new file mode 100644
index 000000000..dc87604da
--- /dev/null
+++ b/packages/notifications/ntfy/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "@openstatus/notification-ntfy",
+ "version": "1.0.0",
+ "main": "src/index.ts",
+ "dependencies": {
+ "@openstatus/db": "workspace:*",
+ "zod": "3.23.8"
+ },
+ "devDependencies": {
+ "@openstatus/tsconfig": "workspace:*",
+ "@types/node": "22.10.2",
+ "typescript": "5.6.2"
+ }
+}
diff --git a/packages/notifications/ntfy/src/index.ts b/packages/notifications/ntfy/src/index.ts
new file mode 100644
index 000000000..5efa2ec78
--- /dev/null
+++ b/packages/notifications/ntfy/src/index.ts
@@ -0,0 +1,166 @@
+import type { Monitor, Notification } from "@openstatus/db/src/schema";
+
+import type { Region } from "@openstatus/db/src/schema/constants";
+import { NtfySchema } from "./schema";
+
+export const sendAlert = async ({
+ monitor,
+ notification,
+ statusCode,
+ message,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ incidentId,
+}: {
+ monitor: Monitor;
+ notification: Notification;
+ statusCode?: number;
+ message?: string;
+ incidentId?: string;
+ cronTimestamp: number;
+ latency?: number;
+ region?: Region;
+}) => {
+ const notificationData = NtfySchema.parse(JSON.parse(notification.data));
+ const { name } = monitor;
+
+ const body = `Your monitor ${name} / ${monitor.url} is down with ${
+ statusCode ? `status code ${statusCode}` : `error: ${message}`
+ }`;
+
+ const authorization = notificationData.token
+ ? { Authorization: `Bearer ${notificationData.token}` }
+ : undefined;
+
+ const url = notificationData.serverUrl
+ ? `${notificationData.serverUrl}/${notificationData.topic}`
+ : `https://ntfy.sh/${notificationData.topic}`;
+
+ try {
+ await fetch(url, {
+ method: "post",
+ body,
+ headers: {
+ ...authorization,
+ },
+ });
+ } catch (err) {
+ console.log(err);
+ // Do something
+ }
+};
+
+export const sendRecovery = async ({
+ monitor,
+ notification,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ statusCode,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ message,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ incidentId,
+}: {
+ monitor: Monitor;
+ notification: Notification;
+ statusCode?: number;
+ message?: string;
+ incidentId?: string;
+ cronTimestamp: number;
+ latency?: number;
+ region?: Region;
+}) => {
+ const notificationData = NtfySchema.parse(JSON.parse(notification.data));
+ const { name } = monitor;
+
+ const body = `Your monitor ${name} / ${monitor.url} is up again`;
+ const authorization = notificationData.token
+ ? { Authorization: `Bearer ${notificationData.token}` }
+ : undefined;
+
+ const url = notificationData.serverUrl
+ ? `${notificationData.serverUrl}/${notificationData.topic}`
+ : `https://ntfy.sh/${notificationData.topic}`;
+ try {
+ await fetch(url, {
+ method: "post",
+ body,
+ headers: {
+ ...authorization,
+ },
+ });
+ } catch (err) {
+ console.log(err);
+ // Do something
+ }
+};
+
+export const sendDegraded = async ({
+ monitor,
+ notification,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ statusCode,
+ // biome-ignore lint/correctness/noUnusedVariables: <explanation>
+ message,
+}: {
+ monitor: Monitor;
+ notification: Notification;
+ statusCode?: number;
+ message?: string;
+ incidentId?: string;
+ cronTimestamp: number;
+ latency?: number;
+ region?: Region;
+}) => {
+ const notificationData = NtfySchema.parse(JSON.parse(notification.data));
+ const { name } = monitor;
+
+ const body = `Your monitor ${name} / ${monitor.url} is degraded `;
+
+ const authorization = notificationData.token
+ ? { Authorization: `Bearer ${notificationData.token}` }
+ : undefined;
+
+ const url = notificationData.serverUrl
+ ? `${notificationData.serverUrl}/${notificationData.topic}`
+ : `https://ntfy.sh/${notificationData.topic}`;
+
+ try {
+ await fetch(url, {
+ method: "post",
+ body,
+ headers: {
+ ...authorization,
+ },
+ });
+ } catch (err) {
+ console.log(err);
+ // Do something
+ }
+};
+
+export const sendTest = async ({
+ serverUrl,
+ topic,
+ token,
+}: {
+ topic: string;
+ serverUrl?: string;
+ token?: string;
+}) => {
+ const authorization = token
+ ? { Authorization: `Bearer ${token}` }
+ : undefined;
+ const url = serverUrl ? `${serverUrl}/${topic}` : `https://ntfy.sh/${topic}`;
+ try {
+ await fetch(url, {
+ method: "post",
+ body: "This is a test message from OpenStatus",
+ headers: {
+ ...authorization,
+ },
+ });
+ } catch (err) {
+ console.log(err);
+ return false;
+ }
+ return true;
+};
diff --git a/packages/notifications/ntfy/src/schema.ts b/packages/notifications/ntfy/src/schema.ts
new file mode 100644
index 000000000..7bf11b210
--- /dev/null
+++ b/packages/notifications/ntfy/src/schema.ts
@@ -0,0 +1,7 @@
+import { z } from "zod";
+
+export const NtfySchema = z.object({
+ topic: z.string(),
+ serverUrl: z.string().default("https://ntfy.sh"),
+ token: z.string().optional(),
+});
diff --git a/packages/notifications/ntfy/tsconfig.json b/packages/notifications/ntfy/tsconfig.json
new file mode 100644
index 000000000..a8a8c9309
--- /dev/null
+++ b/packages/notifications/ntfy/tsconfig.json
@@ -0,0 +1,4 @@
+{
+ "extends": "@openstatus/tsconfig/nextjs.json",
+ "include": ["src", "*.ts"]
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 8eff5339f..834aefcc8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -254,6 +254,9 @@ importers:
'@openstatus/notification-emails':
specifier: workspace:*
version: link:../../packages/notifications/email
+ '@openstatus/notification-ntfy':
+ specifier: workspace:*
+ version: link:../../packages/notifications/ntfy
'@openstatus/notification-opsgenie':
specifier: workspace:*
version: link:../../packages/notifications/opsgenie
@@ -495,6 +498,9 @@ importers:
'@openstatus/notification-emails':
specifier: workspace:*
version: link:../../packages/notifications/email
+ '@openstatus/notification-ntfy':
+ specifier: workspace:*
+ version: link:../../packages/notifications/ntfy
'@openstatus/notification-opsgenie':
specifier: workspace:*
version: link:../../packages/notifications/opsgenie
@@ -814,6 +820,25 @@ importers:
specifier: 5.6.2
version: 5.6.2
+ packages/notifications/ntfy:
+ dependencies:
+ '@openstatus/db':
+ specifier: workspace:*
+ version: link:../../db
+ zod:
+ specifier: 3.23.8
+ version: 3.23.8
+ devDependencies:
+ '@openstatus/tsconfig':
+ specifier: workspace:*
+ version: link:../../tsconfig
+ '@types/node':
+ specifier: 22.10.2
+ version: 22.10.2
+ typescript:
+ specifier: 5.6.2
+ version: 5.6.2
+
packages/notifications/opsgenie:
dependencies:
'@openstatus/db':