🎫 Route and categorize Gmail emails to Slack with Llama 3 via OpenRouter

⚡ 103 views · 🎫 Ticket Management & Triage

Description

Quick overview

This n8n template provides a complete and automated solution to transform your team’s inbox management.

It acts as an intelligent agent that reads incoming Gmail messages, uses AI to determine their category, and automatically routes them to the correct Slack channel—even creating new channels on the fly for new topics.

How it works

  1. Monitor New Emails:
  2. The workflow continuously checks a specified Gmail account for new, unread emails. It automatically filters out spam, drafts, and duplicates.
  3. AI Categorization:
  4. Each new email’s subject and body are sent to an AI model (like Llama 3 via OpenRouter). The AI analyzes the content and assigns a category based on a predefined list (e.g., sales, marketing, accounts, internal).
  5. Find or Create Slack Channel:
  6. The workflow then checks your Slack workspace to see if a channel corresponding to the AI’s category already exists (e.g., #sales).
  7. Route the Email:
  8. If the channel exists: The workflow posts a formatted summary of the email, a link to the original message in Gmail, and a “Reply” button directly into the existing channel.
  9. If the channel does NOT exist: The workflow automatically creates a new public channel (e.g., #new-category), invites a designated user, and then posts the email summary.

Setup

  1. Gmail Configuration: In the “Capture Gmail Event” (Gmail Trigger) node, connect your Gmail account using OAuth2 credentials.
  2. OpenRouter AI Configuration: In the “OpenRouter Chat Model” node, create a new credential and add your OpenRouter API key.
  3. Slack Configuration: Create a Slack App: Go to api.slack.com/apps, create a new app, and install it to your workspace.
  4. Set Permissions: In your app’s “OAuth & Permissions” settings, add the following Bot
  5. Token Scopes: channels:read, channels:manage, chat:write, groups:write, users:read. Reinstall the app to your workspace after adding them.
  6. Get Bot Token: Copy the “Bot User OAuth Token” (it starts with xoxb-).
  7. Connect in n8n: In all Slack nodes in the workflow, create a new credential and paste this Bot Token.
  8. Set User to Invite: In the “Invite a user to a channel” node, replace the placeholder User ID (U0A6ULM7CGK) with the Slack Member ID of the user you want to be automatically invited to new channels.
  9. Save the workflow and toggle the “Active” switch to ON. Your intelligent email routing system is now live!

Requirements

Additional info

Connect with us: Website: https://www.intuz.com/n8n-workflow-automation-templates/ Email: getstarted@intuz.com LinkedIn: https://www.linkedin.com/company/intuz

For Custom Workflow Automation

Get Started: https://n8n.partnerlinks.io/intuz

đź”— Nodes Used

Slack, Gmail Trigger, AI Agent, Structured Output Parser, OpenRouter Chat Model

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup