---
id: I0113
title: "Teams network congestion card"
url: https://carbium.sh/library/integrate/teams-network-congestion-card
collection: Integrations
category: Chat and notifications
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Teams network congestion card

A small Node watcher reads Solana's recent TPS samples and priority fees from Carbium every minute, grades congestion as calm, busy or congested, and posts an Adaptive Card to a Teams channel at start and whenever the grade changes.

## What lands in the channel

The watcher is one Node process with one dependency, `@solana/kit`. Every 60 seconds it reads three things from Carbium and decides on a congestion level. It posts one Adaptive Card to a Teams channel when it starts and again each time the level changes. A level that holds steady stays quiet.

The card has a colored heading with the level, then four facts: transactions per second from the newest performance sample, the mean over the last five samples, the median priority fee, and the processed slot.

| Level | When | Heading color |
|---|---|---|
| calm | Median priority fee below `FEE_BUSY` (default 1000 micro-lamports per compute unit). | Good |
| busy | Median at or above `FEE_BUSY` and below `FEE_CONGESTED` (default 50000). | Warning |
| congested | Median at or above `FEE_CONGESTED`. | Attention |

Both thresholds are starting points. Run the file without a webhook URL at a few different hours, note the median each time, and set the two numbers from what a normal median looks like on the network.

## Where TPS and congestion come from

Solana has no call that returns the current TPS. `getRecentPerformanceSamples` returns one sample per 60 second window, newest first, and each sample carries the slot it ended on, the number of slots, the transaction count and `samplePeriodSecs`. TPS is the transaction count divided by the period. Asking for 5 samples covers the last five minutes.

Two limits follow from that shape. The figure is an average over a minute, so a ten second burst is smoothed into it. The newest sample can also be up to a minute old, so the number trails the chain by that much.

Since the Alpenglow switch on 2026-10-21, mainnet blocks carry no vote transactions. The transaction count in a recent sample is therefore user and program transactions only, and the division needs no subtraction. Samples from before that date include votes and read far higher, so do not chart them on the same axis.

A high TPS is not the same as a congested network, because a chain can run busy and still land everything at a zero fee. Congestion shows up as fee pressure. `getRecentPrioritizationFees` returns one priority fee per recent slot, in micro-lamports per compute unit, for up to 150 slots. Each value is the minimum priority fee any transaction in that slot paid. The watcher sorts them and takes the median, so a median above zero means that in most recent slots every landed transaction paid a fee.

The slot is read at `processed`, the newest slot the node has seen, and it is shown for orientation only. The other two methods take no commitment.

## The Teams side: a workflow URL

Teams takes the card through a Workflows webhook. In the channel, add a workflow from the template that posts to a channel when a webhook request is received, and copy the HTTP URL it gives you into `TEAMS_WEBHOOK_URL`. Treat that URL as a secret, since whoever holds it can post to the channel. The older Office 365 connector webhooks are being retired, so a new setup should start from a workflow.

The body is a JSON message with one attachment of content type `application/vnd.microsoft.card.adaptive`. Its content is an Adaptive Card at version 1.4: a `TextBlock` for the heading and a `FactSet` for the four facts. Any 2xx answer counts as accepted.

The watcher records the level it last posted only after Teams answers with a 2xx. If the URL is wrong or Teams is down, the next poll tries again with the current level.

## The watcher

Install the dependency with `npm install @solana/kit@8.6.0` and set `"type": "module"` in `package.json`. Node 24 strips the types on load. `CARBIUM_KEY` is required and the file exits with a message when it is missing. `TEAMS_WEBHOOK_URL`, `FEE_BUSY`, `FEE_CONGESTED` and `CARBIUM_RPC_URL` are optional. With no webhook URL the file prints the card JSON once and exits, which is the quickest way to see what Teams would receive.

`main.ts` (run: `node main.ts`)

```ts
// I0113 · Teams network congestion card
// https://carbium.sh/library/integrate/teams-network-congestion-card
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY.");
  process.exit(1);
}
const hook = process.env.TEAMS_WEBHOOK_URL; // unset: print the card once and exit
const busy = Number(process.env.FEE_BUSY ?? 1000); // micro-lamports per compute unit
const congested = Number(process.env.FEE_CONGESTED ?? 50_000);
if (!Number.isFinite(busy) || !Number.isFinite(congested)) {
  console.error("FEE_BUSY and FEE_CONGESTED must be numbers.");
  process.exit(1);
}
const POLL_MS = 60_000;
const timeout = () => AbortSignal.timeout(5_000);
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);

type Level = "calm" | "busy" | "congested";
const color: Record<Level, string> = { calm: "Good", busy: "Warning", congested: "Attention" };

async function read() {
  const [s, f, slot] = await Promise.allSettled([
    rpc.getRecentPerformanceSamples(5).send({ abortSignal: timeout() }),
    rpc.getRecentPrioritizationFees().send({ abortSignal: timeout() }),
    rpc.getSlot({ commitment: "processed" }).send({ abortSignal: timeout() }),
  ]);
  if (s.status === "rejected" || f.status === "rejected") {
    const why = [s, f].flatMap((x) => (x.status === "rejected" ? [String(x.reason)] : []));
    throw new Error(`read failed: ${why.join("; ")}`);
  }
  const tps = s.value.map((x) => Number(x.numTransactions) / Number(x.samplePeriodSecs));
  const fees = f.value.map((x) => Number(x.prioritizationFee)).sort((a, b) => a - b);
  const median = fees.length ? fees[Math.floor(fees.length / 2)] : 0;
  const level: Level = median >= congested ? "congested" : median >= busy ? "busy" : "calm";
  const mean = tps.length ? tps.reduce((a, b) => a + b, 0) / tps.length : 0;
  return { level, latest: tps[0] ?? 0, mean, median, slot: slot.status === "fulfilled" ? slot.value.toString() : "n/a" };
}

const card = (r: Awaited<ReturnType<typeof read>>) => ({
  type: "message",
  attachments: [{
    contentType: "application/vnd.microsoft.card.adaptive",
    content: {
      $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
      type: "AdaptiveCard",
      version: "1.4",
      body: [
        { type: "TextBlock", text: `Solana network: ${r.level}`, weight: "Bolder", size: "Medium", color: color[r.level] },
        { type: "FactSet", facts: [
          { title: "TPS, newest 60 s sample", value: r.latest.toFixed(0) },
          { title: "TPS, mean of 5 samples", value: r.mean.toFixed(0) },
          { title: "Median priority fee", value: `${r.median} micro-lamports/CU` },
          { title: "Slot (processed)", value: r.slot },
        ] },
      ],
    },
  }],
});

let posted: Level | null = null;
for (;;) {
  try {
    const r = await read();
    if (!hook) {
      console.log(JSON.stringify(card(r), null, 1));
      break;
    }
    if (r.level !== posted) {
      const res = await fetch(hook, { method: "POST", headers: { "content-type": "application/json" }, signal: timeout(), body: JSON.stringify(card(r)) });
      if (!res.ok) throw new Error(`Teams answered ${res.status}`);
      posted = r.level; // only after Teams accepted it, so a failed post is retried
    }
  } catch (err) {
    console.error("poll failed:", err instanceof Error ? err.message : err);
  }
  await new Promise((done) => setTimeout(done, POLL_MS));
}
```

## Run it and force a level

Run `node main.ts` without a webhook URL first and read the JSON. Then set `TEAMS_WEBHOOK_URL` and start it again under a supervisor such as a systemd unit, so it survives a crash or a reboot. The first poll always posts, so you see a card within a minute.

To see a busy card, start it with `FEE_BUSY=0` and `FEE_CONGESTED=1000000000`: every median is at or above 0, so the first card says busy. Restart with the defaults and the next start posts a fresh card for the real level. The last posted level lives in memory, so every restart posts once.

## What it asks of your account

Each poll sends three calls to the [RPC endpoint](https://carbium.sh/docs/endpoints) at `https://services.carbium.sh`, with the key in the `x-api-key` header. That is 3 calls a minute, or 0.05 req/s. [Limits are per account](https://carbium.sh/docs/limits), so all your keys share one budget, and heavy app traffic on other keys can leave a watcher call with a 429. The watcher logs the failure and tries again at the next poll, 60 seconds later, with the last posted level untouched.

## Where it ends

- TPS here is a one minute average. It cannot show a spike that starts and ends inside a window, and the newest sample may be a minute old.
- The median covers every recent slot, so it can sit at 0 while one hot program is bidding fees up. For one program or account, pass its addresses to `getRecentPrioritizationFees` yourself; the file does not.
- The thresholds are fixed numbers with no baseline learned from history, and no margin on the way back down. A median that hovers at a threshold posts a card on each crossing.
- A watcher that dies sends no alert, and a restart forgets the last level. Supervise the process, since a quiet channel looks the same whether the level held or the watcher stopped.
- A 2xx from Teams means the workflow accepted the request. Whether the card reached the channel is shown in the workflow's own run history.
- It reports what the node's recent samples and fee cache say. It does not predict congestion and does not know why fees rose.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| Teams answers 400 or 404 and the log shows `poll failed: Teams answered 404`. | The webhook URL is cut short, revoked, or an old connector URL. Create a workflow from the webhook template, copy the whole HTTP URL into `TEAMS_WEBHOOK_URL` and restart. The next poll posts the current level. |
| The log shows no error, but nothing appears in the channel. | The workflow accepted the request and then failed on its own. Open its run history in Power Automate and read the failed step. A workflow built for a different body, or one whose owner lost access to the channel, fails after the 2xx. |
| The card posts again and again while the level hovers between calm and busy. | The median is crossing `FEE_BUSY` on every other poll. Raise the threshold to sit above the usual noise, or change the code to leave a level only when the median moves a margin past the threshold. |
| The log shows `poll failed: read failed:` followed by an HTTP error 401. | Carbium does not know the key. Check that `CARBIUM_KEY` holds the whole key and that nothing else sets `CARBIUM_RPC_URL` to another host. The key goes in the [`x-api-key` header](https://carbium.sh/docs/auth). |
| The level stays calm during a visible rush on one program. | The median over all slots stays at 0 when only one program's accounts are contested. Add the program's write-locked account addresses to the `getRecentPrioritizationFees` call and read the median for those. |
| The TPS on the card is far under a dashboard's figure. | The dashboard may include vote transactions or use a shorter window. This figure is the user transaction count of a 60 second sample divided by 60, which matches what the node recorded for that window. |

## Questions

### Is there a call that returns TPS in real time?

No. The node records one sample per 60 seconds and `getRecentPerformanceSamples` returns those. For finer grain you read blocks with `getBlock` and divide the transaction count by the time they cover, which is a heavier read and a larger program.

### Why grade congestion on fees and not on TPS?

A high TPS can be a healthy chain landing everything at no fee. A median priority fee above zero says transactions are competing for space, which is what a team reading the card wants to know.

### Can the card carry a link or a button?

Yes. Adaptive Cards take an `Action.OpenUrl` in the card's `actions` array, next to `body`, so you can add one that opens your own dashboard. Edit the `card` function and keep the rest.

### Does it work for a chat instead of a channel?

The payload is the same. Create the workflow from the template that posts to a chat and put its URL in `TEAMS_WEBHOOK_URL`.

## Related

- [Non-vote TPS meter](https://carbium.sh/library/blockchainideas/non-vote-tps-meter) (Blockchain ideas, BI0063)
- [Slack slot-lag alerts](https://carbium.sh/library/integrate/slack-slot-lag-alerts) (Integrations, I0001)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
