Skip to main content

Email Trigger (E-Mail Inbox Watcher)

The Email Trigger monitors email mailboxes for new messages and automatically starts workflows when new emails are received.

What does this integration do?

The Email Trigger establishes a connection to an IMAP email server and continuously monitors a specific mailbox for new, unread emails. As soon as a new email arrives, it automatically starts a workflow with the email content and metadata.

Typical Use Cases:

  • Customer Support Automation: Automatic classification and routing of support requests
  • Application Processing: Automatic processing of incoming applications
  • Order Processing: Processing orders via email
  • Document Processing: Automatic processing of email attachments
  • Newsletter Management: Processing subscriptions/unsubscriptions
  • Alert Processing: Automatic reaction to system notifications via email

User Configuration

Email Server Connection

Mail Server

  • Purpose: Address of the IMAP email server
  • Format: Domain or IP address
  • Examples: imap.gmail.com, mail.company.com, outlook.office365.com

Port

  • Purpose: Port of the IMAP server
  • Standard Ports:
    • 993 (IMAP over SSL/TLS)
    • 143 (IMAP unencrypted)
  • Recommended: 993 for secure connections

Username

  • Purpose: Email address or username for login
  • Security: Stored encrypted
  • Examples: support@company.com, workflow@example.com

Password

  • Purpose: Password for the email account
  • Security: Stored encrypted
  • Note: Gmail/Outlook may require app-specific passwords

Protocol

  • Purpose: Email protocol for connection
  • Supported: Only IMAP
  • Default: IMAP

Mailbox Configuration

Email Folder

  • Purpose: Folder in the mailbox to monitor
  • Default: INBOX
  • Examples:
    • INBOX (Inbox)
    • Support (Support folder)
    • Applications (Applications folder)

Move after Processing to (Optional)

  • Purpose: Target folder for processed emails
  • Leave empty: Emails remain in original folder
  • Examples: Processed, Archive, Completed

After Processing

  • Purpose: Action performed with emails after processing
  • Options:
    • none - No action (default)
    • read - Mark as read
    • delete - Delete email

Data Output

Result (Email) - Variable for Complete Email

  • Purpose: Variable that stores the complete email object
  • Content: Full email with all metadata
  • Example Variable: incomingEmail

Sender Name - Variable for Sender Name (Optional)

  • Purpose: Variable for the extracted sender name
  • Example Variable: senderName
  • Example Content: John Doe

Sender Email - Variable for Sender Email (Optional)

  • Purpose: Variable for the sender's email address
  • Example Variable: senderEmail
  • Example Content: john.doe@example.com

To Recipients - Variable for Recipients (Optional)

  • Purpose: Variable for the TO recipients of the email
  • Example Variable: toRecipients

CC Recipients - Variable for CC Recipients (Optional)

  • Purpose: Variable for the CC recipients of the email
  • Example Variable: ccRecipients

Email Subject - Variable for Subject (Optional)

  • Purpose: Variable for the email subject
  • Example Variable: emailSubject
  • Example Content: Support Request: Login Problem

Workflow Integration

Data Format

Complete Email (Result Variable):

{
"from": "John Doe <john@example.com>",
"to": "support@company.com",
"cc": ["manager@company.com"],
"subject": "Support Request: Login Problem",
"date": "Fri, 15 Mar 2024 10:30:00 +0100",
"content": "Hello,\n\nI'm having trouble logging in...\n\nBest regards\nJohn Doe"
}

Individual Data Fields:

  • senderName: John Doe
  • senderEmail: john@example.com
  • toRecipients: support@company.com
  • ccRecipients: manager@company.com
  • emailSubject: Support Request: Login Problem

Usage in Subsequent Steps

Process Email Content:

Variable: incomingEmail

In LLM Action:
"Analyze the following email and categorize the request: {{incomingEmail.content}}"

In Script Action:
const email = memory.load('incomingEmail');
const isUrgent = email.subject.includes('URGENT');

Create Responses:

Variables: senderEmail, emailSubject

In Email Action:
To: {{senderEmail}}
Subject: Re: {{emailSubject}}
Body: "Thank you for your inquiry..."

Practical Examples

Support Ticket System

Configuration:

  • Mail Server: imap.company.com
  • Port: 993
  • Username: support@company.com
  • Password: [secure_password]
  • Email Folder: INBOX
  • Move after Processing to: Processed
  • After Processing: read
  • Result: supportEmail
  • Sender Email: customerEmail
  • Email Subject: ticketSubject

Usage: Automatic ticket creation, priority assessment, initial response

Application Processing

Configuration:

  • Mail Server: mail.hr-company.com
  • Port: 993
  • Username: applications@company.com
  • Email Folder: Applications
  • Move after Processing to: In_Progress
  • Result: applicationEmail
  • Sender Name: applicantName
  • Sender Email: applicantEmail

Usage: CV extraction, applicant database update, acknowledgment

Email Order Processing

Configuration:

  • Mail Server: imap.gmail.com
  • Port: 993
  • Username: orders@shop.com
  • Email Folder: INBOX
  • After Processing: delete
  • Result: orderEmail
  • Email Subject: orderSubject

Usage: Order extraction, inventory check, order confirmation

Technical Details

Schema Configuration

configSchema: {
server: {
name: 'Mail Server',
description: 'The mail server address',
schema: z.string(),
},
port: {
name: 'Port',
description: 'The port number',
schema: z.number(),
},
username: {
name: 'Username',
description: 'The username for the mail server',
schema: z.string(),
reference: 'secured',
},
password: {
name: 'Password',
description: 'The password for the mail server',
schema: z.string(),
reference: 'secured',
},
protocol: {
name: 'Protocol',
description: 'The protocol to use (IMAP)',
schema: z.enum(['IMAP']),
},
mailFolder: {
name: 'Email Folder',
description: 'Folder to monitor (INBOX, Sent, etc.)',
schema: z.string().default('INBOX'),
},
moveAfterProcessingTo: {
name: 'Move after Processing to',
description: 'Folder to move emails to after processing (leave empty to keep in current folder)',
schema: z.string().optional(),
},
afterProcessing: {
name: 'After Processing',
description: 'What to do with emails after processing',
schema: z.enum(['none', 'read', 'delete']).default('none'),
},
outputName: {
name: 'Result (Email)',
reference: 'memory-out',
schema: z.string(),
},
senderName: {
name: 'Sender Name',
description: 'Memory key to store sender name',
reference: 'memory-out',
schema: z.string().optional(),
},
senderEmail: {
name: 'Sender Email',
description: 'Memory key to store sender email address',
reference: 'memory-out',
schema: z.string().optional(),
},
toRecipients: {
name: 'To Recipients',
description: 'Memory key to store TO recipients',
reference: 'memory-out',
schema: z.string().optional(),
},
ccRecipients: {
name: 'CC Recipients',
description: 'Memory key to store CC recipients',
reference: 'memory-out',
schema: z.string().optional(),
},
subject: {
name: 'Email Subject',
description: 'Memory key to store email subject',
reference: 'memory-out',
schema: z.string().optional(),
},
}

Internal Implementation

IMAP Connection:

  • Uses imap-simple library for robust IMAP communication
  • Automatic TLS encryption for secure connections
  • Event-based monitoring of new emails

Email Processing:

  • Searches for unread emails (UNSEEN flag)
  • Extracts headers and text content
  • Parsing of sender information (name and email separated)

Post-Processing:

  • Flexible options for email handling after processing
  • Folder management for organized storage
  • Error handling for post-processing actions

Best Practices

Security

Account Management:

  • Use dedicated email accounts for automation
  • Implement app-specific passwords for Gmail/Outlook
  • Regular rotation of credentials

Connection Security:

  • Always use encrypted connections (port 993)
  • Validate SSL certificates of mail servers
  • Monitor connection anomalies

Performance

Folder Management:

  • Use specific folders instead of INBOX for high volumes
  • Implement archiving strategies
  • Avoid accumulation of large email quantities

Processing:

  • Use Move after Processing for better organization
  • Implement error handling in subsequent steps
  • Limit email sizes through server configuration

Workflow Design

Robustness:

  • Implement validation for email contents
  • Handle different email formats (HTML, text)
  • Consider spam and invalid emails

Scaling:

  • Use separate triggers for different email types
  • Implement priority systems based on senders
  • Monitor email processing times

The Email Trigger enables seamless integration of email communication into automated workflows and provides flexible, secure processing of incoming messages.