New Tool Radar

AI Agents & Automation

How to Alert a Slack Channel When an Agent Run Fails

Send a Slack webhook message when an agent run fails so the team hears about it within minutes instead of at the weekly review.

Schematic diagram with three steps: Create the webhook, Add the alert step, then Test a failure.

A failed run that nobody sees is a failure that repeats. A webhook alert sends a short message to a Slack channel when a run fails, with the run ID and the error, so the team hears about it within minutes.

Before you start

You need a Slack channel for agent alerts and a webhook URL for it, plus an agent run that can call a webhook on failure. Keep the webhook URL private: anyone with it can post to the channel.

Create the webhook and add the alert step

Create an incoming webhook in Slack for the alerts channel and copy its URL. Add an alert step to the agent workflow or runner that fires only on failure, sending the run ID, the error and a link to the log. The message should be short: one line per failure is enough.

Test the alert with a forced failure

Force a failure, for example by asking a question the tools cannot answer, and check the Slack message arrives within a minute. If nothing arrives, check the webhook URL and whether the alert step is on the failure path. If the channel floods, the alert is firing on successes too.

Worked example: Alert test for a fictional support agent

Northwind Support is a fictional help desk. Its agent alerts a Slack channel on failure. The table shows the test.

Test Alert sent? Channel
Forced failure: unanswerable question Yes agent-alerts
Normal run No None
Timeout Yes agent-alerts

Expected result (UNTESTED): the forced failure and the timeout each send one Slack message to agent-alerts, and the normal run sends nothing. We checked the n8n tutorial, which describes workflow triggers and actions, but we did not create the webhook on this machine.

Limits

An alert channel that fires too often gets muted, which is worse than no alert. Alert on failures only, keep the message to one line, and review the alert rate weekly. Rotate the webhook URL if it ever leaks.

Sources

See all