Skip to main content

Scan incoming Gmail attachments for threats with VirusTotal and GPT-4o-mini

Workflow preview

Workflow preview
100%
Scan incoming Gmail attachments for threats with VirusTotal and GPT-4o-mini preview
Open on n8n.io

1. Workflow Overview

Who's it for Small teams, solo operators, and security conscious individuals who receive email attachments from external senders. Useful for freelancers, agencies, HR teams, and anyone handling CVs...

Best for

  • SecOps automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.gmailtrigger, n8n-nodes-base.set, n8n-nodes-base.code, n8n-nodes-base.httprequest, @n8n/n8n-nodes-langchain.openai, n8n-nodes-base.switch, n8n-nodes-base.gmail

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Ayaka Sato.

Original n8n.io source

1.1 Workflow description

Title
Scan incoming Gmail attachments for threats with VirusTotal and GPT-4o-mini
Workflow name
Scan incoming Gmail attachments for threats with VirusTotal and GPT-4o-mini

Who's it for

Small teams, solo operators, and security-conscious individuals who receive email attachments from external senders. Useful for freelancers, agencies, HR teams, and anyone handling CVs, invoices, or documents from unknown sources.

How it works

Every minute, the workflow polls Gmail for new unread emails with attachments. For each attachment, it calculates the SHA256 hash and queries VirusTotal for known-malware matches. In parallel, an AI model analyzes the email subject and body for phishing patterns. A rule-based scorer combines both signals into three threat levels: Danger (VirusTotal malicious count >= 3 OR AI detects phishing) triggers a Gmail quarantine label plus a Slack alert. Suspicious (partial hits) logs to a human review queue in Google Sheets. Safe saves the attachment to Google Drive. AI is used only for text classification — the final quarantine decision is always rule-based.

Set up steps

  1. Get a free VirusTotal API key at virustotal.com
  2. Create a Google Sheet named suspicious_queue with columns: timestamp, email_from, email_subject, attachment, malicious_count, ai_verdict
  3. Create a Gmail label called QUARANTINE and a Google Drive folder for safe attachments
  4. Open Set Configuration and fill in the Sheet ID, Drive folder ID, Slack channel, and label name
  5. Connect Gmail, Sheets, Drive, Slack, OpenAI, and VirusTotal (Header Auth with x-apikey) credentials
  6. Activate the workflow

How to customize

Adjust thresholds in the Code node, swap Slack for Discord or Teams, or add SPF and DKIM header checks before scanning.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - README

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Section 1 Trigger & Configure

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Section 2 Scan

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Section 3 Score & Route

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Section 4A Danger

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Section 4B Suspicious

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Section 4C Safe

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Poll Gmail for New Attachments

Type / Role
n8n-nodes-base.gmailTrigger - gmailTrigger
Config choices
Version 1.2

Block 9 - Set Configuration

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 10 - Extract Attachments from Email

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 11 - Compute SHA256 Hash of Attachment

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - Look Up Hash in VirusTotal

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 13 - Classify Phishing Risk with OpenAI

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 1.8

Block 14 - Calculate Combined Risk Level

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - Route by Threat Level

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 16 - Apply Quarantine Label on Gmail

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 17 - Send Security Alert to Slack

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.2

Block 18 - Log to Review Queue on Google Sheets

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.5

Block 19 - Save Attachment to Safe Drive Folder

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 20 - Wait 15s for VirusTotal Rate Limit

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

3. Summary Table

Workflow Scan incoming Gmail attachments for threats with VirusTotal and GPT-4o-mini
Complexity advanced
Nodes 20
Categories SecOps, AI Summarization
Author Ayaka Sato
Published 22 Apr 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/15207/15207.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Scan incoming Gmail attachments for threats with VirusTotal and GPT-4o-mini do?

Who's it for Small teams, solo operators, and security conscious individuals who receive email attachments from external senders. Useful for freelancers, agencies, HR teams, and anyone handling CVs...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your SecOps, AI Summarization use case.