# LangWatch automation notifications on your phone > Get a push notification when a LangWatch automation matches traces, fires a graph alert, or sends a scheduled report. - Company: LangWatch (https://www.justpush.io/recipes/langwatch) - Event: `automation` (Automation) - Tags: AI, Monitoring - Install: https://studio.justpush.io/recipes/langwatch/automation - Web page: https://www.justpush.io/recipes/langwatch/automation ## 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 for Automation. 3. Paste your webhook URL (shown in Studio after install) as the webhook URL and save. 4. Send a test fire to check it. 5. In LangWatch, create an automation (a trace filter, a graph alert, or a scheduled report) and choose the **Webhook** action with the URL above. Keep the **default body**: the recipe reads LangWatch's default fields, so a custom template would break it. 6. **Availability:** the Webhook action for automations is new and may not be switched on for every LangWatch workspace yet. If you don't see it, use the [gateway](../gateway) recipe or ask LangWatch to enable it. 7. LangWatch can sign requests with `X-LangWatch-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 // LangWatch โ†’ automation webhook // Fires when a LangWatch automation with a Webhook action matches traces, fires a graph // alert, or sends a scheduled report. Expects LangWatch's default webhook body. // Docs: https://langwatch.ai/docs/features/automations // Alert types โ†’ emoji and priority. const ALERT_TYPES = { CRITICAL: { emoji: "๐Ÿšจ", priority: 2 }, WARNING: { emoji: "๐ŸŸ ", priority: 0 }, INFO: { emoji: "โ„น๏ธ", priority: -1 }, } // Condition operators โ†’ symbols. const OPERATORS = { gt: ">", gte: "โ‰ฅ", lt: "<", lte: "โ‰ค", eq: "=" } // 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 } // Keep long inputs readable in a notification. function clip(value, max = 100) { const text = (typeof value === "string" ? value : value == null ? "" : JSON.stringify(value)).replace(/\s+/g, " ").trim() return text.length > max ? text.slice(0, max - 1) + "โ€ฆ" : text || 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 || {} const name = body.trigger?.name ?? "LangWatch automation" const project = body.project?.name const type = pick(ALERT_TYPES, body.trigger?.alertType, null) if (body.event === "trigger.matched") { const matches = Array.isArray(body.matches) ? body.matches : [] const count = Number(body.digest?.count) || matches.length const first = clip(matches[0]?.input, 80) return { title: `${type?.emoji ?? "๐Ÿ”Ž"} ${name}`, message: `${count} trace${count === 1 ? "" : "s"} matched` + (project ? ` in ${project}` : "") + (first ? ` โ€” โ€œ${first}โ€` : ""), topic: "LangWatch", priority: type?.priority ?? 0, buttons: link(matches[0]?.url, "View trace"), } } if (body.event === "alert.fired") { const metric = body.metric?.label ?? body.graph?.name ?? "Metric" const operator = pick(OPERATORS, body.condition?.operator, body.condition?.operator ?? "") const rule = body.condition?.threshold != null ? ` (${operator} ${body.condition.threshold}${body.condition.window ? ` over ${body.condition.window}` : ""})` : "" return { title: `${type?.emoji ?? "๐Ÿšจ"} ${name}`, message: `${metric}: ${body.currentValue ?? "?"}${rule}` + (project ? ` ยท ${project}` : ""), topic: "LangWatch", priority: type?.priority ?? 1, buttons: link(body.graph?.url, "View graph"), } } if (body.event === "report.scheduled") { const charts = Array.isArray(body.charts) ? body.charts : [] const summary = charts .filter((chart) => chart?.title && chart.total != null) .slice(0, 3) .map((chart) => `${chart.title}: ${chart.total}`) .join(" ยท ") return { title: `๐Ÿ“Š ${name}`, message: summary || (body.report?.isEmpty ? "Nothing to report" : `Report for ${project ?? "your project"}`), topic: "LangWatch", priority: -1, // Low โ€” a scheduled digest buttons: link(body.viewUrl, "View report"), } } // Guard: anything else (including custom templates) is ignored. console.log(`Ignoring LangWatch event "${body.event ?? "unknown"}"`) return null } ``` ## LangWatch automation webhook payload (sample) ```json { "event": "alert.fired", "graph": { "url": "https://app.langwatch.ai/support-bot/analytics/custom/graph_01J9", "name": "Faithfulness score" }, "metric": { "label": "Avg. faithfulness" }, "project": { "name": "Support bot", "slug": "support-bot" }, "trigger": { "id": "trigger_01J9", "name": "Hallucination rate", "alertType": "CRITICAL" }, "condition": { "window": "1h", "operator": "lt", "threshold": 0.8 }, "currentValue": 0.71, "previousValue": 0.86 } ``` ## 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 LangWatch 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.