Skip to main content

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

Workflow preview

Workflow preview
100%
Route and categorize Gmail emails to Slack with Llama 3 via OpenRouter preview
Open on n8n.io

1. Workflow Overview

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 Gmai...

Best for

  • Ticket Management automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.set, n8n-nodes-base.slack, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.code, n8n-nodes-base.if, @n8n/n8n-nodes-langchain.lmchatopenrouter, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Intuz.

Original n8n.io source

1.1 Workflow description

Title
Route and categorize Gmail emails to Slack with Llama 3 via OpenRouter
Workflow name
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

1. Monitor New Emails: The workflow continuously checks a specified Gmail account for new, unread emails. It automatically filters out spam, drafts, and duplicates.

2. 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).

3. 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).

4. 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

1. 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.

2. Gmail Account: An active Gmail account with API access enabled.

3. 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.

4. OpenRouter Account: An account with OpenRouter to access various AI models like Llama 3. You will need an API key.

Setup Instructions

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.
  • 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.

4. 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:

For Custom Worflow Automation

Click here- Get Started

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Structured Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 2 - Merge Category

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 3 - Invite a user to a channel

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.4

Block 4 - Find Category

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3

Block 5 - Format Channel Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 6 - Check Channel Exist

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 7 - Arrange Email Data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3

Block 8 - OpenRouter Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 9 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - OpenRouter Chat Model1

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 17 - Capture Gmail Event

Type / Role
n8n-nodes-base.gmailTrigger - gmailTrigger
Config choices
Version 1.3

Block 18 - Filter + Deduplicate Validation

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 19 - Check Data Exist

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 20 - Get Channels List

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.4

Block 21 - Join Slack Channel

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.4

Block 22 - Post Message in Channel

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.4

Block 23 - Create Slack Channel

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.4

Block 24 - Post Message in Created Channel

Type / Role
n8n-nodes-base.slack - slack
Config choices
Version 2.4

Showing the first 24 of 26 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Route and categorize Gmail emails to Slack with Llama 3 via OpenRouter
Complexity advanced
Nodes 26
Categories Ticket Management, AI Summarization
Author Intuz
Published 13 Jan 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/12671/12671.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Route and categorize Gmail emails to Slack with Llama 3 via OpenRouter do?

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 Gmai...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Ticket Management, AI Summarization use case.