# LangSmith alert notifications on your phone

> Get a push notification when a LangSmith project alert on errors, latency, cost or feedback score crosses its threshold.

- Company: LangSmith (https://www.justpush.io/recipes/langsmith)
- Event: `alert` (Alert)
- Tags: AI, Monitoring
- Install: https://studio.justpush.io/recipes/langsmith/alert
- Web page: https://www.justpush.io/recipes/langsmith/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 is configured in a different part of LangSmith than the other recipes.
3. Paste your webhook URL (shown in Studio after install) (plus any query parameters from the notes) as the webhook URL and save.
4. In your tracing project, click the **Alerts** icon (top right) → **+ Alert**, pick the metric and threshold, and under **Notification Settings** choose **Webhook**. Paste the URL above.
5. Leave the **request body template** empty (or `{}`): LangSmith adds the alert details itself, and doesn't fill in `{placeholders}` in the template.
6. Use **Send Test Alert** to check it. LangSmith doesn't sign alert webhooks, 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
// LangSmith → alert
// Fires when a LangSmith project alert (errors, latency, cost, feedback score, run count)
// crosses its threshold and notifies a Webhook channel.
// Docs: https://docs.langchain.com/langsmith/alerts

// alert_rule_attribute → how to describe the metric.
const METRICS = {
    error_count: { label: "Errors", emoji: "❌" },
    feedback_score: { label: "Feedback score", emoji: "👎" },
    latency: { label: "Latency", emoji: "🐢" },
    cost: { label: "Cost", emoji: "💸" },
}

// Round to at most two decimals without trailing zeros: 0.1234 → "0.12", 12 → "12".
function num(value) {
    const n = Number(value)
    return Number.isFinite(n) ? String(Math.round(n * 100) / 100) : null
}

// 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 || {}

    // Guard: only LangSmith alert payloads, so anything else on this integration stays quiet.
    if (!body.alert_rule_id || !body.alert_rule_name) {
        console.log("Not a LangSmith alert payload — skipping")
        return null
    }

    const metric = Object.prototype.hasOwnProperty.call(METRICS, body.alert_rule_attribute)
        ? METRICS[body.alert_rule_attribute]
        : { label: "Metric", emoji: "🚨" }
    const value = num(body.triggered_metric_value)
    const threshold = num(body.triggered_threshold)
    const reading = value
        ? `${metric.label} ${value}` + (threshold ? ` (threshold ${threshold})` : "")
        : null
    const where = body.project_name ? ` in ${body.project_name}` : ""

    return {
        title: `${metric.emoji} ${body.alert_rule_name}`,
        message: (reading ?? "Alert threshold crossed") + where,
        topic: "LangSmith",
        priority: 1, // High — an alert you set up yourself just crossed its line
        buttons: [...link(body.runs_url, "View runs"), ...link(body.alert_rule_url, "View alert")],
    }
}
```

## LangSmith alert webhook payload (sample)

```json
{
  "runs_url": "https://smith.langchain.com/o/2ebda79f/projects/p/6a3be6a2?filter=eq(is_root%2C%20true)%2Ceq(error%2C%20true)",
  "timestamp": "2026-09-29T09:15:00Z",
  "project_name": "support-bot",
  "alert_rule_id": "5e2f4c1a-7b3d-4e8f-9a0b-1c2d3e4f5a6b",
  "alert_rule_url": "https://smith.langchain.com/o/2ebda79f/projects/p/6a3be6a2?alertRule=5e2f4c1a",
  "workspace_name": "Acme",
  "alert_rule_name": "Error spike",
  "alert_rule_type": "threshold",
  "triggered_threshold": 10,
  "alert_rule_attribute": "error_count",
  "alert_rule_description": "",
  "triggered_metric_value": 14
}
```

## 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 LangSmith 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.
