cd /news/ai-agents/limit-n8n-ai-workflow-alerts-to-thre… · home › topics › ai-agents › article
[ARTICLE · art-168152] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Limit n8n AI workflow alerts to three fields

A developer published a technique for limiting n8n AI workflow failure alerts to three fields—workflow label, failure phase, and execution ID—so that request and response details in error payloads don't leak into Slack or email. The approach uses an Error Trigger feeding a Code node that maps workflow IDs to approved labels and validates the execution ID before building the outgoing message, with a staging Webhook → Stop And Error workflow to test delivery. The JavaScript was checked with synthetic inputs, but delivery through a live n8n workflow remains untested.

by read2 min views1 publishedNov 12, 2026

An AI workflow failure can leave request or response details in its error payload. For an alert sent to Slack or email, a workflow label, a failure phase, and an execution ID are enough to start the investigation.

Save an error workflow with Error Trigger → Code → Slack or Email. In the AI workflow’s settings, select it under Error workflow. You can assign one error workflow to multiple workflows. n8n error workflow setup

Set the Code node to JavaScript and Run Once for All Items. Replace the synthetic workflow ID 42 and label support-triage with values you’ve approved for the alert destination. n8n Code node

const event = $input.first().json;
const workflowLabels = new Map([["42", "support-triage"]]);
const workflow = workflowLabels.get(String(event.workflow?.id ?? "")) ?? "unmapped";
const phase = event.trigger ? "trigger" : event.execution ? "execution" : "unknown";
const alert = { workflow, phase };

const rawId = event.execution?.id;
const id = typeof rawId === "string" ? rawId : Number.isSafeInteger(rawId) ? String(rawId) : "";
if (/^[0-9]{1,20}$/.test(id)) {
  alert.executionId = id;
}

return [{ json: alert }];

Build the outgoing message using only workflow, phase, and executionId when present. A saved failure could produce support-triage · execution · 231. A failure in the trigger could produce support-triage · trigger. An unsaved execution can also lack an ID, so use the event’s trigger and execution fields to distinguish the two. n8n Error Trigger payload

In staging, use an authenticated Webhook → Stop And Error workflow with the synthetic message ALERT_TEST_ONLY. Assign the error workflow and set the alert destination to a test channel. Publish the staging workflow, call the webhook’s Production URL once, then unpublish it. Error Trigger runs on automatic failures, so Execute workflow in the editor won’t exercise it. Webhook URL behavior

Verify that the alert arrives with the expected label and phase. Check that the error message, stack, and execution URL are absent. Review who can access execution data and how long it’s retained separately from the alert.

The JavaScript was checked with synthetic inputs. Delivery through a live n8n workflow is untested.

── more in #ai-agents 4 stories · sorted by recency
── more on @n8n 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/limit-n8n-ai-workflo…] indexed:0 read:2min 2026-11-12 · —