đź’¬ Answer multi-channel support queries with OpenAI RAG and Supabase

⚡ 8,326 views · 💬 Support Chatbots

Description

Quick overview

Answers customer questions on Email, Live Chat, WhatsApp, Slack and Discord from your own documentation, retrieved through a Supabase vector store. Ungrounded answers, negative sentiment and explicit handover requests escalate to a human with a Zendesk ticket. Every conversation is categorised, logged and reported weekly.

How it works

  1. A message arrives on Email, Live Chat, WhatsApp, Slack or Discord and is normalised into one schema, with an explicit branch per channel.
  2. Five guards run before a single model call is paid for: auto-replies and bounces, empty bodies, duplicate deliveries, oversized messages, and an explicit request for a human matched in six languages. Live chat receives an HTTP response on each of those paths, so a caller never waits on an open connection.
  3. The agent answers from your documentation, retrieved from a Supabase vector store wired as a tool, with Postgres-backed chat memory so history survives restarts.
  4. Confidence is scored on grounding rather than on answer length: did the agent search the knowledge base, and did the knowledge base return anything. A long, fluent answer with no retrieval behind it scores low.
  5. Greetings and thank-yous short circuit that test instead of failing it, so ordinary politeness does not open a support ticket.
  6. At or above the threshold, and without negative sentiment, the answer goes back on the originating channel. Email keeps the customer’s own subject, Slack replies in thread.
  7. Otherwise the case escalates. The reason is derived from what already happened rather than re-decided, an AI step writes a short note for the human agent into the ticket body, and Zendesk gets a priority derived from sentiment. The chain keeps going if a step fails, so one outage cannot delete an entire escalation.
  8. Every conversation, answered or escalated, is categorised and logged to Google Sheets. A weekly job posts real figures to Slack, then archives them and purges old chat memory. A manual branch ingests your documentation, clearing the previous run first so re-running never duplicates anything.

Setup

  1. Run the Supabase SQL from the note beside the ingestion branch. It creates the pgvector extension, three tables, the retrieval function and the indexes. Nothing retrieves anything before it exists, and chat memory has no retention before it exists.
  2. Set four workflow settings by hand: timezone, a 180 second execution timeout, successful production executions set to not save, failed ones set to save. n8n does not carry timezone, timeout or the execution-saving options across an import, so no template can ship them. Two minutes of work, and it keeps customer messages out of your execution history.
  3. Create the 12 n8n Variables listed in the Global Configuration note on the canvas. Four of them are specific to your instance and have no sensible default, so they show SET_ in the field until you fill them in. The other eight resolve on their own. Set SUPPORT_EMAIL before you go live: its default is a placeholder, and it is the From address on every reply.
  4. Connect credentials: IMAP, SMTP, WhatsApp, Slack for both trigger and API, a Discord bot, Zendesk, a Google Sheets service account, Supabase, OpenAI, Postgres on the same Supabase project, and Header Auth for both webhooks.
  5. Replace the Load Source Documents node with your real documentation source, keeping its output shape of title, url and content. It ships with three sample articles so the pipeline runs end to end straight after import.
  6. Create the Google Sheet with these columns, in order: userId, channel, message, category, sentiment, timestamp, aiResponse, confidence, escalated, escalationReason.
  7. Run the manual ingestion trigger once. It populates the knowledge base, and until it has, grounding scores zero and everything routes to a human, which is the intended fallback. Then test three paths: a question your documentation answers, a message asking for a human, and the same message sent twice.
  8. Delete any channel branch you do not use.

Requirements

Customization

Additional info

Anything else worth knowing is written into the notes on the canvas, beside the nodes it applies to.

đź”— Nodes Used

Email Trigger (IMAP), Send Email, Google Sheets, Postgres, Slack, Webhook

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup