Automate Email Phishing Detection with n8n and AI

This n8n workflow automatically analyzes incoming emails for phishing threats using Gmail, AI-powered ChatGPT evaluation, and Jira ticket creation, helping security teams save hours on manual email threat assessments.
gmailTrigger
httpRequest
openAi
+7
Workflow Identifier: 1353
NODES in Use: Gmail Trigger, Microsoft Outlook Trigger, HTTP Request, Set, Code, OpenAI, If, Jira, Convert To File, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Workflow Does

This workflow watches new emails in Gmail every minute.
It finds parts of each email like subject, recipient, body, and headers.
It makes a picture of the email using hcti.io API.
Then, it asks ChatGPT to check if the email might be phishing.
Based on ChatGPT’s answer, it creates a ticket in Jira.
The Jira ticket gets the email picture and text file attached.
This saves time and helps spot phishing emails faster.


Who Should Use This Workflow

This workflow is good for security teams that get many suspicious emails daily.
It helps people who want to stop phishing attacks without checking each email by hand.
It suits teams using Gmail, ChatGPT (OpenAI), hcti.io, and Jira.
Users who want quick, automatic email threat checks will benefit most.


Tools and Services Used

  • Gmail: To watch for new incoming emails every minute.
  • hcti.io API: To turn the HTML email body into a screenshot image.
  • OpenAI ChatGPT (GPT-4o): To analyze email content and headers for phishing risks.
  • Jira Software Cloud: To create and track tickets about suspicious or safe emails.
  • n8n workflow platform: To connect and run all these steps automatically.

How the Workflow Works: Inputs, Processing, and Outputs

Inputs

  • New emails from Gmail inbox.
  • Email HTML body, text body, headers, subject, and recipient
  • API keys and credentials for Gmail, hcti.io, OpenAI, and Jira.

Processing Steps

  • Gmail Trigger checks for new emails every minute.
  • Extract email parts using a Set node for HTML, headers, subject, recipient, and text.
  • Send the HTML body to hcti.io API to create an image of the email.
  • Fetch the screenshot image from hcti.io using another HTTP request.
  • Prepare consistent email variables in another Set node.
  • Convert the email text body into a .txt file.
  • Use ChatGPT with GPT-4o model to analyze email body and headers. It outputs JSON with a “malicious” boolean and explanation.
  • Check the ChatGPT result with an If node. Branch workflow based on if email is malicious or not.
  • Create a Jira ticket for potentially malicious or benign email.
  • Attach the email screenshot and the text email file to the Jira issue.

Outputs

  • Jira tickets with detailed phishing analysis.
  • Email screenshots and text files attached to Jira tickets.
  • Faster and more accurate phishing email detection and reporting.

Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Import the Workflow

  1. Download the workflow file using the Download button on this page.
  2. Open the n8n editor where your instance runs.
  3. Use the menu option Import from File to load the downloaded workflow.

Step 2: Add Credentials and Settings

  1. Add your Gmail OAuth2 credentials in the Gmail Trigger node.
  2. Enter your hcti.io API username and password in the HTTP Request nodes for screenshots.
  3. Set your OpenAI API key in the OpenAI (ChatGPT) node.
  4. Configure Jira API credentials and project keys in the Jira nodes.
  5. Update any email addresses, project IDs, or folder names if needed.

Step 3: Test the Workflow

  1. Send a test email to your monitored Gmail inbox.
  2. Run the workflow in manual mode or trigger it to check it runs and creates Jira tickets.

Step 4: Activate for Production

  1. Enable the Gmail Trigger node to start automatic checking.
  2. Monitor the workflow executions in n8n to catch any errors.
  3. Consider [self-host n8n](https://buldrr.com/hosting/) to run this workflow on a server for better control and uptime.

Common Issues and Troubleshooting

  • “401 Unauthorized” errors from hcti.io mean the API username or password is wrong.
    Double-check credentials in HTTP Request nodes.
  • ChatGPT node not returning results or failing may mean prompt variables are incorrect or JSON output is not enabled.
    Review prompt content and node settings.
  • Jira ticket creation errors usually come from wrong project keys or missing API permissions.
    Check Jira credentials and permissions for creating issues.
  • Missing email parts or broken node flows often happen if variables are not mapped correctly between nodes.
    Verify all email data fields exist where used.

Customization Ideas

  • Enable Microsoft Outlook support by activating disabled Outlook Trigger and related nodes.
  • Change ChatGPT prompt to look for other threats like ransomware or business email compromise.
  • Set Jira project keys and issue types to match your team’s preferences.
  • Rename screenshot attachments or change file types (like .jpeg) in code nodes.
  • Adjust email polling frequency in Gmail or Outlook triggers to fit email volume.

Result and Benefits

✓ Saves hours by automating phishing email reviews.
✓ Detects phishing quickly using AI analysis.
✓ Creates clear Jira tickets with screenshots and email text.
✓ Helps security teams prioritize threats faster.
✓ Reduces human errors in email threat detection.

Frequently Asked Questions

Yes, the workflow supports Outlook emails if the Outlook Trigger and related nodes are enabled and set up with proper credentials.
Yes, every analyzed email consumes OpenAI API credits according to usage.
Jira ticket failures often come from incorrect project keys or insufficient API user permissions.
Email data is handled securely via authenticated API connections inside n8n, but users should follow their organization’s security policies.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free