Know when an n8n AI Agent errors or returns an empty answer
Your workflow tells Stallbell when it starts, what the agent answered and when it fails, and Stallbell emails you if the agent errors, comes back empty, hangs, or the workflow stops running.
The problem
An n8n workflow runs an AI Agent every hour and emails the result to the team. One day the model provider returns a 500 or a rate-limit error, or the agent "succeeds" with an empty answer, and the next node sends a blank email or nothing at all. Without an error workflow, a failed execution just sits in n8n's execution list until someone looks.
This page is a ready-made setup for one scenario.
What goes wrong silently
| What happens in n8n | What Stallbell sees | Alert |
|---|---|---|
| The model call fails (500, 429, bad credentials) and the execution stops | A fail from the error workflow with n8n's message | Failed run |
| The AI Agent returns an empty answer | The finish ping with output: "" | Empty output |
| The agent node is set to Continue on error and the model fails | The finish ping with no answer, sent as "" | Empty output |
| The model or a tool hangs | A start with no finish within 15 minutes | Stuck run |
| The schedule stops, or the workflow is unpublished | No check-in by the expected time plus grace | Missed run |
| The next run answers | A good finish after the incident | Recovered |
Creates a monitor called n8n-ai-agent-empty-answer with the settings below. You can change everything later.
Setup
Add two HTTP Request nodes around the AI Agent, and a small error workflow. All three use Method POST, Send Body on, Body Content Type JSON, Specify Body Using JSON, and the JSON field in expression mode. In each node's Settings tab, turn on Execute Once and Retry On Fail, and set On Error to Continue, so a problem reaching Stallbell never breaks the workflow.
// 1. "Stallbell start", right after the trigger
// URL: https://stallbell.com/p/TOKEN/start
{{ JSON.stringify({ run_id: String($execution.id) }) }}
// 2. "Stallbell finish", right after the AI Agent node
// URL: https://stallbell.com/p/TOKEN/ok
{{ JSON.stringify({
run_id: String($execution.id),
output: String($json.output ?? "").slice(0, 2000)
}) }}
// 3. "Stallbell fail", in a separate workflow that starts with an Error Trigger
// URL: https://stallbell.com/p/TOKEN/fail
{{ JSON.stringify({
run_id: $json.execution?.id ? String($json.execution.id) : undefined,
msg: String($json.execution?.error?.message ?? $json.trigger?.error?.message ?? "n8n workflow failed").slice(0, 500)
}) }}Then:
- Publish the error workflow (n8n 2.x). On 2.43.7 an unpublished error workflow is skipped. On n8n 1.x, saving it is enough.
- In the workflow with the agent, open ⋯ > Settings and pick the error workflow under Error Workflow (to notify when this one errors).
The AI Agent node puts its answer in output, so the finish node reads $json.output. JSON.stringify keeps the answer's quotes and line breaks valid JSON, and .slice(0, 2000) keeps the body small. Stallbell stores the first 2 KB.
Don't paste {{ $json.output }} inside a hand-written JSON body. We tried {"run_id": "{{ $execution.id }}", "output": "{{ $json.output }}"}. On an answer with quotes and line breaks, n8n refused it with "The value in the JSON Body field is not valid JSON", and because the node was set to On Error: Continue, it sent nothing and the workflow still went green.
Stop or continue when the agent errors?
Both are covered, by different alerts:
- Stop (n8n's default): the execution fails, the error workflow sends
failwith n8n's message, and you get a Failed run email with it on the Failure line. In our test the messages were "The service was not able to process your request" for a 500 and "The service is receiving too many requests from you" for a 429. - On Error: Continue on the AI Agent node: the run carries on without an answer. The finish ping sends
output: ""and you get an Empty output warning instead.
Recommended settings
| Field | Value | Why |
|---|---|---|
| Kind | Workflow | A label only. It's an n8n workflow. |
| How it runs | On a fixed interval | Most AI Agent workflows run from a Schedule Trigger on an interval. |
| Every | 1 hour | Every hour. Change it to match your Schedule Trigger. |
| Grace period | 10 minutes | 10 minutes covers n8n queue delays. |
| Failures in a row | 1 | An agent error usually means the next email or reply is blank, so the first one alerts. |
| Stuck after | 15 minutes | 15 minutes. A model or tool call that hangs longer than that is stuck. |
| Flag empty output | On | The finish ping sends the agent's answer as output, so an empty answer raises Empty output. |
Optional: if the agent must answer in JSON, turn on Output must be JSON. If every good answer contains a fixed phrase or key, put it in Output must contain. Both check the first 2 KB.
Related
- Docs: check-in fields
FAQ
What does the alert say when the model errors?
The error workflow sends n8n's error message, which the Failed run email shows on its Failure line. In our test, a 500 from the model came through as "The service was not able to process your request", and a 429 as "The service is receiving too many requests from you".
Should the AI Agent node stop or continue on error?
Either works. If it stops (n8n's default), the error workflow reports a Failed run. If it's set to Continue, the run carries on with no answer and the finish ping raises Empty output.
Why JSON.stringify instead of a JSON body with {{ $json.output }} in it?
Model answers contain quotes and line breaks. In our test, that body broke on a normal answer with "The value in the JSON Body field is not valid JSON", and with On Error: Continue on the node, nothing was sent at all.
Does Stallbell check whether the answer is any good?
No. It checks that the answer isn't empty or whitespace and, if you set one, that it contains a phrase or is valid JSON. It looks at the first 2 KB.