⬡ Hub
Skip to content

2_email_triage

2. Intelligent Email Triage and Response

Description

This workflow monitors an email inbox, uses a Large Language Model (LLM) to classify incoming emails, and then takes action based on the classification. It can categorize emails (e.g., "Sales Lead," "Support Request"), and for certain categories, draft and send an automated reply.

Architecture

graph TD
    A[Email Trigger] --> B{AI Agent LLM};
    B --> C{Switch};
    C -- Sales Lead --> D[Create CRM Lead];
    C -- Support Request --> E[Send Auto-Reply];
    C -- Other --> F[Mark as Read];

Setup

  1. Import Workflow: Import the workflow.json file into your n8n instance.
  2. Configure Email Trigger:
    • In the "New Email Trigger" node, create or select your IMAP/OAuth2 email credentials.
    • Specify the "Folder" you want to monitor (e.g., INBOX).
  3. Configure LLM:
    • In the "Classify Email" node, replace the placeholder URL with the API endpoint of your chosen LLM.
    • Configure the authentication with your LLM API key, similar to the previous project.
    • Adjust the prompt in the JSON body to define your desired categories.
  4. Configure Switch:
    • Review the paths in the "Route by Category" switch node. Ensure the Value in each path matches the output you defined in the LLM prompt.
  5. Configure Actions:
    • Sales Lead: In the "Create CRM Lead" node (example: HubSpot), create or select your CRM credentials and map the fields from the email.
    • Support Request: In the "Draft & Send Reply" branch, configure the "Send Email" node with your email credentials. The body of the email is pre-filled with the AI-generated draft.

Execution

  • This workflow can be triggered in two ways:
    1. Push: (Recommended) The email server sends a push notification to n8n. This is the most efficient method but requires more server configuration.
    2. Poll: n8n checks for new emails every few minutes. This is easier to set up.
  • Once activated, it will process every new email in the specified folder.

Files and Subdirectories