Route and categorize Gmail emails to Slack with Llama 3 via OpenRouter
This n8n template from Intuz 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.
Who's this workflow for? Customer Support Teams Sales & Lead Management Teams Operations & Project Management Teams Any team that uses Slack as a central hub for communication and triaging tasks.
How it works
-
Monitor New Emails: The workflow continuously checks a specified Gmail account for new, unread emails. It automatically filters out spam, drafts, and duplicates.
-
AI Categorization: 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).
-
Find or Create Slack Channel: The workflow then checks your Slack workspace to see if a channel corresponding to the AI's category already exists (e.g., #sales).
-
Route the Email: 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. 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.
Key Requirements to Use This Template
-
n8n Instance & Required Nodes: An active n8n account (Cloud or self-hosted). This workflow uses the official n8n LangChain integration (@n8n/n8n-nodes-langchain). If you are using a self-hosted version of n8n, please ensure this package is installed.
-
Gmail Account: An active Gmail account with API access enabled.
-
Slack Workspace & App: A Slack workspace where you have permission to install apps. A Slack App with a Bot Token that has the following scopes: channels:read, channels:manage, chat:write, groups:write, and users:read.
-
OpenRouter Account: An account with OpenRouter to access various AI models like Llama 3. You will need an API key.
Setup Instructions
-
Gmail Configuration: In the "Capture Gmail Event" (Gmail Trigger) node, connect your Gmail account using OAuth2 credentials.
-
OpenRouter AI Configuration: In the "OpenRouter Chat Model" node, create a new credential and add your OpenRouter API key.
-
Slack Configuration: Create a Slack App: Go to api.slack.com/apps, create a new app, and install it to your workspace. Set Permissions: In your app's "OAuth & Permissions" settings, add the following Bot Token Scopes: channels:read, channels:manage, chat:write, groups:write, users:read. Reinstall the app to your workspace after adding them. Get Bot Token: Copy the "Bot User OAuth Token" (it starts with xoxb-). Connect in n8n: In all Slack nodes in the workflow, create a new credential and paste this Bot Token. 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.
-
Activate the Workflow: Save the workflow and toggle the "Active" switch to ON. Your intelligent email routing system is now live!
Support If you need help setting up this workflow or require a custom version tailored to your specific use case, please feel free to reach out to the template author:
Website: https://www.intuz.com/services Email: getstarted@intuz.com LinkedIn: https://www.linkedin.com/company/intuz Get Started: https://n8n.partnerlinks.io/intuz
For Custom Worflow Automation Click here- Get Started
Related Templates
Automate Free IP Analysis: NixGuard AI Summaries & Wazuh Integration
Supercharge Your Security Operations for Free Stop wasting time manually investigating suspicious IP addresses. This wo...
Convert JSON Objects to Base64 Strings with File Processing
Encode JSON to Base64 String in n8n This example workflow demonstrates how to convert a JSON object into a base64-encod...
AI Agent with Ollama for current weather and wiki
This workflow template demonstrates how to create an AI-powered agent that provides users with current weather informati...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments