Skip to main content

Automated Gmail support agent with Gemini 2.5, RAG & Cohere reranking

Workflow preview

Workflow preview
100%
Automated Gmail support agent with Gemini 2.5, RAG & Cohere reranking preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

AI Email Support Agent with RAG & Cohere Reranking Transform your inbox into an intelligent support system: automatically detect new emails, retrieve relevant knowledge from Pinecone, rerank with C...

Best for

  • Support Chatbot automation workflows
  • AI RAG automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.gmailtrigger, @n8n/n8n-nodes-langchain.lmchatgooglegemini, n8n-nodes-base.gmail, @n8n/n8n-nodes-langchain.rerankercohere, @n8n/n8n-nodes-langchain.vectorstorepinecone, @n8n/n8n-nodes-langchain.embeddingsopenai, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.memorypostgreschat

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Automated Gmail support agent with Gemini 2.5, RAG & Cohere reranking
Workflow name
Automated Gmail support agent with Gemini 2.5, RAG & Cohere reranking

AI Email Support Agent with RAG & Cohere Reranking

Transform your inbox into an intelligent support system: automatically detect new emails, retrieve relevant knowledge from Pinecone, rerank with Cohere for precision, generate contextual replies using Gemini AI, and respond—all while maintaining conversation history.

What It Does

This workflow triggers on incoming Gmail messages, leverages a LangChain agent with PostgreSQL memory for context, queries a Pinecone vector store (RAG) enhanced by Cohere reranking and OpenAI embeddings, crafts personalized responses via Gemini 2.5, and auto-replies to keep support flowing.

Key Features

  • Gmail Integration - Real-time polling for new emails every minute
  • RAG with Pinecone - Retrieves top 10 relevant docs from "agency-info" index as agent tool
  • Cohere Reranking - Boosts retrieval accuracy by reordering results semantically
  • Persistent Memory - Postgres chat history keyed by email ID for ongoing threads
  • Gemini-Powered Agent - Handles queries with custom system prompt for agency support
  • Seamless Auto-Reply - Sends formatted text responses directly in Gmail

Perfect For

  • Agencies: Automate client FAQs on services, pricing, and ownership
  • Support Teams: Scale responses without losing conversation context
  • Small Businesses: Handle inquiries 24/7 with AI-driven accuracy
  • Developers: Prototype RAG agents with vector stores and rerankers
  • Marketers: Personalize outreach replies based on knowledge base
  • Consultants: Quick, informed answers from internal docs

Technical Highlights

Built on n8n's LangChain ecosystem, this workflow highlights:

  • Trigger-to-response pipeline with polling and webhooks
  • Hybrid retrieval: Embeddings + vector search + semantic reranking
  • Stateful agents with database-backed memory for multi-turn chats
  • Multi-provider setup: OpenAI (embeddings), Cohere (rerank), Google (LLM)
  • Scalable for production with configurable topK and session keys

Setup Instructions

Prerequisites

  • n8n instance with LangChain nodes enabled
  • Accounts for: Gmail (OAuth2), OpenAI (API key), Cohere (API key), Google Gemini (API key), Pinecone (API key and index), Postgres (database connection, e.g., Neon or Supabase)

Required Credentials

Gmail OAuth2
  1. Enable Gmail API in Google Cloud Console
  2. Create OAuth2 credential in n8n with scopes: https://www.googleapis.com/auth/gmail.readonly, https://www.googleapis.com/auth/gmail.send
OpenAI API
  1. Get API key from platform.openai.com
  2. Add as OpenAI credential in n8n
Cohere API
  1. Sign up at cohere.com
  2. Copy API key to n8n Cohere credential
Google Gemini API
  1. Generate key at https://aistudio.google.com/
  2. Add as Google PaLM credential in n8n (compatible with Gemini)
Pinecone API
  1. Create index "agency-info" with dimension 1024
  2. Add API key to n8n Pinecone credential
Postgres
  1. Set up database (e.g., Neon/Supabase) with a table for chat history
  2. Add connection details (host, database, user, password) to n8n Postgres credential

Configuration Steps

  1. Import the workflow JSON into your n8n instance
  2. Assign all required credentials to the respective nodes
  3. Populate the Pinecone "agency-info" index with your knowledge base documents (use a separate upsert workflow or Pinecone dashboard)
  4. Customize the tableName in the Postgres Memory node if needed (default: "email_support_agent_")
  5. Adjust the agent's system prompt or topK retrieval if required for your use case
  6. Activate the workflow and test by sending a sample email to trigger it

Troubleshooting

  • No trigger firing: Verify Gmail scopes and polling interval
  • Empty retrieval: Check Pinecone index population, dimensions (must be 1024), and document embeddings
  • Rerank errors: Ensure Cohere API key is valid and has sufficient quota
  • Memory issues: Confirm Postgres connection and that sessionKey uses email ID

Perfect for deploying hands-off email automation. Import, connect credentials, and activate!

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 - Gmail Trigger

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

Block 2 - Gemini 2.5

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

Block 3 - Gmail Reply

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 4 - Cohere Reranker

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

Block 5 - Pinecone Retriever

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

Block 6 - OpenAI Embeddings

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.2

Block 7 - Email Support Agent

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

Block 8 - Postgres Memory

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

Block 9 - Note: Pinecone

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

Block 10 - Note: Cohere

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

Block 11 - Note: Agent

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

Block 12 - Overview Note1

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

3. Summary Table

Workflow Automated Gmail support agent with Gemini 2.5, RAG & Cohere reranking
Complexity intermediate
Nodes 12
Categories Support Chatbot, AI RAG
Author Daniel Nkencho
Published 08 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9382/9382.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 Automated Gmail support agent with Gemini 2.5, RAG & Cohere reranking do?

AI Email Support Agent with RAG & Cohere Reranking Transform your inbox into an intelligent support system: automatically detect new emails, retrieve relevant knowledge from Pinecone, rerank with C...

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 Support Chatbot, AI RAG use case.