Loomscape Docs

Alerts

Deliver project events to email, Slack, Telegram or your own webhook, and verify webhook signatures

An alert rule sends newly detected events of a project (mention spikes, complaint clusters, sentiment shifts and so on) to the channels configured on the rule. Rules live on the project page in the app under Alerts. Every rule has a Send test alert button that delivers a sample event to all of its channels and reports which ones failed.

Telegram

  1. Create a bot with @BotFather (/newbot) and copy the bot token it gives you, for example 123456789:AAH….
  2. Add the bot to the group or channel that should receive alerts. In a channel the bot needs permission to post messages.
  3. Find the chat ID. For a group, send any message in it, then open https://api.telegram.org/bot<token>/getUpdates and read message.chat.id (group IDs are negative, such as -1001234567890). A public channel can use its @username instead.
  4. Enter the bot token and the chat ID in the alert rule. Both are required together.

The bot token is stored as a secret. The app only shows the bot ID and the last four characters.

Webhooks

A webhook rule sends an HTTPS POST with a JSON body:

{
  "project": "Gahalu",
  "rule": "Brand crisis",
  "dashboardUrl": "https://app.loomscape.space/analytics?projectId=…",
  "test": false,
  "events": [
    {
      "id": "…",
      "projectId": "…",
      "brandId": "…",
      "brandName": "Gahalu",
      "type": "complaint_cluster",
      "severity": "critical",
      "title": "…",
      "summary": "…",
      "evidenceUrl": "https://…",
      "occurredAt": "2026-09-28"
    }
  ]
}

test is true for requests sent with Send test alert. The endpoint must answer with a 2xx status within 15 seconds, otherwise the delivery counts as failed and is retried.

Signature

Every webhook request carries a Loomscape-Signature header:

Loomscape-Signature: t=1790589600,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
  • t is the Unix time in seconds when the request was signed.
  • v1 is the hex HMAC-SHA256 of the string <t>.<raw request body>, keyed with the rule's signing secret (whsec_…).

Each rule has its own signing secret. Open the rule in the app and choose Show webhook signing secret to view or copy it. Rotate secret replaces it immediately: the old secret stops working for the next request, so update your receiver first.

To verify a request:

  1. Read the raw body exactly as received, before parsing JSON. Re-serialized JSON will not match.
  2. Split the header on , and each part on the first = to get t and v1.
  3. Compute HMAC-SHA256 of `${t}.${rawBody}` with the signing secret and hex-encode it.
  4. Compare it with v1 using a constant-time comparison.
  5. Reject requests whose t is more than 5 minutes away from your clock, to block replays.

Node.js

import { createHmac, timingSafeEqual } from 'node:crypto'

export function verifyLoomscapeSignature(rawBody, header, secret, toleranceSeconds = 300) {
  const parts = new Map(header.split(',').map((part) => part.split('=', 2)))
  const timestamp = Number(parts.get('t'))
  if (!Number.isInteger(timestamp) || Math.abs(Date.now() / 1000 - timestamp) > toleranceSeconds) return false
  const expected = createHmac('sha256', secret).update(`${parts.get('t')}.${rawBody}`).digest('hex')
  const received = parts.get('v1') ?? ''
  return received.length === expected.length && timingSafeEqual(Buffer.from(received), Buffer.from(expected))
}

// Express: keep the raw body for the alert route.
app.post('/loomscape', express.raw({ type: 'application/json' }), (req, res) => {
  const rawBody = req.body.toString('utf8')
  if (!verifyLoomscapeSignature(rawBody, req.get('Loomscape-Signature') ?? '', process.env.LOOMSCAPE_WEBHOOK_SECRET)) {
    return res.status(401).end()
  }
  const alert = JSON.parse(rawBody)
  res.status(204).end()
})

Python

import hashlib
import hmac
import time


def verify_loomscape_signature(raw_body: bytes, header: str, secret: str, tolerance_seconds: int = 300) -> bool:
    parts = dict(part.split("=", 1) for part in header.split(",") if "=" in part)
    try:
        timestamp = int(parts["t"])
    except (KeyError, ValueError):
        return False
    if abs(time.time() - timestamp) > tolerance_seconds:
        return False
    signed_payload = f"{parts['t']}.".encode() + raw_body
    expected = hmac.new(secret.encode(), signed_payload, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts.get("v1", ""))

On this page