Multi-Department Customer Support Bot using Pinecone and Telegram - n8n Workflow

Deploy a robust, multi-department support bot with this advanced n8n workflow. Integrates Telegram, PostgreSQL for sessions, Google Drive, Pinecone RAG, and AI agents.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Businesses needing automated, multi-department support on messaging platforms like Telegram.

  • Developers looking for advanced n8n templates integrating RAG and state management.

  • Teams seeking to update knowledge bases dynamically via Google Drive file drops.

  • Users who require a complex, production-ready n8n workflow using Langchain tools.

Overview

Managing customer inquiries efficiently across multiple departments—such as Billing, Technical Support, and Returns—is challenging. This n8n workflow solves this by creating a highly organized, intelligent support bot powered by retrieval-augmented generation (RAG).

This sophisticated n8n solution uses Telegram as the interface and PostgreSQL for persistent session management, allowing the bot to maintain context even across long conversations. Crucially, the system uses three parallel RAG pipelines that monitor Google Drive folders. When a new policy document (like a PDF) is added, an n8n trigger initiates the automatic embedding and ingestion into the correct Pinecone vector store namespace, ensuring the AI agent always has the latest information. This dynamic setup makes the n8n workflow an ideal backend for responsive, accurate customer service.

How it Works

The entire process starts with the Telegram n8n trigger, monitoring incoming messages.


  1. Session Initialization: The workflow first uses a PostgreSQL n8n node to check if the user exists and creates a session if necessary, setting the user's initial state (active/inactive, department).

  2. Flow Control (Switch1): A primary n8n node, Switch1, routes the user based on their current state and command (/start or /end).

  3. Department Selection: If the user sends /start, they are prompted with available departments. If they send a slash command (e.g., /billing), a second Switch n8n node detects the command, sends a confirmation via a Telegram n8n node, and updates the PostgreSQL session to set the user's department and activate the chat session.

  4. AI Query Handling: If the user is active and has selected a department, their message is routed to the AI Agent3 n8n node.

  5. RAG Execution: The AI Agent uses an OpenRouter language model, retrieves the user's chat history via the Simple Memory n8n node, and dynamically uses the appropriate Pinecone Vector Store n8n tool (e.g., only the 'Billing' vector store if the user is in that department).

  6. Response: The agent’s answer is delivered back to the user via a Telegram n8n node.

  7. Knowledge Base Update (Independent RAG Pipelines): Three separate n8n workflow branches use a Google Drive n8n trigger to watch dedicated folders. When a new file is created, it is downloaded, processed by Langchain nodes (Embeddings Cohere, Default Data Loader, Character Text Splitter), and inserted into the relevant Pinecone namespace using an n8n node configured for insertion, keeping the knowledge base current.

Installation Guide

To deploy this comprehensive n8n workflow, follow these steps:


  1. Import the n8n template: Copy the provided JSON and import it into your n8n instance.

  2. Configure Credentials: You will need credentials for:

Telegram: Connect your Bot Token to the Telegram Trigger and all Telegram send nodes.
PostgreSQL: Set up credentials for the Postgres n8n nodes for session management.
Google Drive: Configure credentials for the three Google Drive Trigger nodes and ensure they point to the correct department-specific folders.
AI/RAG Services: Configure connections for Cohere (Embeddings), OpenRouter (Language Model), and Pinecone (Vector Database). You must have a Pinecone index named 'n8n-proj' with the namespaces 'billing', 'tech ques', and 'return policy' pre-created.

  1. Activate the Workflow: Ensure all three RAG ingestion workflows (starting with the Google Drive n8n trigger) and the main bot workflow (starting with the Telegram n8n trigger) are active.

Node Details

This n8n workflow leverages several powerful nodes:

Telegram Trigger (n8n trigger): The starting point. Listens for new messages on Telegram, initiating the core automation flow.
Postgres (Execute a SQL query / Select rows): Used for robust state management. It inserts new user IDs, checks their session status (active/department), and updates their chosen department, making this n8n node critical for context.
Switch (n8n node): Essential for routing the user's journey. The primary switch handles /start, /end, and routes messages to the AI Agent if a department is selected.
AI Agent3 (n8n node): The core intelligence. This Langchain n8n node dynamically routes user questions to the correct knowledge base using specific tools.
OpenRouter Chat Model3 (n8n node): Provides the LLM capabilities (configured here using the deepseek model).
Pinecone Vector Store (Insert Mode): Used in the three parallel RAG ingestion pipelines. This n8n node inserts document chunks and their Cohere embeddings into the dedicated Pinecone namespaces (billing, tech ques, return policy).
Pinecone Vector Store (Retrieve-as-Tool Mode): Used within the AI Agent configuration. These n8n nodes act as specialized tools, allowing the AI to search the correct knowledge base based on the user’s department context.
Google Drive Trigger (n8n trigger): Watches specified Google Drive folders. This n8n trigger ensures the knowledge base is updated automatically whenever new documents are uploaded.

Related n8n Workflows

Free

Nodes: 14 Nodes
Updated: December 26 2025
View all
Created by

Featured*