Quick overview
Automate Gmail customer support using an approved knowledge base, Google Gemini and Supabase. Send routine replies, route sensitive requests to a human reviewer, label unrelated messages, and log outcomes in Google Sheets. A separate branch sends the reviewer’s final response.
How it works
- Manually download a knowledge file from Google Drive, generate OpenAI embeddings, and store the content in Supabase for retrieval.
- Monitor Gmail for unread customer emails, excluding messages already labeled AI-Processed, Needs-Human or AI-Ignored, and messages from the configured reviewer.
- Extract the sender, subject, message body and email identifiers. Google Gemini is instructed to search the approved knowledge base and return a structured routing decision.
- Extract the sender, subject, message body and email identifiers. Google Gemini is instructed to search the approved knowledge base and return a structured routing decision.
- For requests requiring human review, apply Needs-Human, email the reviewer with the customer message and suggested reply, and log the case.
- For messages classified as unrelated promotions or spam, apply AI-Ignored, mark the email as read, and log the decision.
- Monitor the configured reviewer’s replies. Validate the sender and extract the response between SEND_TO_CUSTOMER and END_SEND. Send it to the original customer message, update labels, mark the reviewer’s email as read, and append a final log row.
Setup
- Connect your Gmail, Google Drive, Google Sheets, OpenAI, Google Gemini and Supabase credentials. Use the support Gmail account for both Gmail triggers and all Gmail actions. Select a Gemini model that supports tool calling and structured output.
- In Supabase, create a documents table containing content, metadata and a 1536-dimensional embedding column, together with a compatible match_documents search function. Configure both OpenAI embedding nodes to use text-embedding-3-small.
- Upload your approved business knowledge as a plain-text file to Google Drive and select it in Download Knowledge File. Replace the fictional agency details and policies in the agent prompt and knowledge file.
- Replace [email protected] in both Gmail trigger filters, Notify Human Reviewer and Parse Human Final Reply. Use a separate reviewer mailbox and enter its address in lowercase in the validation code.
- Create Gmail labels named AI-Processed, Needs-Human and AI-Ignored. Select their corresponding IDs in every node that adds or removes these labels.
- Select your spreadsheet in all four Google Sheets nodes. Create a Support Log tab with these headers: Date, Email ID, Thread ID, Sender, Subject, Customer Message, Category, Action, Knowledge Found, Reason, Reply Subject, Reply Message, Final Status, AI Suggested Reply, Reviewer Email, Final Reply, Reviewer Reply ID, Review Requested At, Final Reply Sent At. Run Load Knowledge Base Manually once, confirm insertion into Supabase, and test all email paths with dummy messages before activating.
Requirements
- An n8n instance, a Google account with Gmail, Drive and Sheets access, Gemini and OpenAI API credentials, a Supabase project with vector search, and a separate reviewer mailbox.
Customization
- Customize the business knowledge, agent instructions and escalation rules. Change Gmail labels or logging columns as needed, updating the corresponding filters and field mappings.
Additional info
Test all branches before activation. AI replies depend on retrieved knowledge and model output. Re-running knowledge ingestion appends documents rather than replacing existing content. Human review and final responses create separate log rows. API and hosting usage may incur charges.