Notify on anomalous Google Drive access and send weekly email summaries

Go to Workflow
0 views
Built by Dele Tosh @ Protomated Dele Tosh @ Protomated
Created on September 04, 2026

Description

Quick Overview
This workflow monitors Google Workspace Drive audit logs on an hourly and weekly schedule, detecting bulk downloads, access bursts, and new access IPs, then emailing security alerts and a weekly activity digest while also logging both messages to a separate compliance/audit workflow.

How it works
Runs on two schedules: hourly for anomaly detection and weekly for a firm-wide access summary.
Pulls Google Drive activity from the Google Workspace Admin Reports API and normalizes each event (user, file name, matter reference pattern, timestamp, and IP address).
Filters the log to access-only events (view, download, and print) and aggregates counts per user.
Tracks each user’s known IP addresses over time and flags access from a newly observed IP after a baseline exists.
Checks each user’s activity against configured thresholds and a cooldown window to decide whether an alert is required.
For flagged users, generates a formatted alert email, logs the alert by calling a separate n8n compliance workflow, and sends the email via SMTP.
On the weekly schedule, aggregates the last 7 days into a top-users summary, logs it via the same compliance workflow, and emails the weekly digest.

Setup
Create Google Workspace Admin Reports API access and add a Google OAuth2/API credential with domain-wide delegation and the admin.reports.audit.readonly scope.
Configure an SMTP email credential and set the sender address in FIRM_FROM_EMAIL.
Set n8n variables for FIRM_EMAIL (and optionally SECURITY_ALERT_EMAIL) and the anomaly thresholds (LOOKBACK_HOURS, BULK_DOWNLOAD_THRESHOLD, ACCESS_BURST_THRESHOLD, ALERT_COOLDOWN_HOURS).
Update GUARDRAIL_WORKFLOW_ID to point to the n8n workflow that logs messages for compliance/audit purposes.
If needed, adjust the matter reference regex in the normalization code and the cron expressions for the hourly and weekly schedules.

Nodes Used (3)

Code
n8n-nodes-base.code
HTTP Request
n8n-nodes-base.httpRequest
Send Email
n8n-nodes-base.emailSend