Hi there — great question. The short version is: NetBeez webhooks are sent by the NetBeez server, not by agents, so agent WebSocket messages or port-20018 details won’t affect webhook delivery. Let’s get your Telegram bot receiving real alerts.
1) Enable and test the webhook in NetBeez (server side)
- In the NetBeez dashboard go to Settings → Integrations.
- Enable Webhooks (or expand the integration you’re using) and paste your endpoint:
http://<public-ip-or-dns>:5000/webhook
- Click Test and confirm you see the green check and that your endpoint returns 2xx. (help.netbeez.net)
Tip: After enabling an integration, set which notifications it receives under Settings → Notification Settings (e.g., alerts vs incidents, minimum severity). If this mapping isn’t set, you’ll pass the “Test” but won’t get live alerts. (help.netbeez.net)
2) Verify your alerting actually produces events
Make sure your tests/targets have an Alert Profile (baseline/watermark/up-down) and that the severity threshold you’ve chosen is included in the notification mapping above. Otherwise nothing gets emitted to the webhook. (help.netbeez.net)
3) Confirm your endpoint is reachable by NetBeez Cloud
- The URL must be publicly reachable from the Internet. If you’re on raw
http://IP:5000, ensure inbound rules allow traffic, or front it with HTTPS via a reverse proxy.
- Your handler must reply 2xx quickly (within a few seconds) and not hang; non-2xx responses are treated as failures.
- If you need to restrict sources, allowlist the path behind a token (e.g.,
POST /webhook?token=...) or a header secret, rather than IP-based filtering.
4) Payload your handler should expect
Example (matches what you posted):
{
"data": {
"id": "4868703",
"type": "alert",
"attributes": {
"severity": 6,
"severity_name": "informational",
"alert_dedup_id": 4868695,
"event_type": "ALERT_CLEARED",
"agent": "BCN Wired",
"target": "Genesys",
"destination": "WEST (netdiag.usw2.pure.cloud)",
"message": "Warning Cleared: The 5 minute errors metric (0%) is less than the watermark errors value of 3%.",
"test_type": "PingTest",
"alert_ts": 1760102886934
}
}
}
Notes:
- You’ll also see raise events (e.g.,
event_type: "ALERT_RAISED"). Make sure your code handles both raised and cleared.
- Newer versions include a dedup key so you can suppress repeats (
alert_dedup_id). (help.netbeez.net)
5) Minimal Express handler → Telegram
Here’s a tight Node/Express example that formats the alert and sends it to Telegram via sendMessage:
import express from "express";
import fetch from "node-fetch";
const app = express();
app.use(express.json());
const TELEGRAM_TOKEN = process.env.TELEGRAM_TOKEN; // e.g. 123456:ABC...
const CHAT_ID = process.env.TELEGRAM_CHAT_ID; // e.g. -1001234567890
app.post("/webhook", async (req, res) => {
try {
const a = req.body?.data?.attributes || {};
const when = new Date(Number(a.alert_ts)).toISOString();
const text =
`🔔 NetBeez ${a.event_type?.replace("_", " ")}
• Severity: ${a.severity_name ?? a.severity}
• Test: ${a.test_type}
• Agent: ${a.agent}
• Target: ${a.target}${a.destination ? ` → ${a.destination}` : ""}
• Message: ${a.message}
• Time: ${when}
• Dedup: ${a.alert_dedup_id ?? "-"}`
.replace(/\n\s+/g, "\n");
const tgUrl = `https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage`;
const body = { chat_id: CHAT_ID, text, parse_mode: "HTML", disable_web_page_preview: true };
const r = await fetch(tgUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
if (!r.ok) {
const err = await r.text();
console.error("Telegram error:", err);
return res.status(202).send("Received but Telegram failed");
}
res.status(200).send("OK");
} catch (e) {
console.error(e);
res.status(500).send("Handler error");
}
});
app.get("/health", (_, res) => res.send("OK"));
app.listen(5000, () => console.log("Listening on :5000"));
Local tests
curl -sS -X POST http://localhost:5000/webhook \
-H 'Content-Type: application/json' \
--data @example-alert.json
6) About the WebSocket error you’re seeing
WebSocket CONNECTION ERROR: HS: ws upgrade response not 101
That’s from the agent → server control channel (e.g., registration/tunnels). It’s unrelated to webhook delivery, which is a simple HTTP POST from the NetBeez server to your URL. Focus troubleshooting on the Integration + Notification Settings + your webhook endpoint path/availability. (help.netbeez.net)
Quick troubleshooting checklist
- Integrations → Webhooks is On, your URL is saved, and the Test succeeds. (help.netbeez.net)
- Notification Settings include Alerts (and/or Incidents) for your webhook, with the severity you expect. (help.netbeez.net)
- The tests/targets actually have an Alert Profile that can fire (baseline/watermark/up-down). (help.netbeez.net)
- Your endpoint returns HTTP 2xx quickly; logs show it receives both
ALERT_RAISED and ALERT_CLEARED.
- Endpoint is publicly reachable (consider placing behind HTTPS + DNS).
- Telegram token/chat_id are correct (send a manual
sendMessage to verify).
If you’d like, share (a) a redacted screenshot of Notification Settings, and (b) a brief log line from your /webhook on an actual alert window, and I can spot-check the mapping.