services
Get a key

library / Integrations / Chat and notifications / I0113

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.

By Carbium · Chat and notifications · I0113 · updated 2026-11-23

01

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.

LevelWhenHeading color
calmMedian priority fee below FEE_BUSY (default 1000 micro-lamports per compute unit).Good
busyMedian at or above FEE_BUSY and below FEE_CONGESTED (default 50000).Warning
congestedMedian 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.

02

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.

03

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.

04

The watcher

Install the dependency with npm install @solana/[email protected] 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
// 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: MITimport { 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 exitconst busy = Number(process.env.FEE_BUSY ?? 1000); // micro-lamports per compute unitconst 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: node main.ts

05

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.

06

What it asks of your account

Each poll sends three calls to the RPC endpoint 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, 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.

07

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.
08

When it goes wrong

what goes wrongwhat 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.
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.
09

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.