CASE STUDY 04 / 08 · KNOWLEDGE SYSTEMS
RAG Knowledge Agent
The AI Customer Agent Example prepares incoming Gmail messages, classifies them as sales rep or sales FAQ, and uses an OpenAI agent with access to a Supabase vector store to support its response. The workflow can draft an email using a Gmail tool and sends a Telegram message.

01 / THE PROBLEM
The challenge.
AI assistants often need access to specific business information instead of relying only on general AI knowledge.
02 / THE SOLUTION
The connected answer.
The AI Customer Agent Example prepares incoming Gmail messages, classifies them as sales rep or sales FAQ, and uses an OpenAI agent with access to a Supabase vector store to support its response. The workflow can draft an email using a Gmail tool and sends a Telegram message.
RAG means the assistant looks through trusted information before it answers, instead of relying only on general AI knowledge.
03 / HOW IT WORKS
Inside the logic.
A new email triggers the workflow through Gmail.
The email body is prepared, then a text classifier decides what kind of email it is — for example a message from a sales rep or a sales FAQ question — and routes it accordingly.
An AI agent takes over. It has access to a Supabase vector store that holds the business’s knowledge, and it uses OpenAI embeddings to find the most relevant information before answering. The agent can also draft an email through a Gmail tool.
A Telegram message is sent with the outcome, so someone can see what the agent did.
- 01
Gmail trigger
Receive the incoming email.
- 02
Prepare email body
Format the message for classification.
- 03
Text classifier
Route to sales rep or sales FAQ.
- 04
AI agent
OpenAI chat model can search a Supabase vector store with OpenAI embeddings and draft an email through a Gmail tool.
- 05
Telegram message
Send a message through Telegram.
BUILD GUIDE
How to build it.
A practical guide to recreating this workflow in n8n.
- 01
Prepare the knowledge base
Create a Supabase project and enable its vector store table. Load your business documents into it using a separate n8n workflow with OpenAI Embeddings and a Supabase Vector Store insert node.
- 02
Add the Gmail trigger
Connect Gmail and add a Gmail Trigger that watches for new emails in the inbox.
- 03
Clean the email body
Use a Set (Edit Fields) node to keep the sender, subject and plain-text body.
- 04
Classify the email
Add a Text Classifier node with categories such as "sales rep" and "sales FAQ", each with a short description, so emails go down the right path.
- 05
Build the RAG agent
Add an AI Agent node with an OpenAI Chat Model. Attach a Supabase Vector Store tool (using OpenAI Embeddings) so it searches your documents before answering, plus a Gmail tool so it can create a draft reply.
- 06
Send a Telegram notification
Create a Telegram bot, add its credentials, and send a message summarising what the agent did.
- 07
Test and activate
Send test emails of each type, check the retrieved context and draft, refine the prompt, then activate.
04 / TECHNOLOGY USED
Connected tools.
05 / WORKFLOW SCREENSHOTS
Behind the build.
Screenshot: AI Customer Agent Example workflow in n8n
Select the image to enlarge.
06 / RESULT
What it demonstrates.
An agent that answers from the business’s own knowledge instead of guessing, and routes different kinds of emails differently.
WHAT THIS PROJECT SHOWS
UP NEXT
AI Lead Generation Workflow