Changelog #89

·

Alert webhooks

Receive a webhook alert when runs fail, deploys fail, or deploys succeed.

Matt Aitken

Matt Aitken

CEO, Trigger.dev

Image for Alert webhooks

We've added support for webhook alerts in Trigger.dev. Now you can receive alerts via webhooks when runs fail, deployments fail, or deployments succeed. This complements our existing email and Slack notification options.

How it works

You can now setup webhook alerts through our dashboard and handle them in your application using our SDK. When an alert is triggered, we'll send a POST request to your specified endpoint with details about the event.

Setting up webhook alerts

  1. Navigate to the "Alerts" section in the dashboard
  2. Click "New alert"
  3. Select "Webhook" as your alert method
  4. Choose which events you want to receive alerts for:
    • Run failures
    • Deployment failures
    • Deployment successes
  5. Enter your webhook URL
  6. Copy the generated webhook secret - you'll need this to verify webhooks

Handling webhooks

Here's how to handle webhook alerts in your application using the Trigger.dev SDK. In this exammple, we're using the Remix framework:


import { ActionFunctionArgs, json } from "@remix-run/server-runtime";
import { webhooks, WebhookError } from "@trigger.dev/sdk/v3";
export async function action({ request }: ActionFunctionArgs) {
if (request.method !== "POST") {
return json({ error: "Method not allowed" }, { status: 405 });
}
try {
const event = await webhooks.constructEvent(request, process.env.ALERT_WEBHOOK_SECRET!);
// Handle different alert types
switch (event.type) {
case "alert.run.failed": {
console.log("Run failed alert received", { event });
break;
}
case "alert.deployment.success": {
console.log("Deployment succeeded alert received", { event });
break;
}
case "alert.deployment.failed": {
console.log("Deployment failed alert received", { event });
break;
}
}
return json({ received: true });
} catch (err) {
if (err instanceof WebhookError) {
return json({ error: err.message }, { status: 400 });
}
return json({ error: "Internal server error" }, { status: 500 });
}
}

Why is this useful?

Webhook alerts allow you to:

  • Build custom alert handling logic
  • Integrate alerts with your existing monitoring systems
  • Automate responses to failed runs or deployments
  • Track deployment success/failure rates

Next steps

Check out our Alerts documentation to learn more about setting up alerts. If you have questions or need help, join us on Discord or reach out on Twitter.

Ready to start building?

Build and deploy your first task in 3 minutes.

Get started now