Contents

Forward Important Emails to Slack Automatically

Important emails often get lost in crowded inboxes. By forwarding critical messages to Slack, you ensure your team sees them immediately. This tutorial shows you how to set up smart email-to-Slack forwarding with n8n.

Download the Workflow
Get the ready-to-use workflow from our n8n Workflow Gallery.
  • An n8n instance
  • Email account with IMAP access (Gmail, Outlook, etc.)
  • Slack workspace with incoming webhooks
Email Trigger (IMAP) → Filter Important → Format Message → Post to Slack
  1. Add an Email Read IMAP node
  2. Configure your email credentials:
    • Host: imap.gmail.com (for Gmail)
    • Port: 993
    • User: Your email
    • Password: App-specific password
  3. Set polling interval (e.g., every minute)
  4. Mailbox: INBOX

Add a Filter node to only forward relevant emails:

Conditions (match ANY):

// From important domains
$json.from.includes('@important-client.com')

// Contains urgent keywords
$json.subject.toLowerCase().includes('urgent')

// From VIP senders
['ceo@company.com', 'support@vendor.com'].includes($json.from)

Example filter configuration:

  • from contains @important-domain.com OR
  • subject contains URGENT OR
  • subject contains ACTION REQUIRED

Add a Set node to prepare the message:

// Truncate long email bodies
const maxLength = 500;
let body = $json.text || $json.html || 'No content';
if (body.length > maxLength) {
  body = body.substring(0, maxLength) + '...';
}

// Clean HTML if present
body = body.replace(/<[^>]*>/g, '');

return {
  from: $json.from,
  subject: $json.subject,
  preview: body,
  date: $json.date
};

Step 4: Post to Slack

Add a Slack node:

Channel: #important-emails

Message:

📧 *New Important Email*

*From:* {{ $json.from }}
*Subject:* {{ $json.subject }}
*Received:* {{ $json.date }}

>>> {{ $json.preview }}

Or use Block Kit for richer formatting:

{
  "blocks": [
    {
      "type": "header",
      "text": {
        "type": "plain_text",
        "text": "📧 New Important Email"
      }
    },
    {
      "type": "section",
      "fields": [
        {
          "type": "mrkdwn",
          "text": "*From:*\n{{ $json.from }}"
        },
        {
          "type": "mrkdwn",
          "text": "*Subject:*\n{{ $json.subject }}"
        }
      ]
    },
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "{{ $json.preview }}"
      }
    }
  ]
}
const importantDomains = [
  'client1.com',
  'client2.com',
  'partner.com'
];

const senderDomain = $json.from.split('@')[1];
return importantDomains.includes(senderDomain);
const urgentKeywords = ['urgent', 'asap', 'critical', 'emergency', 'action required'];
const subject = $json.subject.toLowerCase();
return urgentKeywords.some(keyword => subject.includes(keyword));
const excludePatterns = [
  'unsubscribe',
  'newsletter',
  'marketing',
  'noreply'
];

const content = ($json.subject + ' ' + $json.from).toLowerCase();
return !excludePatterns.some(pattern => content.includes(pattern));

Send emails to different channels based on content:

const subject = $json.subject.toLowerCase();

if (subject.includes('support') || subject.includes('ticket')) {
  return '#support';
} else if (subject.includes('sales') || subject.includes('deal')) {
  return '#sales';
} else if (subject.includes('invoice') || subject.includes('payment')) {
  return '#finance';
} else {
  return '#general-emails';
}

Notify about attachments without forwarding them:

const hasAttachments = $json.attachments && $json.attachments.length > 0;
const attachmentInfo = hasAttachments
  ? `\n📎 *Attachments:* ${$json.attachments.length} file(s)`
  : '';

return {
  ...$json,
  attachmentInfo: attachmentInfo
};
  1. Go to Google Account → Security
  2. Enable 2-Step Verification
  3. Go to App Passwords
  4. Generate password for “Mail”
  5. Use this password in n8n

Filter by Gmail label instead of scanning all emails:

Mailbox: [Gmail]/Important
  • Verify IMAP is enabled in email settings
  • Check host and port are correct
  • Use app-specific password for Gmail
  • Check spam/junk folder
  • Verify filter conditions aren’t too strict
  • Check polling interval
  • Add a seen/processed check
  • Use email Message-ID for deduplication
  1. Start with strict filters - Expand gradually to avoid noise
  2. Use a dedicated channel - Don’t spam general channels
  3. Include original link - Let users read full email in client
  4. Handle errors gracefully - Don’t crash on malformed emails
  5. Monitor the workflow - Ensure it’s running reliably

Email-to-Slack forwarding ensures critical messages get immediate attention. With n8n’s flexible filtering, you can fine-tune exactly which emails get forwarded and to which channels.

Download the complete workflow from our n8n Workflow Gallery.