Log workflow failures with Google Gemini, Google Sheets, and Gmail alerts

Go to Workflow
4 views
Built by Swapnil Mandloi Swapnil Mandloi
Created on July 24, 2026

Description

Quick overview
This error workflow captures n8n workflow failures, classifies them, generates a short Google Gemini diagnosis, logs each incident to Google Sheets, and emails an on-call address via Gmail only for critical errors.

How it works
Triggers when a linked n8n workflow fails in a production execution.
Extracts failure details and classifies the error message into a category and severity (for example authentication, rate limit, transient network, data shape, or configuration).
Sends the workflow context and raw error to Google Gemini to produce a plain-English, three-sentence diagnosis.
Combines the classification and AI diagnosis into a single incident record.
Appends the incident record as a new row in Google Sheets.
Sends a formatted Gmail alert to the on-call address only when the incident severity is marked as Critical.

Setup
Add a Google Gemini (PaLM) API credential and select it for the chat model used to generate the diagnosis.
Add a Google Sheets OAuth2 credential and select the target spreadsheet and sheet tab, ensuring the columns exist for failed_at, workflow_name, workflow_id, execution_id, execution_url, failed_node, error_message, error_type, severity, and ai_diagnosis.
Add a Gmail OAuth2 credential and replace [email protected] with your real on-call email recipient.
In each workflow you want monitored, set this workflow as its Error Workflow in the workflow settings so failures route here.

Nodes Used (5)

Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm
Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
Google Gemini Chat Model
@n8n/n8n-nodes-langchain.lmChatGoogleGemini
Google Sheets
n8n-nodes-base.googleSheets