AIAutomationPro Gestion avancée des erreurs et notification par e-mail v1
Ceci est unEngineering, DevOpsworkflow d'automatisation du domainecontenant 16 nœuds.Utilise principalement des nœuds comme If, N8n, Set, Code, Html. Système centralisé de gestion des erreurs n8n avec envoi automatique d'alertes par e-mail
- •Compte Google et informations d'identification Gmail API
Nœuds utilisés (16)
Catégorie
{
"id": "KhpM42Ckgy6qgzCz",
"meta": {
"instanceId": "b3df22d2875c82e3ba1883c50049ed9cee0bcabf99d2b486961d2245a09e3964",
"templateId": "2312",
"templateCredsSetupCompleted": true
},
"name": "AIAutomationPro Advanced Error Handling And Email Notifications v1",
"tags": [],
"nodes": [
{
"id": "7b9a99ba-2e76-4210-a2e5-cb5c9fd707a7",
"name": "Déclencheur d'erreur",
"type": "n8n-nodes-base.errorTrigger",
"position": [
460,
800
],
"parameters": {},
"typeVersion": 1
},
{
"id": "301a2f94-187c-4183-a0fc-5ec30480202a",
"name": "Note adhésive",
"type": "n8n-nodes-base.stickyNote",
"position": [
1080,
580
],
"parameters": {
"width": 783,
"height": 549,
"content": "## Send Error Handling Email"
},
"typeVersion": 1
},
{
"id": "f624fcc6-ea87-425c-b20c-b8c14d7f1226",
"name": "Déclencheur planifié",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
460,
300
],
"parameters": {
"rule": {
"interval": [
{}
]
}
},
"typeVersion": 1.2
},
{
"id": "dedfb0a6-a297-42c3-8a68-6aded7203373",
"name": "Note adhésive2",
"type": "n8n-nodes-base.stickyNote",
"position": [
660,
220
],
"parameters": {
"width": 1195,
"height": 260,
"content": "## Update Default Error Handler For All N8n Workflows"
},
"typeVersion": 1
},
{
"id": "2de34694-ccc8-451d-9bd7-9b438d5d045b",
"name": "N8n Get Gestionnaire d'erreurs",
"type": "n8n-nodes-base.n8n",
"position": [
760,
300
],
"parameters": {
"operation": "get",
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $workflow.id }}"
},
"requestOptions": {}
},
"credentials": {
"n8nApi": {
"id": "S63rln42rAvGFfBB",
"name": "n8n account"
}
},
"typeVersion": 1
},
{
"id": "c5ac588c-3972-4b32-9d40-dbb5a73cb170",
"name": "N8n Get All Workflows",
"type": "n8n-nodes-base.n8n",
"position": [
980,
300
],
"parameters": {
"filters": {},
"requestOptions": {}
},
"credentials": {
"n8nApi": {
"id": "S63rln42rAvGFfBB",
"name": "n8n account"
}
},
"typeVersion": 1
},
{
"id": "ad17b29e-18c9-4ac9-8b87-67c79ca2b0a4",
"name": "If No Default Error Handler Définir",
"type": "n8n-nodes-base.if",
"position": [
1200,
300
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "290fd302-4e2d-44d6-8a8a-14a0b8f2c360",
"operator": {
"type": "string",
"operation": "notExists",
"singleValue": true
},
"leftValue": "={{ $json.settings.errorWorkflow }}",
"rightValue": "=Default Error Handler"
},
{
"id": "2a5799e9-2030-4281-bf11-e7f9777906c5",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $json.id }}",
"rightValue": "={{ $('N8n Get Error Handler').first().json.id }}"
},
{
"id": "6059514d-9bef-4d21-a52e-eb967aea84f7",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.active }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2
},
{
"id": "19439590-b2a7-4884-9280-16955e1cf895",
"name": "N8n Update Workflow",
"type": "n8n-nodes-base.n8n",
"position": [
1640,
280
],
"parameters": {
"operation": "update",
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $json.id }}"
},
"requestOptions": {},
"workflowObject": "={{ JSON.stringify($json) }}"
},
"credentials": {
"n8nApi": {
"id": "S63rln42rAvGFfBB",
"name": "n8n account"
}
},
"typeVersion": 1
},
{
"id": "4c1bb8fe-8029-4cf1-9b96-c17d54145340",
"name": "Définir Data",
"type": "n8n-nodes-base.code",
"position": [
1420,
280
],
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const data = $json\n\ndata.settings.errorWorkflow = $('N8n Get Error Handler').item.json.id ;\ndelete data.settings.callerPolicy;\n\nreturn {\n id: data.id,\n name: data.name,\n nodes: data.nodes,\n connections: data.connections,\n settings: data.settings\n}"
},
"typeVersion": 2
},
{
"id": "4d8b7522-62ae-4738-9c48-285363399b0a",
"name": "Note adhésive3",
"type": "n8n-nodes-base.stickyNote",
"position": [
660,
720
],
"parameters": {
"width": 300,
"height": 260,
"content": "## Settings"
},
"typeVersion": 1
},
{
"id": "a6a452ec-5320-46b3-be99-cf6b3f562de2",
"name": "Définirtings",
"type": "n8n-nodes-base.set",
"position": [
760,
800
],
"parameters": {
"options": {
"dotNotation": true
},
"assignments": {
"assignments": [
{
"id": "53ac5417-db98-41e5-bc6d-acb6dd1fec42",
"name": "N8n Url",
"type": "string",
"value": "={{ $('Error Trigger').first().json.execution.url.split('executions')[0] }}"
},
{
"id": "0f85c65a-80bb-4977-90b9-1b4e741b5f70",
"name": "Email Receiver",
"type": "string",
"value": "your-email-here@gmail.com"
},
{
"id": "138c091f-7cd4-453a-9c75-5d193b617a39",
"name": "Email Sender Name",
"type": "string",
"value": "Error Handling System"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "a357bfaf-66d4-4b35-b4e8-8e4dbc255a68",
"name": "If Execution Error",
"type": "n8n-nodes-base.if",
"position": [
1200,
800
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a757d78d-799b-401b-8c01-3103fddfe757",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ Boolean($('Settings').first().json.execution) }}",
"rightValue": "={{ true }}"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "f72827ca-6775-45d1-923b-0ced413a7b25",
"name": "HTML For Execution Error",
"type": "n8n-nodes-base.html",
"position": [
1420,
680
],
"parameters": {
"html": "<h2>Execution Details</h2>\n<p>Please see execution details at <a href=\"{{ $('Settings').first().json.execution.url }}\">workflow execution url</a></p>\n<h3>DateTime</h3>\n<p>{{ DateTime.fromMillis($json.execution.error.timestamp) }}</p>\n<h3>Last Node Executed</h3>\n<p>{{ $json.execution.lastNodeExecuted }}</p>\n<h3>Mode</h3>\n<p>{{ $json.execution.mode }}</p>\n<h3>Message</h3>\n<p>{{ $json.execution.error.message }}</p>\n<h3>Stack trace</h3>\n<pre>\n{{ $json.execution.error.stack }}\n</pre>"
},
"typeVersion": 1.2,
"alwaysOutputData": true
},
{
"id": "c0dc9576-73f4-44f6-b82b-c056e40ec693",
"name": "HTML For Trigger Error",
"type": "n8n-nodes-base.html",
"position": [
1420,
920
],
"parameters": {
"html": "<h2>Trigger Failure Details</h2>\n<p>A trigger on main workflow has thrown an error.</p>\n<h3>DateTime</h3>\n<p>{{ DateTime.fromMillis($json.trigger.error.timestamp) }}</p>\n<h3>Mode</h3>\n<p>{{ $json.trigger.mode }}</p>\n<h3>Message</h3>\n<p>{{ $json.trigger.error.message }}</p>\n<h3>Name</h3>\n<p>{{ $json.trigger.error.name }}</p>\n<h3>Description</h3>\n<p>{{ $json.trigger.error.description }}</p>\n<h3>Context</h3>\n<pre>{{ JSON.stringify($json.trigger.error.context, null, 2) }}</pre>\n\n<h3>Cause</h3>\n<p>Message: {{ $json.trigger.error.cause.message }}</p>\n<p>Name: {{ $json.trigger.error.cause.name }}</p>\n<p>Code:{{ $json.trigger.error.cause.code }} </p>\n<p>Status: {{ $json.trigger.error.cause.status }}</p>\n<h3>Stack trace</h3>\n<pre>\n{{ $json.trigger.error.cause.stack }}\n</pre>"
},
"typeVersion": 1.2,
"alwaysOutputData": true
},
{
"id": "b497eb7b-a9b3-41f6-a71b-d614d20f2402",
"name": "Gmail Send Notification",
"type": "n8n-nodes-base.gmail",
"position": [
1640,
800
],
"webhookId": "d9c9328c-5be7-4ebe-a20a-c025e52cdf46",
"parameters": {
"sendTo": "={{ $('Settings').first().json['Email Receiver'] }}",
"message": "={{ $json.html }}\n",
"options": {
"senderName": "={{ $('Settings').first().json['Email Sender Name'] }}",
"appendAttribution": false
},
"subject": "=[N8N Alert] Issue Detected In Workflow ({{ $('Settings').first().json.workflow.name }}) - {{ Boolean($('Settings').first().json.execution) ? \"Execution Error\" : \"Trigger Failure\" }}: {{ $('Settings').first().json.execution.error.message || $('Settings').first().json.trigger.error.message }}"
},
"credentials": {
"gmailOAuth2": {
"id": "HOfMnLio66bOO80m",
"name": "Ai Auto Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "34b07331-bf9e-453e-89de-1c51fa094642",
"name": "Note adhésive1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-400,
140
],
"parameters": {
"width": 740,
"height": 3080,
"content": "## **Advanced n8n Error Handling: Automated Email Alerts & Global Error Workflow Configuration**\n\nIn any automated environment, n8n workflows, while powerful, can sometimes encounter unexpected issues or fail during execution. Without a dedicated error handling strategy, these failures might go unnoticed, leading to incomplete processes, data inconsistencies, or critical operational disruptions. Manually monitoring every workflow execution or sifting through logs for error details is inefficient and can significantly delay crucial fixes. This is where a centralized, automated error management system becomes essential to maintain reliability and quickly address any problems.\n\nThe \"**Advanced n8n Error Handling: Automated Email Alerts & Global Error Workflow Configuration**\" template provides a robust solution to proactively manage and respond to errors within your n8n instance. \n\nFor more powerful n8n templates, visit our website or contact us at [**AI Automation Pro**](https://aiautomationpro.org/). We help your business build custom AI workflow automation and apps.\n\n## Highlight features\n\n* **Automated Email Notifications:** Sends detailed HTML emails via Gmail for both execution and trigger failures, ensuring you're promptly informed. \n* **Centralized Error Management:** Acts as a single, dedicated workflow to catch and process errors from multiple other n8n workflows. \n* **Proactive Global Error Handler Configuration:** A scheduled task automatically scans and updates other active n8n workflows to use this workflow as their default error handler, ensuring consistent error management. \n* **Comprehensive Error Reporting:** Notification emails are rich with information, including error messages, stack traces, the last executed node, direct links to failed executions, and detailed trigger failure context. \n* **Dynamic Email Content:** The subject line and body of the notification email are dynamically adjusted based on whether the failure was an execution error or a trigger failure. \n* **Highly Customizable:** Offers flexibility to modify email content (HTML), change the notification channel (e.g., Slack, other email providers), and adjust the logic for updating other workflows' error handlers. \n* **Scheduled Operation:** The global configuration part runs on a user-definable schedule (e.g., daily, hourly) for proactive and automated error handling setup across your n8n instance.\n\n## Who is this for?\n\nThis workflow is designed for n8n users and administrators who want to:\n\n* Establish a resilient and centralized error handling mechanism across their n8n instance. \n* Receive immediate and detailed email notifications for any workflow failures. \n* Automate the process of assigning a default error handling workflow to all their active n8n workflows. \n* Save time on manually configuring error handlers for each individual workflow and ensure comprehensive error coverage.\n\n## What problem is this workflow solving? / use case\n\nIn an n8n environment with multiple workflows, errors can occur without immediate visibility. This can lead to:\n\n* Unnoticed failures, potentially causing data loss or incomplete automated processes. \n* Time-consuming diagnosis of issues due to a lack of readily available, detailed error information. \n* Inefficiency and oversight from manually setting an error workflow for every new or existing workflow.\n\nThis template tackles these issues by providing a proactive error management system. It not only alerts you to failures with comprehensive details but also ensures that your other workflows are automatically configured to use this centralized handler.\n\n## What this workflow does\n\nThis workflow operates in two distinct yet complementary parts:\n\n**1\\. Scheduled Global Error Handler Configuration:**\n\n* **Trigger:** Initiates based on a configurable schedule (e.g., daily, hourly). \n* **Identify Self:** Retrieves its own workflow ID to use as the designated error handler. \n* **Scan Workflows:** Fetches a list of all other workflows within your n8n instance. \n* **Conditional Update Logic:** For each active workflow found, it checks if: \n * An error workflow (`errorWorkflow` setting) is not currently set, OR \n * The currently set `errorWorkflow` is different from this central error handling workflow. \n * The workflow is active. \n* **Apply Default Handler:** If the above conditions are met, it automatically updates the target workflow's settings. This sets the current workflow as its default error handler, ensuring that any future errors in those workflows are routed here. The `callerPolicy` setting is also removed during this update.\n\n**2\\. Error Notification via Email:**\n\n* **Trigger:** Activates whenever an error occurs in any n8n workflow that has this workflow designated as its `errorWorkflow`. \n* **Gather Error Context:** Collects vital information about the failure, such as: \n * The base URL of your n8n instance. \n * Specific details of the workflow that failed (name, ID). \n * The nature of the error: whether it's an \"execution error\" (occurring mid-workflow) or a \"trigger failure\" (occurring at the start). \n* **Format Detailed Error Message:** Constructs a comprehensive HTML email tailored to the error type: \n * **For Execution Errors:** The email includes a direct link to the failed execution's page, the timestamp of the error, the name of the last node that successfully executed, the error message, and the full error stack trace. \n * **For Trigger Failures:** The email includes the timestamp, operational mode, error message, error name and description, relevant context data, details about the cause (message, name, code, status), and the stack trace. \n* **Send Email Notification:** Dispatches the formatted HTML email using Gmail to a predefined recipient. The email subject line dynamically indicates the name of the failing workflow and the type of error, providing a quick overview.\n\n## Setup\n\n1. **Import Workflow:** Import the JSON file into your n8n instance. \n2. **Configure Credentials:** \n * **n8n API Access:** \n * Locate the nodes: \"N8n Get Error Handler\", \"N8n Get All Workflows\", and \"N8n Update Workflow\". \n * For each, select or create new n8n API credentials. These credentials must have permissions to read all workflows (`workflows.read`) and update workflows (`workflows.update`). \n * **Gmail Access:** \n * Locate the \"Gmail Send Notification\" node. \n * Select or create new Gmail OAuth2 credentials to authorize n8n to send emails on your behalf. \n3. **Set Email Recipient and Sender Details:** \n * Navigate to the \"Settings\" node, which is connected directly after the \"Error Trigger\" node. \n * Modify the value for the `Email Receiver` variable to the email address where error notifications should be sent. \n * Optionally, update the `Email Sender Name` variable. \n4. **Configure Schedule (Optional):** \n * Select the \"Schedule Trigger\" node. \n * Adjust the \"Trigger Interval\" (e.g., Every Day, Every Hour) according to how frequently you want the workflow to scan and update the error handler settings for other workflows in your n8n instance. \n5. **Activate Workflow:** Ensure this workflow is toggled to \"Active\". Once active, its scheduled component will begin operating, and it will be ready to process and notify on errors from other linked workflows. \n6. **Manual Configuration (Optional):** While this workflow automates the assignment, you can also manually set this workflow as the `errorWorkflow` in the settings of any critical existing workflows for immediate protection.\n\n## How to customize this workflow to your needs\n\n* **Email Content & Formatting:** Modify the HTML content within the \"HTML For Execution Error\" and \"HTML For Trigger Error\" nodes to alter the appearance, structure, or information included in the notification emails. \n* **Alternative Notification Channels:** Replace the \"Gmail Send Notification\" node with a different email service node (e.g., Microsoft Outlook, SendGrid) or integrate other notification platforms like Slack, Microsoft Teams, or Discord. Remember to adjust the input data mappings for the new node. \n* **Refine Global Update Logic:** Adjust the conditions within the \"If No Default Error Handler Set\" node if you need more granular control over which workflows are automatically updated (e.g., filter by workflow tags, names, or explicitly exclude certain workflows). \n* **Enrich Error Data:** Insert additional nodes after the \"Error Trigger\" but before the \"Settings\" node if you need to fetch more context about the error or the workflow that failed (e.g., look up related information from a database or API). \n* **Advanced Notification Routing:** Implement more complex logic prior to sending notifications. For example, you could use a Switch node to route error alerts to different email addresses or channels based on the name of the failing workflow or the severity of the error. \n* **Handling of `callerPolicy`:** The \"Set Data\" node is configured to remove the `callerPolicy` setting from workflows it updates. If your workflows rely on this setting, you may need to modify or remove this part of the \"Set Data\" node's code. \n* **Adjust Scheduled Task:** Change the frequency or timing of the \"Schedule Trigger\" to better suit your operational needs for the global error handler update.\n"
},
"typeVersion": 1
}
],
"active": true,
"pinData": {
"Error Trigger": [
{
"json": {
"trigger": {
"mode": "trigger",
"error": {
"name": "NodeApiError",
"cause": {
"code": "ERR_BAD_RESPONSE",
"name": "AxiosError",
"stack": "AxiosError: Request failed with status code 503\n at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:19:12)\n at Unzip.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:599:11)\n at Unzip.emit (node:events:536:35)\n at endReadableNT (node:internal/streams/readable:1698:12)\n at processTicksAndRejections (node:internal/process/task_queues:82:21)\n at Axios.request (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/Axios.js:45:41)\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at invokeAxios (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/node-execution-context/utils/request-helper-functions.js:173:16)\n at proxyRequestToAxios (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/node-execution-context/utils/request-helper-functions.js:513:26)\n at Object.request (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/node-execution-context/utils/request-helper-functions.js:1145:50)\n at PollContext.requestOAuth2 (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/node-execution-context/utils/request-helper-functions.js:792:12)\n at PollContext.requestOAuth2 (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/node-execution-context/utils/request-helper-functions.js:1153:20)\n at PollContext.apiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/v2/transport/index.js:68:14)\n at GoogleSheet.spreadsheetGetSheet (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/v2/helpers/GoogleSheet.js:121:22)\n at PollContext.poll (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Sheet/GoogleSheetsTrigger.node.js:402:45)\n at TriggersAndPollers.runPoll (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/triggers-and-pollers.js:59:16)\n at executeTrigger (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/execution-engine/active-workflows.js:78:38)",
"status": 503,
"message": "503 - {\"error\":{\"code\":503,\"message\":\"The service is currently unavailable.\",\"status\":\"UNAVAILABLE\"}}"
},
"context": {},
"message": "Service unavailable - try again later or consider setting this node to retry automatically (in the node settings)",
"timestamp": 1748605421337,
"description": "The service is currently unavailable."
}
},
"workflow": {
"id": "dm2trOGY525Nr10K",
"name": "(Duc) WordPress Blog Automation Pro (Deep Research) v1"
}
}
}
]
},
"settings": {},
"versionId": "b0e4a2b2-8787-4b7d-b8fc-ccf1b36a0ddd",
"connections": {
"Set Data": {
"main": [
[
{
"node": "19439590-b2a7-4884-9280-16955e1cf895",
"type": "main",
"index": 0
}
]
]
},
"Settings": {
"main": [
[
{
"node": "a357bfaf-66d4-4b35-b4e8-8e4dbc255a68",
"type": "main",
"index": 0
}
]
]
},
"Error Trigger": {
"main": [
[
{
"node": "Settings",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "N8n Get Error Handler",
"type": "main",
"index": 0
}
]
]
},
"a357bfaf-66d4-4b35-b4e8-8e4dbc255a68": {
"main": [
[
{
"node": "f72827ca-6775-45d1-923b-0ced413a7b25",
"type": "main",
"index": 0
}
],
[
{
"node": "c0dc9576-73f4-44f6-b82b-c056e40ec693",
"type": "main",
"index": 0
}
]
]
},
"c5ac588c-3972-4b32-9d40-dbb5a73cb170": {
"main": [
[
{
"node": "If No Default Error Handler Set",
"type": "main",
"index": 0
}
]
]
},
"N8n Get Error Handler": {
"main": [
[
{
"node": "c5ac588c-3972-4b32-9d40-dbb5a73cb170",
"type": "main",
"index": 0
}
]
]
},
"c0dc9576-73f4-44f6-b82b-c056e40ec693": {
"main": [
[
{
"node": "b497eb7b-a9b3-41f6-a71b-d614d20f2402",
"type": "main",
"index": 0
}
]
]
},
"f72827ca-6775-45d1-923b-0ced413a7b25": {
"main": [
[
{
"node": "b497eb7b-a9b3-41f6-a71b-d614d20f2402",
"type": "main",
"index": 0
}
]
]
},
"If No Default Error Handler Set": {
"main": [
[
{
"node": "Set Data",
"type": "main",
"index": 0
}
]
]
}
}
}Comment utiliser ce workflow ?
Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.
Dans quelles scénarios ce workflow est-il adapté ?
Avancé - Ingénierie, DevOps
Est-ce payant ?
Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.
Workflows recommandés
Daniel Ng
@danielngA Growth Hacker, Digital Marketer & AI Automation Builder with 10+ years of experience in Digital Marketing & Workflow Automation. Based in Helsinki, Finland. For questions about my templates and customization, contact me at: daniel@aiautomationpro.org
Partager ce workflow