# Langfuse alert notifications on your phone

> Get a push notification when a Langfuse alert on latency, cost, errors or scores changes severity, including when it recovers.

- Company: Langfuse (https://www.justpush.io/recipes/langfuse)
- Event: `monitor-alert` (Alert)
- Tags: AI, Monitoring
- Install: https://studio.justpush.io/recipes/langfuse/alert
- Web page: https://www.justpush.io/recipes/langfuse/alert

## Setup

1. Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL.
2. Follow the setup notes below: Alert lives under Prompts > Automations or Project > Alerts.
3. Choose the Webhook action and paste your webhook URL (shown in Studio after install) as the URL.
4. Save the automation or alert.
5. In your Langfuse project, go to **Alerts → New Alert**, set the metric and thresholds, and choose **Webhook** as the notification with the URL above.
6. Langfuse sends one webhook per severity change (plus optional reminders), so you hear about it when it goes wrong and when it recovers. Alerts are limited per plan (Hobby 2, Core 20, Pro 50).
7. Langfuse signs each request with `x-langfuse-signature` (HMAC-SHA256), but JustPush doesn't check it yet, so keep your endpoint URL private.

## Code

Studio calls `handleRequest(request)` with the incoming webhook (`{ method, headers, body, query, raw }`) and sends the message object it returns. Returning `null` sends nothing.

```js
// Langfuse → alert
// Fires when a Langfuse alert (latency, cost, error rate, scores, …) changes severity.
// Docs: https://langfuse.com/docs/observability/features/alerts

// Severities: how to label them and how loud to be. PAUSED doesn't push.
const SEVERITIES = {
    ALERT: { emoji: "🚨", priority: 1 },
    WARNING: { emoji: "🟠", priority: 0 },
    NO_DATA: { emoji: "⚪", priority: 0 },
    OK: { emoji: "✅", priority: -1 },
    UNKNOWN: { emoji: "❔", priority: 0 },
}

// Look a key up in one of the tables above, ignoring inherited names like "toString".
function pick(table, key, fallback) {
    return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : fallback
}

// Only link to real http(s) URLs.
function link(url, cta) {
    return typeof url === "string" && /^https?:\/\//.test(url) ? [{ cta, url }] : []
}

function handleRequest(request) {
    const body = request.body || {}
    const alert = body.payload

    // Guard: only monitor alerts, so prompt webhooks on this integration stay quiet.
    if (body.type !== "monitor-alert" || !alert) {
        console.log(`Ignoring Langfuse "${body.type ?? "unknown"}" webhook`)
        return null
    }

    const severity = pick(SEVERITIES, alert.severity, null)

    if (!severity) {
        console.log(`Skipping alert with severity "${alert.severity}"`)
        return null
    }

    const title = alert.message?.title ?? "Langfuse alert"
    const text = alert.message?.body ?? `Severity: ${alert.severity}`

    return {
        title: `${severity.emoji} ${title.charAt(0).toUpperCase()}${title.slice(1)}`,
        message: text,
        topic: "Langfuse",
        priority: severity.priority,
        buttons: [...link(alert.permalink, "View alert"), ...link(alert.dataPermalink, "View data")],
    }
}
```

## Langfuse monitor-alert webhook payload (sample)

```json
{
  "id": "660e8400-e29b-41d4-a716-446655440001",
  "type": "monitor-alert",
  "payload": {
    "view": "observations",
    "window": "1h",
    "filters": [],
    "message": {
      "body": "avg latency is 1234 ms (threshold: 1000 ms) over the last 1 hour",
      "title": "avg latency crossed alert threshold"
    },
    "severity": "ALERT",
    "monitorId": "monitor_abc123",
    "permalink": "https://cloud.langfuse.com/project/proj_xyz789/monitors/monitor_abc123",
    "projectId": "proj_xyz789",
    "timestamp": "2026-09-29T10:30:00Z",
    "toTimestamp": "2026-09-29T10:30:00Z",
    "fromTimestamp": "2026-09-29T09:30:00Z"
  },
  "timestamp": "2026-09-29T10:30:00Z",
  "apiVersion": "v1"
}
```

## FAQ

### Does this work on iPhone and Android?

Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification.

### Do I need to write code?

No. Install the recipe in Studio, paste your webhook URL into Langfuse and you are done. The code is there if you want to change the text, the sound or the buttons.

### Can I change what the notification says?

Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save.

### What does it cost?

JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.
