Send daily ops digests and age-based anomaly alerts with OpenAI and Gmail

Go to Workflow
0 views
Built by Kuliberda Labs Kuliberda Labs
Created on August 12, 2026

Description

Quick overview
This workflow runs every morning to fetch sales, support, calendar, and finance operational metrics via HTTP endpoints, summarizes the deterministic status with OpenAI, emails a daily digest via Gmail, and sends a separate throttled Gmail alert when oldest-item age thresholds are breached.

How it works
Runs on a daily schedule at 08:30.
Requests operational data from four configured HTTP endpoints (sales, support, calendar, and finance) and continues even if a source fails.
Normalizes each source into consistent fields such as open count, oldest open item ID, and oldest age, marking the digest as degraded when a source is unavailable or malformed.
Aggregates the normalized results, detects age-threshold anomalies per source, and prepares a fact-only prompt for OpenAI to draft a short prose summary.
Validates the OpenAI output to ensure it is safe and contains no numbers, falling back to a fixed summary message when validation fails.
Builds and sends an HTML daily operations digest email via Gmail with the summary and per-source status table.
Filters anomalies against a once-per-day throttle key, sends an HTML anomaly alert email via Gmail when any unthrottled anomalies remain, and records the throttle keys after a successful send.

Setup
Provide four reachable endpoints and set the workflow variables OPS_SALES_URL, OPS_SUPPORT_URL, OPS_CALENDAR_URL, and OPS_FINANCE_URL.
Add an HTTP Header Auth credential for the HTTP Request nodes to authenticate to your ops endpoints.
Add an OpenAI credential for the OpenAI (LangChain) node and confirm the model selection fits your account.
Add a Gmail OAuth2 credential and replace [email protected] with your real recipients in both Gmail send steps.
Review and tune the per-source age thresholds and healthy-count limits in the normalization code to match your SLAs.

Nodes Used (4)

Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
HTTP Request
n8n-nodes-base.httpRequest
OpenAI
@n8n/n8n-nodes-langchain.openAi