Log errors and avoid sending too many emails
Configured with Email Send, Error Trigger, Execute Workflow, Execute Workflow Trigger, and additional nodes. Review the connections and setup before adapting this template.
Node categories in this workflow
- Trigger
- Data store
- Messaging
- Subworkflow
- Routing
- Code
Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.
Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.
How it works
The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.
| Node | Category | Type | Operation |
|---|---|---|---|
| Error Trigger | Trigger | Error Trigger | See node parameters |
| Insert Log | Data store | Postgres | See node parameters |
| Count for 5 minutes | Data store | Postgres | executeQuery |
| Principal E-Mail | Messaging | Email Send | See node parameters |
| Fallback E-Mail | Messaging | Email Send | See node parameters |
| Push mobile notification | Messaging | Pushover | See node parameters |
| Truncate Log Database | Data store | Postgres | deleteTable |
| Sometimes... just cleanup | Trigger | Manual Trigger | See node parameters |
| Call this Sample - Prepend to your error catcher | Subworkflow | Execute Workflow | See node parameters |
| See below to prepend this at your error handling | Trigger | Execute Workflow Trigger | See node parameters |
| If there is no logs in 5 minutes | Routing | If | See node parameters |
| CleanUp execution. See below if you will prepend this workflow | Code | Code | See node parameters |
| Insert your error handling logic after this | Routing | No Op | See node parameters |
Setup
- Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
- Connect your own credentials through n8n’s credential store. Replace
REPLACE_WITH_*values with your resource identifiers. - Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
- Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.
Requirements
An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.
Credential types declared in the source
postgrespushoverApismtp
Workflow notes
Log errors and avoid sending too many emails
Log errors and avoid sending too many emails
Use case
Most of the time, it’s necessary to log all errors that occur. However, in some cases, a scheduled task or service consuming excessive resources might trigger a surge of errors.
To address this, we can log all errors but limit alerts to a maximum of one notification every 5 minutes.
What this workflow does
This workflow can be configured to receive error events, or you can integrate it before your own error-handling logic.
If used as the primary error handler, note that this flow will only add a database log entry and take no further action. You’ll need to add your own alerts (e.g., email or push notifications). Below is an example of a notification setup I prefer to use.
At the end, there’s an error cleanup option. This feature is particularly useful in development environments.
If you already have an error-handling workflow, you can call this one as a sub-workflow. Its final steps include cleanup logic to reset the execution state and terminate the workflow.
Setup
Verify all Postgres nodes and credentials when using the 'Error Handling Sample'
How to adjust it to your needs
-
You can set this workflow as a sub-workflow within your existing error-handling setup.
-
Alternatively, you can add the "Error Handling Sample" at the end of this workflow, which sends email and push notifications.
Configuration Requirements:
⚠️ You must create a database table for this to work!
DDL of this sample:
create table p1gq6ljdsam3x1m."N8Err" ( id serial primary key, created_at timestamp, updated_at timestamp, created_by varchar, updated_by varchar, nc_order numeric, title text, "URL" text, "Stack" text, json json, "Message" text, "LastNode" text );
alter table p1gq6ljdsam3x1m."N8Err" owner to postgres;
create index "N8Err_order_idx" on p1gq6ljdsam3x1m."N8Err" (nc_order);
by Davi Saranszky Mesquita https://www.linkedin.com/in/mesquitadavi/
Log errors and avoid sending too many emails
Log errors and avoid sending too many emails
Purpose and structure
This folder contains the Log errors and avoid sending too many emails workflow. Its executable nodes use code, emailSend, errorTrigger, executeWorkflow, executeWorkflowTrigger, if, manualTrigger, noOp, postgres, pushover. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.
Setup
Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.
Entry points
Error Trigger, Sometimes... just cleanup, See below to prepend this at your error handling
Verification
Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.
Attribution
https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Error/1777_Error_Postgres_Send_Triggered.json MIT; preserve source notices.
Canvas section labels
These name areas of the original canvas; they do not include explanatory instructions.
- Error handling sample
- Database Cleanup: Useful in DEV, but DO NOT run in production