Skip to content

Open-source status page, incident response and uptime monitoring

feat(subscriptions): detect Microsoft Teams webhook URLs and emit Adaptive Cards (#2898)

Sarah Vogel1945a394182b
diff --git a/apps/dashboard/src/components/data-table/subscribers/columns.tsx b/apps/dashboard/src/components/data-table/subscribers/columns.tsx
index e99309883..6246dcad8 100644
--- a/apps/dashboard/src/components/data-table/subscribers/columns.tsx
+++ b/apps/dashboard/src/components/data-table/subscribers/columns.tsx
@@ -20,6 +20,7 @@ type Subscriber = RouterOutputs["pageSubscriber"]["list"][number];
const FLAVOR_LABELS = {
slack: "Slack",
discord: "Discord",
+ teams: "Microsoft Teams",
generic: "Webhook",
} as const;
diff --git a/apps/dashboard/src/components/forms/subscriber/form.tsx b/apps/dashboard/src/components/forms/subscriber/form.tsx
index ab49da242..789fe22ea 100644
--- a/apps/dashboard/src/components/forms/subscriber/form.tsx
+++ b/apps/dashboard/src/components/forms/subscriber/form.tsx
@@ -293,8 +293,9 @@ export function FormSubscriber({
</FormControl>
<FormDescription>
<span className="mr-0.5">
- Slack and Discord URLs receive channel-native messages;
- any other URL receives a generic JSON payload.
+ Slack, Discord, and Microsoft Teams URLs receive
+ channel-native messages; any other URL receives a
+ generic JSON payload.
</span>
{/^https?:\/\//.test(field.value) ? (
<Badge variant="outline" className="capitalize">
diff --git a/apps/web/src/content/pages/docs/reference/subscriber.mdx b/apps/web/src/content/pages/docs/reference/subscriber.mdx
index 7e704423e..fdf76bf34 100644
--- a/apps/web/src/content/pages/docs/reference/subscriber.mdx
+++ b/apps/web/src/content/pages/docs/reference/subscriber.mdx
@@ -57,7 +57,7 @@ Status page administrators can manage their subscriber lists, including:
Beyond public self-subscription, administrators can add subscribers directly from the dashboard. This is useful for onboarding partners, internal teams, or automation that should receive updates without going through the public opt-in flow. Each manually added subscriber uses one of three channels:
- **Email** — delivers updates to a contact address. By adding an email here you confirm the contact has consented to receive status updates; no confirmation email is sent.
-- **Webhook** — POSTs each update to a URL. Slack and Discord URLs receive channel-native messages; any other URL receives a generic JSON payload.
+- **Webhook** — POSTs each update to a URL. Slack, Discord, and Microsoft Teams URLs receive channel-native messages; any other URL receives a generic JSON payload.
- **Slack** — posts each update straight into a Slack channel through the openstatus Slack app. The bot token is resolved from the workspace integration at send time and is never stored on the subscriber. A channel can also subscribe itself with the slash command (see [Slack subscribers](#slack-subscribers)).
For every channel, you can optionally:
@@ -119,6 +119,10 @@ A URL starting with `https://hooks.slack.com/services/` is treated as a Slack in
A URL starting with `https://discord.com/api/webhooks/` is treated as a Discord webhook. The payload uses a Discord embed with a status-colored sidebar, a title linking to the event, status and page fields, the update message, affected components, and manage/unsubscribe links.
+### Microsoft Teams
+
+A URL whose hostname ends with `.logic.azure.com`, `.powerplatform.com`, or `.webhook.office.com` is treated as a Microsoft Teams webhook (Teams Workflows or the legacy Office connector). The payload is an [Adaptive Card 1.5](https://adaptivecards.io/) wrapped in the standard Teams message envelope — a status-colored header container, a FactSet with status, page, and timestamp, the update message, affected components, manage/unsubscribe links, and a `View details` action button.
+
### Generic
Any other URL receives a versioned, channel-agnostic JSON payload. Use this to forward updates into your own systems. The body is shaped as:
diff --git a/packages/subscriptions/src/channels/webhook.test.ts b/packages/subscriptions/src/channels/webhook.test.ts
index d17be6f40..749f75fe0 100644
--- a/packages/subscriptions/src/channels/webhook.test.ts
+++ b/packages/subscriptions/src/channels/webhook.test.ts
@@ -16,6 +16,10 @@ import {
const SLACK_URL = "https://hooks.slack.com/services/T1/B1/XXX";
const DISCORD_URL = "https://discord.com/api/webhooks/1/xxx";
+const TEAMS_WORKFLOWS_URL =
+ "https://prod-123.westus.logic.azure.com:443/workflows/abc/triggers/manual/paths/invoke";
+const TEAMS_LEGACY_URL =
+ "https://acme.webhook.office.com/webhookb2/abc@def/IncomingWebhook/xyz/pid";
let fetchMock: Stub<typeof globalThis>;
@@ -330,6 +334,32 @@ describe("detectWebhookFlavor", () => {
test("falls back to generic for unknown hosts", () => {
expect(detectWebhookFlavor("https://example.com/webhook")).toBe("generic");
});
+
+ test("detects Teams Workflows URLs on *.logic.azure.com", () => {
+ expect(detectWebhookFlavor(TEAMS_WORKFLOWS_URL)).toBe("teams");
+ });
+
+ test("detects legacy Office connector URLs on *.webhook.office.com", () => {
+ expect(detectWebhookFlavor(TEAMS_LEGACY_URL)).toBe("teams");
+ });
+
+ test("detects Power Automate URLs on *.powerplatform.com", () => {
+ expect(
+ detectWebhookFlavor(
+ "https://default-abc.flow.europe.powerplatform.com/manual/paths/invoke",
+ ),
+ ).toBe("teams");
+ });
+
+ test("does not misclassify URLs that merely contain a Teams host as a path segment", () => {
+ expect(
+ detectWebhookFlavor("https://example.com/proxy?to=webhook.office.com"),
+ ).toBe("generic");
+ });
+
+ test("falls back to generic for malformed URLs", () => {
+ expect(detectWebhookFlavor("not-a-url")).toBe("generic");
+ });
});
// ─── flavor-specific notification payloads ────────────────────────────────────
@@ -432,6 +462,84 @@ describe("sendWebhookNotifications (flavor detection)", () => {
"[Demo](https://demo.openstatus.dev)",
);
});
+
+ test("emits Teams Adaptive Card envelope for Teams URLs", async () => {
+ resolveFetch(new Response(null, { status: 200 }));
+ const sub = makeSub({
+ webhookUrl: TEAMS_WORKFLOWS_URL,
+ pageSlug: "demo",
+ pageName: "Demo",
+ });
+
+ await sendWebhookNotifications([sub], makeUpdate({ id: 42 }));
+
+ const [, init] = fetchMock.calls[0].args;
+ const body = JSON.parse(init?.body as string);
+ expect(body.type).toBe("message");
+ expect(body.attachments[0].contentType).toBe(
+ "application/vnd.microsoft.card.adaptive",
+ );
+ const card = body.attachments[0].content;
+ expect(card.type).toBe("AdaptiveCard");
+ expect(card.version).toBe("1.5");
+ expect(card.body[0]).toMatchObject({
+ type: "Container",
+ style: "attention", // "investigating" → red → attention
+ items: [
+ {
+ type: "TextBlock",
+ text: "Test Incident",
+ weight: "Bolder",
+ },
+ ],
+ });
+ expect(card.actions[0]).toMatchObject({
+ type: "Action.OpenUrl",
+ title: "View details",
+ url: "https://demo.openstatus.dev/events/report/42",
+ });
+ });
+
+ test("Teams payload includes manage/unsubscribe links in a TextBlock", async () => {
+ resolveFetch(new Response(null, { status: 200 }));
+ const sub = makeSub({
+ webhookUrl: TEAMS_LEGACY_URL,
+ token: "tok-123",
+ pageSlug: "demo",
+ });
+
+ await sendWebhookNotifications([sub], makeUpdate());
+
+ const [, init] = fetchMock.calls[0].args;
+ const stringified = init?.body as string;
+ expect(stringified).toContain(
+ "[Manage](https://demo.openstatus.dev/manage/tok-123)",
+ );
+ expect(stringified).toContain(
+ "[Unsubscribe](https://demo.openstatus.dev/unsubscribe/tok-123)",
+ );
+ });
+
+ test("Teams payload uses the maintenance deep-link and a blue/accent header for maintenance", async () => {
+ resolveFetch(new Response(null, { status: 200 }));
+ const sub = makeSub({
+ webhookUrl: TEAMS_WORKFLOWS_URL,
+ pageSlug: "demo",
+ });
+
+ await sendWebhookNotifications(
+ [sub],
+ makeUpdate({ id: 7, status: "maintenance" }),
+ );
+
+ const [, init] = fetchMock.calls[0].args;
+ const body = JSON.parse(init?.body as string);
+ const card = body.attachments[0].content;
+ expect(card.body[0].style).toBe("accent");
+ expect(card.actions[0].url).toBe(
+ "https://demo.openstatus.dev/events/maintenance/7",
+ );
+ });
});
// ─── buildGenericPayload (staged, not yet reachable in production) ────────────
@@ -584,6 +692,22 @@ describe("buildTestPayload", () => {
expect(payload.embeds).toBeInstanceOf(Array);
});
+ test("Teams flavor returns an Adaptive Card wrapped in a Teams message envelope", () => {
+ const payload = buildTestPayload("teams") as {
+ type: string;
+ attachments: {
+ contentType: string;
+ content: { type: string; version: string };
+ }[];
+ };
+ expect(payload.type).toBe("message");
+ expect(payload.attachments[0].contentType).toBe(
+ "application/vnd.microsoft.card.adaptive",
+ );
+ expect(payload.attachments[0].content.type).toBe("AdaptiveCard");
+ expect(payload.attachments[0].content.version).toBe("1.5");
+ });
+
test("generic flavor returns enveloped type='test' JSON", () => {
const payload = buildTestPayload("generic") as {
version: string;
diff --git a/packages/subscriptions/src/channels/webhook.ts b/packages/subscriptions/src/channels/webhook.ts
index cc17dedb6..6fa49a4f4 100644
--- a/packages/subscriptions/src/channels/webhook.ts
+++ b/packages/subscriptions/src/channels/webhook.ts
@@ -6,10 +6,16 @@ import { WEBHOOK_PAYLOAD_VERSION } from "../payload";
import type { PageUpdate, Subscription } from "../types";
import { postWebhookWithRetry } from "./retry";
-export type WebhookFlavor = "slack" | "discord" | "generic";
+export type WebhookFlavor = "slack" | "discord" | "teams" | "generic";
const SLACK_PREFIX = "https://hooks.slack.com/services/";
const DISCORD_PREFIX = "https://discord.com/api/webhooks/";
+// Teams hosts vary by tenant and region, so match by hostname suffix.
+const TEAMS_HOST_SUFFIXES = [
+ ".logic.azure.com",
+ ".powerplatform.com",
+ ".webhook.office.com",
+] as const;
const TIMEOUT_MS = 5000; // 5 seconds
/**
@@ -19,9 +25,20 @@ const TIMEOUT_MS = 5000; // 5 seconds
export function detectWebhookFlavor(url: string): WebhookFlavor {
if (url.startsWith(SLACK_PREFIX)) return "slack";
if (url.startsWith(DISCORD_PREFIX)) return "discord";
+ if (isTeamsWebhookUrl(url)) return "teams";
return "generic";
}
+function isTeamsWebhookUrl(url: string): boolean {
+ let hostname: string;
+ try {
+ hostname = new URL(url).hostname.toLowerCase();
+ } catch {
+ return false;
+ }
+ return TEAMS_HOST_SUFFIXES.some((suffix) => hostname.endsWith(suffix));
+}
+
function redactWebhookUrl(url: string): string {
try {
return `${new URL(url).origin}/***`;
@@ -258,8 +275,118 @@ function buildDiscordPayload(
};
}
+type TeamsContainerStyle = "attention" | "warning" | "good" | "accent";
+type TeamsTextColor = "Default" | "Accent" | "Good" | "Warning" | "Attention";
+
+function teamsStyleForStatus(color: StatusColor): {
+ containerStyle: TeamsContainerStyle;
+ textColor: TeamsTextColor;
+} {
+ switch (color) {
+ case "red":
+ return { containerStyle: "attention", textColor: "Attention" };
+ case "yellow":
+ return { containerStyle: "warning", textColor: "Warning" };
+ case "green":
+ return { containerStyle: "good", textColor: "Good" };
+ case "blue":
+ return { containerStyle: "accent", textColor: "Accent" };
+ }
+}
+
+/**
+ * Microsoft Teams webhook payload (Workflows / legacy Office). Wraps an
+ * Adaptive Card 1.5 in the `application/vnd.microsoft.card.adaptive`
+ * envelope, mirroring the ms-teams monitor-alert provider's wire format.
+ */
+function buildTeamsPayload(
+ pageUpdate: PageUpdate,
+ subscription: Subscription,
+ links: ManagementLinks,
+) {
+ const color = statusColor(pageUpdate.status);
+ const { containerStyle, textColor } = teamsStyleForStatus(color);
+ const eventUrl = resolveEventUrl(pageUpdate, subscription);
+ const pageOrigin = resolveStatusPageOrigin(subscription);
+
+ const body: Record<string, unknown>[] = [
+ {
+ type: "Container",
+ style: containerStyle,
+ items: [
+ {
+ type: "TextBlock",
+ text: pageUpdate.title,
+ weight: "Bolder",
+ size: "Large",
+ color: textColor,
+ wrap: true,
+ },
+ ],
+ },
+ {
+ type: "FactSet",
+ facts: [
+ { title: "Status", value: statusLabel(pageUpdate.status) },
+ { title: "Page", value: `[${subscription.pageName}](${pageOrigin})` },
+ { title: "Timestamp", value: pageUpdate.date },
+ ],
+ },
+ ];
+
+ if (pageUpdate.message) {
+ body.push({
+ type: "TextBlock",
+ text: pageUpdate.message,
+ wrap: true,
+ spacing: "Medium",
+ });
+ }
+
+ if (pageUpdate.pageComponents.length > 0) {
+ body.push({
+ type: "TextBlock",
+ text: `**Affected:** ${pageUpdate.pageComponents.join(", ")}`,
+ wrap: true,
+ });
+ }
+
+ if (links.manageUrl && links.unsubscribeUrl) {
+ body.push({
+ type: "TextBlock",
+ text: `[Manage](${links.manageUrl}) · [Unsubscribe](${links.unsubscribeUrl})`,
+ wrap: true,
+ isSubtle: true,
+ spacing: "Medium",
+ });
+ }
+
+ return {
+ type: "message",
+ attachments: [
+ {
+ contentType: "application/vnd.microsoft.card.adaptive",
+ contentUrl: null,
+ content: {
+ type: "AdaptiveCard",
+ $schema: "https://adaptivecards.io/schemas/adaptive-card.json",
+ version: "1.5",
+ body,
+ actions: [
+ {
+ type: "Action.OpenUrl",
+ title: "View details",
+ url: eventUrl,
+ },
+ ],
+ },
+ },
+ ],
+ };
+}
+
/**
- * Generic JSON webhook payload, sent to any non-Slack/Discord URL.
+ * Generic JSON webhook payload, sent to any non-Slack/Discord/Teams URL.
* Shape is pinned by `webhookPayloadSchema` in `../payload`.
*/
export function buildGenericPayload(
@@ -352,6 +479,8 @@ function buildNotificationPayload(
return buildSlackPayload(pageUpdate, subscription, links);
case "discord":
return buildDiscordPayload(pageUpdate, subscription, links);
+ case "teams":
+ return buildTeamsPayload(pageUpdate, subscription, links);
case "generic":
return buildGenericPayload(pageUpdate, subscription, links);
}
@@ -452,6 +581,45 @@ export function buildTestPayload(flavor: WebhookFlavor) {
},
],
};
+ case "teams":
+ return {
+ type: "message",
+ attachments: [
+ {
+ contentType: "application/vnd.microsoft.card.adaptive",
+ contentUrl: null,
+ content: {
+ type: "AdaptiveCard",
+ $schema: "https://adaptivecards.io/schemas/adaptive-card.json",
+ version: "1.5",
+ body: [
+ {
+ type: "Container",
+ style: "good",
+ items: [
+ {
+ type: "TextBlock",
+ text: "Test Notification",
+ weight: "Bolder",
+ size: "Large",
+ color: "Good",
+ wrap: true,
+ },
+ {
+ type: "TextBlock",
+ text: "Your openstatus webhook is configured correctly.",
+ spacing: "None",
+ isSubtle: true,
+ wrap: true,
+ },
+ ],
+ },
+ ],
+ actions: [],
+ },
+ },
+ ],
+ };
case "generic":
return {
version: WEBHOOK_PAYLOAD_VERSION,