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
Automate email phishing with n8n and Gmail

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

Learn how to Build this Workflow with AI:

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.

Automate email phishing with n8n and Gmail

Visit through Desktop to Interact with the Workflow.

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 Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.