Skip to content

Open-source status page, incident response and uptime monitoring

feat: whatsapp notifications (#2140)

Thibault Le Ouay376aa087e773
diff --git a/apps/dashboard/package.json b/apps/dashboard/package.json
index b796e6ba0..ada6cb98d 100644
--- a/apps/dashboard/package.json
+++ b/apps/dashboard/package.json
@@ -41,7 +41,7 @@
"@openstatus/notification-pagerduty": "workspace:*",
"@openstatus/notification-slack": "workspace:*",
"@openstatus/notification-telegram": "workspace:*",
- "@openstatus/notification-twillio-whatsapp": "workspace:*",
+ "@openstatus/notification-bird-whatsapp": "workspace:*",
"@openstatus/notification-webhook": "workspace:*",
"@openstatus/react": "workspace:*",
"@openstatus/regions": "workspace:*",
diff --git a/apps/server/.dockerignore b/apps/server/.dockerignore
index c8236a8b4..a6903313b 100644
--- a/apps/server/.dockerignore
+++ b/apps/server/.dockerignore
@@ -1,4 +1,4 @@
-# This file is generated by Dofigen v2.7.0
+# This file is generated by Dofigen v2.6.0
# See https://github.com/lenra-io/dofigen
node_modules
diff --git a/apps/server/Dockerfile b/apps/server/Dockerfile
index 81c9c19bf..41a0cf175 100644
--- a/apps/server/Dockerfile
+++ b/apps/server/Dockerfile
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.19.0
-# This file is generated by Dofigen v2.7.0
+# This file is generated by Dofigen v2.6.0
# See https://github.com/lenra-io/dofigen
# install
@@ -27,7 +27,7 @@ RUN \
--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 \
--mount=type=bind,target=packages/notifications/telegram/package.json,source=packages/notifications/telegram/package.json \
- --mount=type=bind,target=packages/notifications/twillio-whatsapp/package.json,source=packages/notifications/twillio-whatsapp/package.json \
+ --mount=type=bind,target=packages/notifications/bird-whatsapp/package.json,source=packages/notifications/bird-whatsapp/package.json \
--mount=type=bind,target=packages/notifications/twillio-sms/package.json,source=packages/notifications/twillio-sms/package.json \
--mount=type=bind,target=packages/notifications/webhook/package.json,source=packages/notifications/webhook/package.json \
--mount=type=bind,target=packages/error/package.json,source=packages/error/package.json \
@@ -66,7 +66,7 @@ RUN bun build --compile --sourcemap src/index.ts --outfile=app
# runtime
FROM debian@sha256:1a4701c321b1d28b1ff5f0230e766791e4b79b1d4c6c7a70064f4b297b1a330f AS runtime
LABEL \
- io.dofigen.version="2.7.0" \
+ io.dofigen.version="2.6.0" \
org.opencontainers.image.authors="OpenStatus Team" \
org.opencontainers.image.base.digest="sha256:1a4701c321b1d28b1ff5f0230e766791e4b79b1d4c6c7a70064f4b297b1a330f" \
org.opencontainers.image.base.name="docker.io/debian:bullseye-slim" \
diff --git a/apps/server/dofigen.lock b/apps/server/dofigen.lock
index 542b6342f..fe07d09cb 100644
--- a/apps/server/dofigen.lock
+++ b/apps/server/dofigen.lock
@@ -10,6 +10,27 @@ effective: |
- /packages/api
- /packages/integrations/vercel
builders:
+ build:
+ fromImage:
+ path: oven/bun
+ digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a
+ label:
+ org.opencontainers.image.stage: build
+ org.opencontainers.image.base.name: docker.io/oven/bun:1.3.6
+ org.opencontainers.image.base.digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a
+ workdir: /app/apps/server
+ env:
+ NODE_ENV: production
+ copy:
+ - paths:
+ - .
+ target: /app/
+ - fromBuilder: install
+ paths:
+ - /app/node_modules
+ target: /app/node_modules
+ run:
+ - bun build --compile --sourcemap src/index.ts --outfile=app
install:
fromImage:
path: oven/bun
@@ -58,8 +79,8 @@ effective: |
source: packages/notifications/slack/package.json
- target: packages/notifications/telegram/package.json
source: packages/notifications/telegram/package.json
- - target: packages/notifications/twillio-whatsapp/package.json
- source: packages/notifications/twillio-whatsapp/package.json
+ - target: packages/notifications/bird-whatsapp/package.json
+ source: packages/notifications/bird-whatsapp/package.json
- target: packages/notifications/twillio-sms/package.json
source: packages/notifications/twillio-sms/package.json
- target: packages/notifications/webhook/package.json
@@ -90,39 +111,18 @@ effective: |
source: packages/services/package.json
- target: packages/importers/package.json
source: packages/importers/package.json
- build:
- fromImage:
- path: oven/bun
- digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a
- label:
- org.opencontainers.image.stage: build
- org.opencontainers.image.base.digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a
- org.opencontainers.image.base.name: docker.io/oven/bun:1.3.6
- workdir: /app/apps/server
- env:
- NODE_ENV: production
- copy:
- - paths:
- - .
- target: /app/
- - fromBuilder: install
- paths:
- - /app/node_modules
- target: /app/node_modules
- run:
- - bun build --compile --sourcemap src/index.ts --outfile=app
fromImage:
path: debian
digest: sha256:1a4701c321b1d28b1ff5f0230e766791e4b79b1d4c6c7a70064f4b297b1a330f
label:
- io.dofigen.version: 2.7.0
+ org.opencontainers.image.vendor: OpenStatus
org.opencontainers.image.source: https://github.com/openstatusHQ/openstatus
org.opencontainers.image.base.digest: sha256:1a4701c321b1d28b1ff5f0230e766791e4b79b1d4c6c7a70064f4b297b1a330f
+ org.opencontainers.image.authors: OpenStatus Team
+ org.opencontainers.image.description: REST API server with Hono framework for OpenStatus
org.opencontainers.image.base.name: docker.io/debian:bullseye-slim
org.opencontainers.image.title: OpenStatus Server
- org.opencontainers.image.description: REST API server with Hono framework for OpenStatus
- org.opencontainers.image.vendor: OpenStatus
- org.opencontainers.image.authors: OpenStatus Team
+ io.dofigen.version: 2.6.0
user:
user: '1000'
group: '1000'
@@ -149,17 +149,17 @@ effective: |
retries: 3
images:
docker.io:
- oven:
- bun:
- 1.3.6:
- digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a
library:
debian:
bullseye-slim:
digest: sha256:1a4701c321b1d28b1ff5f0230e766791e4b79b1d4c6c7a70064f4b297b1a330f
+ oven:
+ bun:
+ 1.3.6:
+ digest: sha256:f20d9cf365ab35529384f1717687c739c92e6f39157a35a95ef06f4049a10e4a
resources:
dofigen.yml:
- hash: 0b4934ac4087020f7814554afb8423bb611e051830041107fdecd32afaa8dc28
+ hash: 1759a213e33b260058574d435c45eadd2a9c2b2468f09644d06b78765abc076a
content: |
# Files to exclude from Docker context
ignore:
@@ -198,7 +198,7 @@ resources:
- packages/notifications/pagerduty/package.json
- packages/notifications/slack/package.json
- packages/notifications/telegram/package.json
- - packages/notifications/twillio-whatsapp/package.json
+ - packages/notifications/bird-whatsapp/package.json
- packages/notifications/twillio-sms/package.json
- packages/notifications/webhook/package.json
- packages/error/package.json
diff --git a/apps/server/dofigen.yml b/apps/server/dofigen.yml
index 5827aedad..bcde71728 100644
--- a/apps/server/dofigen.yml
+++ b/apps/server/dofigen.yml
@@ -35,7 +35,7 @@ builders:
- packages/notifications/pagerduty/package.json
- packages/notifications/slack/package.json
- packages/notifications/telegram/package.json
- - packages/notifications/twillio-whatsapp/package.json
+ - packages/notifications/bird-whatsapp/package.json
- packages/notifications/twillio-sms/package.json
- packages/notifications/webhook/package.json
- packages/error/package.json
diff --git a/apps/server/package.json b/apps/server/package.json
index a1d3c0de2..da35f20da 100644
--- a/apps/server/package.json
+++ b/apps/server/package.json
@@ -37,7 +37,7 @@
"@openstatus/notification-pagerduty": "workspace:*",
"@openstatus/notification-slack": "workspace:*",
"@openstatus/notification-telegram": "workspace:*",
- "@openstatus/notification-twillio-whatsapp": "workspace:*",
+ "@openstatus/notification-bird-whatsapp": "workspace:*",
"@openstatus/notification-webhook": "workspace:*",
"@openstatus/assertions": "workspace:*",
"@openstatus/db": "workspace:*",
diff --git a/apps/server/src/routes/rpc/handlers/notification/test-providers.ts b/apps/server/src/routes/rpc/handlers/notification/test-providers.ts
index 90c002284..e179424ce 100644
--- a/apps/server/src/routes/rpc/handlers/notification/test-providers.ts
+++ b/apps/server/src/routes/rpc/handlers/notification/test-providers.ts
@@ -1,3 +1,4 @@
+import { sendTest as sendWhatsAppTest } from "@openstatus/notification-bird-whatsapp";
import { sendTestDiscordMessage } from "@openstatus/notification-discord";
import { sendTest as sendGoogleChatTest } from "@openstatus/notification-google-chat";
import { sendTest as sendGrafanaTest } from "@openstatus/notification-grafana-oncall";
@@ -6,7 +7,6 @@ import { sendTest as sendOpsgenieTest } from "@openstatus/notification-opsgenie"
import { sendTest as sendPagerDutyTest } from "@openstatus/notification-pagerduty";
import { sendTestSlackMessage } from "@openstatus/notification-slack";
import { sendTest as sendTelegramTest } from "@openstatus/notification-telegram";
-import { sendTest as sendWhatsAppTest } from "@openstatus/notification-twillio-whatsapp";
import { sendTest as sendWebhookTest } from "@openstatus/notification-webhook";
import {
type NotificationData,
diff --git a/apps/workflows/Dockerfile b/apps/workflows/Dockerfile
index 506c737b9..422908d02 100644
--- a/apps/workflows/Dockerfile
+++ b/apps/workflows/Dockerfile
@@ -37,7 +37,7 @@ RUN \
--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 \
--mount=type=bind,target=packages/notifications/telegram/package.json,source=packages/notifications/telegram/package.json \
- --mount=type=bind,target=packages/notifications/twillio-whatsapp/package.json,source=packages/notifications/twillio-whatsapp/package.json \
+ --mount=type=bind,target=packages/notifications/bird-whatsapp/package.json,source=packages/notifications/bird-whatsapp/package.json \
--mount=type=bind,target=packages/notifications/twillio-sms/package.json,source=packages/notifications/twillio-sms/package.json \
--mount=type=bind,target=packages/notifications/webhook/package.json,source=packages/notifications/webhook/package.json \
--mount=type=bind,target=packages/regions/package.json,source=packages/regions/package.json \
diff --git a/apps/workflows/dofigen.lock b/apps/workflows/dofigen.lock
index 00f777e83..1e5c24ebb 100644
--- a/apps/workflows/dofigen.lock
+++ b/apps/workflows/dofigen.lock
@@ -58,8 +58,8 @@ effective: |
source: packages/notifications/slack/package.json
- target: packages/notifications/telegram/package.json
source: packages/notifications/telegram/package.json
- - target: packages/notifications/twillio-whatsapp/package.json
- source: packages/notifications/twillio-whatsapp/package.json
+ - target: packages/notifications/bird-whatsapp/package.json
+ source: packages/notifications/bird-whatsapp/package.json
- target: packages/notifications/twillio-sms/package.json
source: packages/notifications/twillio-sms/package.json
- target: packages/notifications/webhook/package.json
@@ -78,68 +78,68 @@ effective: |
source: packages/theme-store/package.json
- target: packages/locales/package.json
source: packages/locales/package.json
- docker:
+ build:
fromImage:
path: oven/bun
digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
label:
+ org.opencontainers.image.stage: build
org.opencontainers.image.base.name: docker.io/oven/bun:1.3.11
org.opencontainers.image.base.digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
workdir: /app/apps/workflows
+ env:
+ NODE_ENV: production
copy:
- paths:
- .
target: /app/
+ - fromBuilder: install
+ paths:
+ - /app/node_modules
+ target: /app/node_modules
run:
- - bun run src/build-docker.ts
- libsql:
+ - bun build --compile --target bun --sourcemap src/index.ts --outfile=app
+ docker:
fromImage:
path: oven/bun
digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
label:
- org.opencontainers.image.base.name: docker.io/oven/bun:1.3.11
org.opencontainers.image.base.digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
- workdir: /app/
+ org.opencontainers.image.base.name: docker.io/oven/bun:1.3.11
+ workdir: /app/apps/workflows
copy:
- - fromBuilder: docker
- paths:
- - /app/apps/build-docker/package.json
- target: /app/package.json
+ - paths:
+ - .
+ target: /app/
run:
- - bun install
- build:
+ - bun run src/build-docker.ts
+ libsql:
fromImage:
path: oven/bun
digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
label:
- org.opencontainers.image.stage: build
org.opencontainers.image.base.name: docker.io/oven/bun:1.3.11
org.opencontainers.image.base.digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
- workdir: /app/apps/workflows
- env:
- NODE_ENV: production
+ workdir: /app/
copy:
- - paths:
- - .
- target: /app/
- - fromBuilder: install
+ - fromBuilder: docker
paths:
- - /app/node_modules
- target: /app/node_modules
+ - /app/apps/build-docker/package.json
+ target: /app/package.json
run:
- - bun build --compile --target bun --sourcemap src/index.ts --outfile=app
+ - bun install
fromImage:
path: debian
digest: sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734
label:
- org.opencontainers.image.base.digest: sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734
- org.opencontainers.image.authors: OpenStatus Team
- org.opencontainers.image.source: https://github.com/openstatusHQ/openstatus
- org.opencontainers.image.description: Background job processing and probe scheduling for OpenStatus
- org.opencontainers.image.title: OpenStatus Workflows
org.opencontainers.image.vendor: OpenStatus
org.opencontainers.image.base.name: docker.io/debian:bullseye-slim
+ org.opencontainers.image.source: https://github.com/openstatusHQ/openstatus
+ org.opencontainers.image.authors: OpenStatus Team
+ org.opencontainers.image.title: OpenStatus Workflows
+ org.opencontainers.image.base.digest: sha256:b32674fb57780ad57d7b0749242d3f585f462f4ec4a60ae0adacd945f9cb9734
io.dofigen.version: 2.6.0
+ org.opencontainers.image.description: Background job processing and probe scheduling for OpenStatus
workdir: /app/
copy:
- fromBuilder: build
@@ -174,7 +174,7 @@ images:
digest: sha256:0733e50325078969732ebe3b15ce4c4be5082f18c4ac1a0f0ca4839c2e4e42a7
resources:
dofigen.yml:
- hash: af5f6cc6d868908681abdb8a70ec8c09594d385545750b5c157d192313d9a3e4
+ hash: fab9bc8c5c598a92c10a5d711facde7620fb57db581ebc3e2bfe673468c8ec33
content: |
ignore:
- node_modules
@@ -211,7 +211,7 @@ resources:
- packages/notifications/pagerduty/package.json
- packages/notifications/slack/package.json
- packages/notifications/telegram/package.json
- - packages/notifications/twillio-whatsapp/package.json
+ - packages/notifications/bird-whatsapp/package.json
- packages/notifications/twillio-sms/package.json
- packages/notifications/webhook/package.json
- packages/regions/package.json
diff --git a/apps/workflows/dofigen.yml b/apps/workflows/dofigen.yml
index 7f8b6fd6a..c0ea3dd97 100644
--- a/apps/workflows/dofigen.yml
+++ b/apps/workflows/dofigen.yml
@@ -33,7 +33,7 @@ builders:
- packages/notifications/pagerduty/package.json
- packages/notifications/slack/package.json
- packages/notifications/telegram/package.json
- - packages/notifications/twillio-whatsapp/package.json
+ - packages/notifications/bird-whatsapp/package.json
- packages/notifications/twillio-sms/package.json
- packages/notifications/webhook/package.json
- packages/regions/package.json
diff --git a/apps/workflows/package.json b/apps/workflows/package.json
index 1df1352b8..2a5b86084 100644
--- a/apps/workflows/package.json
+++ b/apps/workflows/package.json
@@ -25,7 +25,7 @@
"@openstatus/notification-slack": "workspace:*",
"@openstatus/notification-telegram": "workspace:*",
"@openstatus/notification-twillio-sms": "workspace:*",
- "@openstatus/notification-twillio-whatsapp": "workspace:*",
+ "@openstatus/notification-bird-whatsapp": "workspace:*",
"@openstatus/notification-webhook": "workspace:*",
"@openstatus/regions": "workspace:*",
"@openstatus/tinybird": "workspace:*",
diff --git a/apps/workflows/src/checker/utils.ts b/apps/workflows/src/checker/utils.ts
index 4bb85b2c9..09d6c794b 100644
--- a/apps/workflows/src/checker/utils.ts
+++ b/apps/workflows/src/checker/utils.ts
@@ -1,5 +1,10 @@
import type { NotificationProvider } from "@openstatus/db/src/schema";
import type { NotificationContext } from "@openstatus/notification-base";
+import {
+ sendAlert as sendWhatsappAlert,
+ sendDegraded as sendWhatsappDegraded,
+ sendRecovery as sendWhatsappRecovery,
+} from "@openstatus/notification-bird-whatsapp";
import {
sendAlert as sendDiscordAlert,
sendDegraded as sendDiscordDegraded,
@@ -50,11 +55,6 @@ import {
sendDegraded as sendSmsDegraded,
sendRecovery as sendSmsRecovery,
} from "@openstatus/notification-twillio-sms";
-import {
- sendAlert as sendWhatsappAlert,
- sendDegraded as sendWhatsappDegraded,
- sendRecovery as sendWhatsappRecovery,
-} from "@openstatus/notification-twillio-whatsapp";
import {
sendAlert as sendWebhookAlert,
sendDegraded as sendWebhookDegraded,
diff --git a/packages/api/package.json b/packages/api/package.json
index 895867b61..02447c5f6 100644
--- a/packages/api/package.json
+++ b/packages/api/package.json
@@ -23,7 +23,7 @@
"@openstatus/notification-pagerduty": "workspace:*",
"@openstatus/notification-slack": "workspace:*",
"@openstatus/notification-telegram": "workspace:*",
- "@openstatus/notification-twillio-whatsapp": "workspace:*",
+ "@openstatus/notification-bird-whatsapp": "workspace:*",
"@openstatus/notification-webhook": "workspace:*",
"@openstatus/regions": "workspace:*",
"@openstatus/services": "workspace:*",
diff --git a/packages/api/src/router/notification.ts b/packages/api/src/router/notification.ts
index a3b9bafba..5d22e0ff2 100644
--- a/packages/api/src/router/notification.ts
+++ b/packages/api/src/router/notification.ts
@@ -25,6 +25,7 @@ import {
import { Events } from "@openstatus/analytics";
import { SchemaError } from "@openstatus/error";
+import { sendTest as sendWhatsAppTest } from "@openstatus/notification-bird-whatsapp";
import { sendTestDiscordMessage as sendDiscordTest } from "@openstatus/notification-discord";
import { sendTest as sendGoogleChatTest } from "@openstatus/notification-google-chat";
import { sendTest as sendGrafanaTest } from "@openstatus/notification-grafana-oncall";
@@ -36,7 +37,6 @@ import {
} from "@openstatus/notification-pagerduty";
import { sendTestSlackMessage as sendSlackTest } from "@openstatus/notification-slack";
import { sendTest as sendTelegramTest } from "@openstatus/notification-telegram";
-import { sendTest as sendWhatsAppTest } from "@openstatus/notification-twillio-whatsapp";
import { sendTest as sendWebhookTest } from "@openstatus/notification-webhook";
import { redis } from "@openstatus/upstash";
import { nanoid } from "nanoid";
diff --git a/packages/notifications/bird-whatsapp/.env.example b/packages/notifications/bird-whatsapp/.env.example
new file mode 100644
index 000000000..c34cd76e4
--- /dev/null
+++ b/packages/notifications/bird-whatsapp/.env.example
@@ -0,0 +1,3 @@
+BIRD_ACCESS_KEY=your_access_key
+BIRD_WORKSPACE_ID=your_workspace_id
+BIRD_CHANNEL_ID=your_channel_id
diff --git a/packages/notifications/twillio-whatsapp/package.json b/packages/notifications/bird-whatsapp/package.json
similarity index 78%
rename from packages/notifications/twillio-whatsapp/package.json
rename to packages/notifications/bird-whatsapp/package.json
index 9b84bc4b2..0a84393a0 100644
--- a/packages/notifications/twillio-whatsapp/package.json
+++ b/packages/notifications/bird-whatsapp/package.json
@@ -1,5 +1,5 @@
{
- "name": "@openstatus/notification-twillio-whatsapp",
+ "name": "@openstatus/notification-bird-whatsapp",
"version": "0.0.0",
"main": "src/index.ts",
"scripts": {
@@ -10,13 +10,11 @@
"@openstatus/db": "workspace:*",
"@openstatus/notification-base": "workspace:*",
"@t3-oss/env-core": "0.13.10",
- "validator": "13.12.0",
"zod": "4.1.13"
},
"devDependencies": {
"@openstatus/tsconfig": "workspace:*",
"@types/node": "24.0.8",
- "@types/validator": "13.12.0",
"bun-types": "1.3.1",
"typescript": "5.9.3"
}
diff --git a/packages/notifications/bird-whatsapp/src/env.ts b/packages/notifications/bird-whatsapp/src/env.ts
new file mode 100644
index 000000000..13663f021
--- /dev/null
+++ b/packages/notifications/bird-whatsapp/src/env.ts
@@ -0,0 +1,12 @@
+import { createEnv } from "@t3-oss/env-core";
+import { z } from "zod";
+
+export const env = createEnv({
+ server: {
+ BIRD_ACCESS_KEY: z.string(),
+ BIRD_WORKSPACE_ID: z.string(),
+ BIRD_CHANNEL_ID: z.string(),
+ },
+ runtimeEnv: process.env,
+ skipValidation: true,
+});
diff --git a/packages/notifications/bird-whatsapp/src/index.test.ts b/packages/notifications/bird-whatsapp/src/index.test.ts
new file mode 100644
index 000000000..36bfbfa7e
--- /dev/null
+++ b/packages/notifications/bird-whatsapp/src/index.test.ts
@@ -0,0 +1,169 @@
+import {
+ afterEach,
+ beforeEach,
+ describe,
+ expect,
+ jest,
+ spyOn,
+ test,
+} from "bun:test";
+import type { Monitor } from "@openstatus/db/src/schema";
+import { selectNotificationSchema } from "@openstatus/db/src/schema";
+import { sendAlert, sendDegraded, sendRecovery, sendTest } from "./index";
+
+const BIRD_URL_PATTERN =
+ /https:\/\/api\.bird\.com\/workspaces\/.*\/channels\/.*\/batch\/messages/;
+
+function createMonitor(): Monitor {
+ return {
+ url: "https://api.example.com/health",
+ } as Monitor;
+}
+
+function createNotification() {
+ return selectNotificationSchema.parse({
+ id: 1,
+ name: "WhatsApp Notification",
+ provider: "whatsapp",
+ workspaceId: 1,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ data: '{"whatsapp":"+33623456789"}',
+ });
+}
+
+function parseRequestBody(call: ReturnType<typeof spyOn>): {
+ messageRequests: Array<{
+ receiver: {
+ contacts: Array<{ identifierKey: string; identifierValue: string }>;
+ };
+ template: {
+ projectId: string;
+ version: string;
+ locale: string;
+ parameters: Array<{ type: string; key: string; value: string }>;
+ };
+ }>;
+} {
+ const body = (call as ReturnType<typeof spyOn>).mock.calls[0][1]?.body;
+ return JSON.parse(body as string);
+}
+
+describe("WhatsApp Notifications (Bird)", () => {
+ let fetchMock: ReturnType<typeof spyOn>;
+
+ beforeEach(() => {
+ // @ts-expect-error
+ fetchMock = spyOn(global, "fetch").mockImplementation(() =>
+ Promise.resolve(new Response(null, { status: 200 })),
+ );
+ });
+
+ afterEach(() => {
+ jest.resetAllMocks();
+ });
+
+ test("sendAlert calls Bird API with alert template", async () => {
+ await sendAlert({
+ monitor: createMonitor(),
+ notification: createNotification(),
+ statusCode: 500,
+ message: "Something went wrong",
+ cronTimestamp: Date.now(),
+ });
+
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ const url = fetchMock.mock.calls[0][0] as string;
+ expect(url).toMatch(BIRD_URL_PATTERN);
+
+ const options = fetchMock.mock.calls[0][1] as RequestInit;
+ expect(options.headers).toHaveProperty("Authorization");
+ expect((options.headers as Record<string, string>).Authorization).toMatch(
+ /^AccessKey /,
+ );
+
+ const body = parseRequestBody(fetchMock);
+ expect(body.messageRequests[0].receiver.contacts[0].identifierKey).toBe(
+ "phonenumber",
+ );
+ expect(body.messageRequests[0].receiver.contacts[0].identifierValue).toBe(
+ "+33623456789",
+ );
+ expect(body.messageRequests[0].template.projectId).toBe(
+ "20cd47e2-70e9-4e06-97be-21eee5e4de33",
+ );
+ expect(body.messageRequests[0].template.version).toBe(
+ "9a86655b-9e5a-4e8a-80f3-33f232bb7e63",
+ );
+ expect(body.messageRequests[0].template.locale).toBe("en");
+ expect(body.messageRequests[0].template.parameters[0].key).toBe(
+ "monitor_url",
+ );
+ expect(body.messageRequests[0].template.parameters[0].value).toBe(
+ "https://api.example.com/health",
+ );
+ });
+
+ test("sendRecovery calls Bird API with recovery template", async () => {
+ await sendRecovery({
+ monitor: createMonitor(),
+ notification: createNotification(),
+ statusCode: 200,
+ message: "Back up",
+ cronTimestamp: Date.now(),
+ });
+
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ const body = parseRequestBody(fetchMock);
+ expect(body.messageRequests[0].template.projectId).toBe(
+ "2068001e-330d-4093-8d06-7071e9d34aa1",
+ );
+ expect(body.messageRequests[0].template.version).toBe(
+ "af66e5de-015b-4822-a34e-fb6dfd538bb6",
+ );
+ expect(body.messageRequests[0].template.parameters[0].value).toBe(
+ "https://api.example.com/health",
+ );
+ });
+
+ test("sendDegraded calls Bird API with degraded template", async () => {
+ await sendDegraded({
+ monitor: createMonitor(),
+ notification: createNotification(),
+ statusCode: 500,
+ message: "Something went wrong",
+ cronTimestamp: Date.now(),
+ });
+
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ const body = parseRequestBody(fetchMock);
+ expect(body.messageRequests[0].template.projectId).toBe(
+ "c9a842d9-cf9e-4a13-8cde-024d57e29143",
+ );
+ expect(body.messageRequests[0].template.version).toBe(
+ "dcbfac35-db0e-4e07-9390-e53dda2fda0b",
+ );
+ expect(body.messageRequests[0].template.parameters[0].value).toBe(
+ "https://api.example.com/health",
+ );
+ });
+
+ test("sendTest calls Bird API with test template and openstat.us URL", async () => {
+ await sendTest({ phoneNumber: "+33623456789" });
+
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ const body = parseRequestBody(fetchMock);
+ expect(body.messageRequests[0].receiver.contacts[0].identifierValue).toBe(
+ "+33623456789",
+ );
+ expect(body.messageRequests[0].template.projectId).toBe(
+ "3315bcd8-2fde-411c-83c5-009ac4b4b8ff",
+ );
+ expect(body.messageRequests[0].template.version).toBe(
+ "a3e55807-ff35-4dbc-a16b-670c7eeaae85",
+ );
+ expect(body.messageRequests[0].template.parameters[0].value).toBe(
+ "https://openstat.us",
+ );
+ });
+});
diff --git a/packages/notifications/bird-whatsapp/src/index.ts b/packages/notifications/bird-whatsapp/src/index.ts
new file mode 100644
index 000000000..4d00d4e28
--- /dev/null
+++ b/packages/notifications/bird-whatsapp/src/index.ts
@@ -0,0 +1,106 @@
+import { whatsappDataSchema } from "@openstatus/db/src/schema";
+import type { NotificationContext } from "@openstatus/notification-base";
+import { env } from "./env";
+
+const TEMPLATES = {
+ alert: {
+ projectId: "20cd47e2-70e9-4e06-97be-21eee5e4de33",
+ version: "9a86655b-9e5a-4e8a-80f3-33f232bb7e63",
+ },
+ recovery: {
+ projectId: "2068001e-330d-4093-8d06-7071e9d34aa1",
+ version: "af66e5de-015b-4822-a34e-fb6dfd538bb6",
+ },
+ degraded: {
+ projectId: "c9a842d9-cf9e-4a13-8cde-024d57e29143",
+ version: "dcbfac35-db0e-4e07-9390-e53dda2fda0b",
+ },
+ test: {
+ projectId: "3315bcd8-2fde-411c-83c5-009ac4b4b8ff",
+ version: "a3e55807-ff35-4dbc-a16b-670c7eeaae85",
+ },
+} as const;
+
+async function sendMessage(
+ phoneNumber: string,
+ monitorUrl: string,
+ template: { projectId: string; version: string },
+): Promise<void> {
+ const res = await fetch(
+ `https://api.bird.com/workspaces/${env.BIRD_WORKSPACE_ID}/channels/${env.BIRD_CHANNEL_ID}/batch/messages`,
+ {
+ method: "POST",
+ headers: {
+ Authorization: `AccessKey ${env.BIRD_ACCESS_KEY}`,
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ messageRequests: [
+ {
+ receiver: {
+ contacts: [
+ {
+ identifierKey: "phonenumber",
+ identifierValue: phoneNumber,
+ },
+ ],
+ },
+ template: {
+ projectId: template.projectId,
+ version: template.version,
+ locale: "en",
+ parameters: [
+ {
+ type: "string",
+ key: "monitor_url",
+ value: monitorUrl,
+ },
+ ],
+ },
+ },
+ ],
+ }),
+ },
+ );
+ if (!res.ok) {
+ throw new Error(`Failed to send WhatsApp message: ${res.statusText}`);
+ }
+}
+
+export const sendAlert = async ({
+ monitor,
+ notification,
+}: NotificationContext) => {
+ const notificationData = whatsappDataSchema.parse(
+ JSON.parse(notification.data),
+ );
+ await sendMessage(notificationData.whatsapp, monitor.url, TEMPLATES.alert);
+};
+
+export const sendRecovery = async ({
+ monitor,
+ notification,
+}: NotificationContext) => {
+ const notificationData = whatsappDataSchema.parse(
+ JSON.parse(notification.data),
+ );
+ await sendMessage(notificationData.whatsapp, monitor.url, TEMPLATES.recovery);
+};
+
+export const sendDegraded = async ({
+ monitor,
+ notification,
+}: NotificationContext) => {
+ const notificationData = whatsappDataSchema.parse(
+ JSON.parse(notification.data),
+ );
+ await sendMessage(notificationData.whatsapp, monitor.url, TEMPLATES.degraded);
+};
+
+export const sendTest = async ({ phoneNumber }: { phoneNumber: string }) => {
+ try {
+ await sendMessage(phoneNumber, "https://openstat.us", TEMPLATES.test);
+ } catch (err) {
+ console.log(err);
+ }
+};
diff --git a/packages/notifications/twillio-whatsapp/tsconfig.json b/packages/notifications/bird-whatsapp/tsconfig.json
similarity index 100%
rename from packages/notifications/twillio-whatsapp/tsconfig.json
rename to packages/notifications/bird-whatsapp/tsconfig.json
diff --git a/packages/notifications/twillio-whatsapp/.env.example b/packages/notifications/twillio-whatsapp/.env.example
deleted file mode 100644
index 07a929433..000000000
--- a/packages/notifications/twillio-whatsapp/.env.example
+++ /dev/null
@@ -1,2 +0,0 @@
-TWILLIO_AUTH_TOKEN=your_auth_token
-TWILLIO_ACCOUNT_ID=your_account_id
diff --git a/packages/notifications/twillio-whatsapp/src/env.ts b/packages/notifications/twillio-whatsapp/src/env.ts
deleted file mode 100644
index 49035cca7..000000000
--- a/packages/notifications/twillio-whatsapp/src/env.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { createEnv } from "@t3-oss/env-core";
-import { z } from "zod";
-
-export const env = createEnv({
- server: {
- TWILLIO_AUTH_TOKEN: z.string(),
- TWILLIO_ACCOUNT_ID: z.string(),
- },
-
- /**
- * What object holds the environment variables at runtime. This is usually
- * `process.env` or `import.meta.env`.
- */
- runtimeEnv: process.env,
-
- /**
- * By default, this library will feed the environment variables directly to
- * the Zod validator.
- *
- * This means that if you have an empty string for a value that is supposed
- * to be a number (e.g. `PORT=` in a ".env" file), Zod will incorrectly flag
- * it as a type mismatch violation. Additionally, if you have an empty string
- * for a value that is supposed to be a string with a default value (e.g.
- * `DOMAIN=` in an ".env" file), the default value will never be applied.
- *
- * In order to solve these issues, we recommend that all new projects
- * explicitly specify this option as true.
- */
- skipValidation: true,
-});
diff --git a/packages/notifications/twillio-whatsapp/src/index.test.ts b/packages/notifications/twillio-whatsapp/src/index.test.ts
deleted file mode 100644
index 7b680a79b..000000000
--- a/packages/notifications/twillio-whatsapp/src/index.test.ts
+++ /dev/null
@@ -1,132 +0,0 @@
-import {
- afterEach,
- beforeEach,
- describe,
- expect,
- jest,
- spyOn,
- test,
-} from "bun:test";
-import { selectNotificationSchema } from "@openstatus/db/src/schema";
-import { sendAlert, sendDegraded, sendRecovery } from "./index";
-
-describe("whatsapp Notifications", () => {
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
- let fetchMock: any = undefined;
-
- beforeEach(() => {
- // @ts-expect-error
- fetchMock = spyOn(global, "fetch").mockImplementation(() =>
- Promise.resolve(new Response(null, { status: 200 })),
- );
- });
-
- afterEach(() => {
- jest.resetAllMocks();
- });
-
- test("Send degraded", async () => {
- const monitor = {
- id: "monitor-1",
- name: "API Health Check",
- url: "https://api.example.com/health",
- jobType: "http" as const,
- periodicity: "5m" as const,
- status: "active" as const, // or "down", "degraded"
- createdAt: new Date(),
- updatedAt: new Date(),
- region: "us-east-1",
- };
-
- const a = {
- id: 1,
- name: "slack Notification",
- provider: "slack",
- workspaceId: 1,
- createdAt: new Date(),
- updatedAt: new Date(),
- data: '{"whatsapp":"+33623456789"}',
- };
-
- const n = selectNotificationSchema.parse(a);
- await sendDegraded({
- // @ts-expect-error
- monitor,
- notification: n,
- statusCode: 500,
- message: "Something went wrong",
- cronTimestamp: Date.now(),
- });
- expect(fetchMock).toHaveBeenCalled();
- });
-
- test("Send Recovered", async () => {
- const monitor = {
- id: "monitor-1",
- name: "API Health Check",
- url: "https://api.example.com/health",
- jobType: "http" as const,
- periodicity: "5m" as const,
- status: "active" as const, // or "down", "degraded"
- createdAt: new Date(),
- updatedAt: new Date(),
- region: "us-east-1",
- };
-
- const a = {
- id: 1,
- name: "slack Notification",
- provider: "slack",
- workspaceId: 1,
- createdAt: new Date(),
- updatedAt: new Date(),
- data: '{"whatsapp":"+33623456789"}',
- };
-
- const n = selectNotificationSchema.parse(a);
- await sendRecovery({
- // @ts-expect-error
- monitor,
- notification: n,
- statusCode: 500,
- message: "Something went wrong",
- cronTimestamp: Date.now(),
- });
- expect(fetchMock).toHaveBeenCalled();
- });
-
- test("Send Alert", async () => {
- const monitor = {
- id: "monitor-1",
- name: "API Health Check",
- url: "https://api.example.com/health",
- jobType: "http" as const,
- periodicity: "5m" as const,
- status: "active" as const, // or "down", "degraded"
- createdAt: new Date(),
- updatedAt: new Date(),
- region: "us-east-1",
- };
- const a = {
- id: 1,
- name: "slack Notification",
- provider: "slack",
- workspaceId: 1,
- createdAt: new Date(),
- updatedAt: new Date(),
- data: '{"whatsapp":"+33623456789"}',
- };
-
- const n = selectNotificationSchema.parse(a);
-
- await sendAlert({
- // @ts-expect-error
- monitor,
- notification: n,
- statusCode: 500,
- message: "Something went wrong",
- cronTimestamp: Date.now(),
- });
- expect(fetchMock).toHaveBeenCalled();
- });
-});
diff --git a/packages/notifications/twillio-whatsapp/src/index.ts b/packages/notifications/twillio-whatsapp/src/index.ts
deleted file mode 100644
index ebb9c4787..000000000
--- a/packages/notifications/twillio-whatsapp/src/index.ts
+++ /dev/null
@@ -1,127 +0,0 @@
-import { whatsappDataSchema } from "@openstatus/db/src/schema";
-import type { NotificationContext } from "@openstatus/notification-base";
-import { env } from "./env";
-
-export const sendAlert = async ({
- monitor,
- notification,
-}: NotificationContext) => {
- const notificationData = whatsappDataSchema.parse(
- JSON.parse(notification.data),
- );
- const contentVariables = JSON.stringify({ url: monitor.url });
-
- const body = new FormData();
- body.set("To", `whatsapp:${notificationData.whatsapp}`);
- body.set("From", "whatsapp:+14807252613");
- body.set("ContentSid", "HX8282106bfaecb7939e69f9c5564babe5");
- body.set("ContentVariables", contentVariables);
-
- const res = await fetch(
- `https://api.twilio.com/2010-04-01/Accounts/${env.TWILLIO_ACCOUNT_ID}/Messages.json`,
- {
- method: "post",
- body,
- headers: {
- Authorization: `Basic ${btoa(
- `${env.TWILLIO_ACCOUNT_ID}:${env.TWILLIO_AUTH_TOKEN}`,
- )}`,
- },
- },
- );
- if (!res.ok) {
- throw new Error(`Failed to send WhatsApp message: ${res.statusText}`);
- }
-};
-
-export const sendRecovery = async ({
- monitor,
- notification,
-}: NotificationContext) => {
- const notificationData = whatsappDataSchema.parse(
- JSON.parse(notification.data),
- );
- const contentVariables = JSON.stringify({ url: monitor.url });
-
- const body = new FormData();
- body.set("To", `whatsapp:${notificationData.whatsapp}`);
- body.set("From", "whatsapp:+14807252613");
- body.set("ContentSid", "HX8fdeb4201bed18ac8838b3c0135bbf28");
- body.set("ContentVariables", contentVariables);
-
- const res = await fetch(
- `https://api.twilio.com/2010-04-01/Accounts/${env.TWILLIO_ACCOUNT_ID}/Messages.json`,
- {
- method: "post",
- body,
- headers: {
- Authorization: `Basic ${btoa(
- `${env.TWILLIO_ACCOUNT_ID}:${env.TWILLIO_AUTH_TOKEN}`,
- )}`,
- },
- },
- );
- if (!res.ok) {
- throw new Error(`Failed to send SMS: ${res.statusText}`);
- }
-};
-
-export const sendDegraded = async ({
- monitor,
- notification,
-}: NotificationContext) => {
- const notificationData = whatsappDataSchema.parse(
- JSON.parse(notification.data),
- );
- const contentVariables = JSON.stringify({ url: monitor.url });
-
- const body = new FormData();
- body.set("To", `whatsapp:${notificationData.whatsapp}`);
- body.set("From", "whatsapp:+14807252613");
- body.set("ContentSid", "HX35589f2e7ac8b8be63f4bd62a60e435f");
- body.set("ContentVariables", contentVariables);
-
- const res = await fetch(
- `https://api.twilio.com/2010-04-01/Accounts/${env.TWILLIO_ACCOUNT_ID}/Messages.json`,
- {
- method: "post",
- body,
- headers: {
- Authorization: `Basic ${btoa(
- `${env.TWILLIO_ACCOUNT_ID}:${env.TWILLIO_AUTH_TOKEN}`,
- )}`,
- },
- },
- );
- if (!res.ok) {
- throw new Error(`Failed to send SMS: ${res.statusText}`);
- }
-};
-
-export const sendTest = async ({ phoneNumber }: { phoneNumber: string }) => {
- const contentVariables = JSON.stringify({ url: "https://openstat.us" });
- const body = new FormData();
- body.set("To", `whatsapp:${phoneNumber}`);
- body.set("ContentSid", "HX36ac9074ebda4376c7d6ddd1690b5291");
- body.set("From", "whatsapp:+14807252613");
- body.set("ContentVariables", contentVariables);
-
- console.log("send data");
- try {
- await fetch(
- `https://api.twilio.com/2010-04-01/Accounts/${env.TWILLIO_ACCOUNT_ID}/Messages.json`,
- {
- method: "post",
- body,
- headers: {
- Authorization: `Basic ${btoa(
- `${env.TWILLIO_ACCOUNT_ID}:${env.TWILLIO_AUTH_TOKEN}`,
- )}`,
- },
- },
- );
- } catch (err) {
- console.log(err);
- // Do something
- }
-};
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 328111433..f4e115332 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -104,6 +104,9 @@ importers:
'@openstatus/locales':
specifier: workspace:*
version: link:../../packages/locales
+ '@openstatus/notification-bird-whatsapp':
+ specifier: workspace:*
+ version: link:../../packages/notifications/bird-whatsapp
'@openstatus/notification-discord':
specifier: workspace:*
version: link:../../packages/notifications/discord
@@ -131,9 +134,6 @@ importers:
'@openstatus/notification-telegram':
specifier: workspace:*
version: link:../../packages/notifications/telegram
- '@openstatus/notification-twillio-whatsapp':
- specifier: workspace:*
- version: link:../../packages/notifications/twillio-whatsapp
'@openstatus/notification-webhook':
specifier: workspace:*
version: link:../../packages/notifications/webhook
@@ -485,6 +485,9 @@ importers:
'@openstatus/error':
specifier: workspace:*
version: link:../../packages/error
+ '@openstatus/notification-bird-whatsapp':
+ specifier: workspace:*
+ version: link:../../packages/notifications/bird-whatsapp
'@openstatus/notification-discord':
specifier: workspace:*
version: link:../../packages/notifications/discord
@@ -509,9 +512,6 @@ importers:
'@openstatus/notification-telegram':
specifier: workspace:*
version: link:../../packages/notifications/telegram
- '@openstatus/notification-twillio-whatsapp':
- specifier: workspace:*
- version: link:../../packages/notifications/twillio-whatsapp
'@openstatus/notification-webhook':
specifier: workspace:*
version: link:../../packages/notifications/webhook
@@ -1139,6 +1139,9 @@ importers:
'@openstatus/notification-base':
specifier: workspace:*
version: link:../../packages/notifications/base
+ '@openstatus/notification-bird-whatsapp':
+ specifier: workspace:*
+ version: link:../../packages/notifications/bird-whatsapp
'@openstatus/notification-discord':
specifier: workspace:*
version: link:../../packages/notifications/discord
@@ -1169,9 +1172,6 @@ importers:
'@openstatus/notification-twillio-sms':
specifier: workspace:*
version: link:../../packages/notifications/twillio-sms
- '@openstatus/notification-twillio-whatsapp':
- specifier: workspace:*
- version: link:../../packages/notifications/twillio-whatsapp
'@openstatus/notification-webhook':
specifier: workspace:*
version: link:../../packages/notifications/webhook
@@ -1261,6 +1261,9 @@ importers:
'@openstatus/locales':
specifier: workspace:*
version: link:../locales
+ '@openstatus/notification-bird-whatsapp':
+ specifier: workspace:*
+ version: link:../notifications/bird-whatsapp
'@openstatus/notification-discord':
specifier: workspace:*
version: link:../notifications/discord
@@ -1285,9 +1288,6 @@ importers:
'@openstatus/notification-telegram':
specifier: workspace:*
version: link:../notifications/telegram
- '@openstatus/notification-twillio-whatsapp':
- specifier: workspace:*
- version: link:../notifications/twillio-whatsapp
'@openstatus/notification-webhook':
specifier: workspace:*
version: link:../notifications/webhook
@@ -1574,6 +1574,34 @@ importers:
specifier: 5.9.3
version: 5.9.3
+ packages/notifications/bird-whatsapp:
+ dependencies:
+ '@openstatus/db':
+ specifier: workspace:*
+ version: link:../../db
+ '@openstatus/notification-base':
+ specifier: workspace:*
+ version: link:../base
+ '@t3-oss/env-core':
+ specifier: 0.13.10
+ zod:
+ specifier: 4.1.13
+ version: 4.1.13
+ devDependencies:
+ '@openstatus/tsconfig':
+ specifier: workspace:*
+ version: link:../../tsconfig
+ '@types/node':
+ specifier: 24.0.8
+ version: 24.0.8
+ bun-types:
+ specifier: 1.3.1
+ version: 1.3.1(@types/[email protected])
+ typescript:
+ specifier: 5.9.3
+ version: 5.9.3
+
packages/notifications/discord:
dependencies:
'@openstatus/db':
@@ -1908,40 +1936,6 @@ importers:
specifier: 5.9.3
version: 5.9.3
- packages/notifications/twillio-whatsapp:
- dependencies:
- '@openstatus/db':
- specifier: workspace:*
- version: link:../../db
- '@openstatus/notification-base':
- specifier: workspace:*
- version: link:../base
- '@t3-oss/env-core':
- specifier: 0.13.10
- validator:
- specifier: 13.12.0
- version: 13.12.0
- zod:
- specifier: 4.1.13
- version: 4.1.13
- devDependencies:
- '@openstatus/tsconfig':
- specifier: workspace:*
- version: link:../../tsconfig
- '@types/node':
- specifier: 24.0.8
- version: 24.0.8
- '@types/validator':
- specifier: 13.12.0
- version: 13.12.0
- bun-types:
- specifier: 1.3.1
- version: 1.3.1(@types/[email protected])
- typescript:
- specifier: 5.9.3
- version: 5.9.3
-
packages/notifications/webhook:
dependencies:
'@openstatus/db':