Platform Overview
Understand the current SupportGPT data flow, dashboard, widget, and retrieval pipeline.
SupportGPT is a Next.js application backed by Supabase, Supabase Realtime, S3-compatible storage, model providers, and a hosted JavaScript widget.
Core Concepts
- Workspace: Team, plan, billing, message credits, members, and shared knowledge sources.
- Agent: Chat assistant configuration, model, instructions, widget settings, handoff settings, and actions.
- Sources: Files, text snippets, Q&A, crawled website pages, and Notion content stored as workspace files.
- Chunks: Extracted source text split into retrieval chunks and embedded with Gemini embeddings.
- Chat session: A visitor conversation with messages, source, visitor info, feedback, status, and handoff state.
- Live inbox: Human support workspace for escalated sessions.
Request Flow
flowchart LR
V[Visitor]
W[Embed script or iframe]
A[Agent settings]
R[Retrieval]
M[Model provider]
S[Supabase]
I[Live Inbox]
V --> W
W --> A
A --> R
R --> S
R --> M
M --> W
W --> S
S --> ISource Processing
When a source is added:
- The dashboard sends the source to an authenticated upload or sync route.
- The original file or extracted content is stored.
- Text is extracted from supported formats.
- Text is chunked for retrieval.
- Chunks are embedded with
gemini-embedding-001. - Chunks are stored in Supabase with pgvector.
Supported file text extraction currently includes PDF, DOCX, and TXT. The dashboard also accepts DOC files, but clean DOCX/TXT/PDF content is the safest source format.
Chat Response Flow
When a visitor sends a message:
- The widget sends the message to the public embed chat route.
- The route loads agent settings.
- The route checks rate limits and identity data when available.
- Workspace chunks are retrieved using the agent match threshold.
- A grounded prompt is built with instructions, chat history, and source context.
- The selected model provider returns the answer.
- The message and session data are stored for analytics and logs.
Human Handoff Flow
Human handoff can be triggered by:
- The "Talk to Human" button.
- Configured trigger keywords.
- Negative sentiment patterns.
- Optional message count rules.
Escalated sessions appear in Agent -> Inbox. Supabase Realtime broadcasts new escalations and messages to active dashboard users.
Security And Identity
The widget can identify logged-in users with:
userId.userHash, an HMAC generated on your server.user_metadata.email.user_metadata.name.
Use the secret key shown in Deploy -> Embed to generate the HMAC. Never place the secret key in browser code.
Current API Status
The dashboard and widget use Next.js API routes under /api. These routes require Supabase auth, service credentials, or public widget context depending on route. They are not a versioned public API contract.