Route Telegram support with Groq, Pinecone, Supabase, and Slack

Go to Workflow
0 views
Built by Akshat Akshat
Created on September 11, 2026

Description

Quick overview
RELAY is a Telegram support agent that answers from your real knowledge base and live order data — not guesses. An AI agent drafts each reply, a second model reviews it before sending, and unresolved issues escalate to Slack as trackable tickets. Built-in rate-limiting keeps it production-safe.

How it works
Triggers when a new Telegram message is received and checks Supabase to ignore duplicate Telegram updates.
Looks up the sender’s rate-limit record in Supabase, updates the sliding window counter, and replies in Telegram if the user exceeds the message limit.
Validates and normalizes the incoming text, then retrieves the last 10 messages for the chat from Supabase and formats them into a conversation history.
Uses a Groq chat model agent that can search a Pinecone vector knowledge base (with Google Gemini embeddings), look up orders in Supabase, and check for existing follow-up tickets in Supabase to draft a structured support response.
Extracts any order ID and email from the draft output, fetches matching order records from Supabase, and passes the question, evidence, and draft response to a second Groq model to approve or revise the answer.
Saves the user message and final assistant reply to Supabase chat memory, then replies to the customer on Telegram.
If escalation is required and no ticket is already open, creates a pending follow-up ticket in Supabase and posts the escalation details to a Slack channel, while still replying to the customer in Telegram.
Separately, receives a Slack /resolve-ticket webhook command, updates the ticket status to resolved in Supabase, and posts an ephemeral confirmation back to Slack.

Setup
Add Telegram Bot credentials and configure the bot to send updates to the Telegram trigger used by this workflow.
Add Supabase credentials and create the required tables: processed_updates, rate_limits, chat_memory, orders, and follow_up_tickets with fields matching the workflow queries and inserts.
Add Groq API credentials for both chat models used for the agent and the reviewer.
Configure Pinecone credentials and connect the vector store node to your own index (the template ships pointing at a placeholder index named company-latest — update it to yours), then add Google Gemini embeddings credentials for vector retrieval.
Add Slack credentials, set the target channel for escalation notifications, and configure a Slack slash command to POST to the /resolve-ticket webhook URL.

Nodes Used (10)

AI Agent
@n8n/n8n-nodes-langchain.agent
Code
n8n-nodes-base.code
Embeddings Google Gemini
@n8n/n8n-nodes-langchain.embeddingsGoogleGemini
Groq Chat Model
@n8n/n8n-nodes-langchain.lmChatGroq
HTTP Request
n8n-nodes-base.httpRequest
Pinecone Vector Store
@n8n/n8n-nodes-langchain.vectorStorePinecone
Slack
n8n-nodes-base.slack
Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured
Supabase
n8n-nodes-base.supabase
Telegram
n8n-nodes-base.telegram