An enterprise-grade AI customer support platform that handles conversations across multiple social channels, seamlessly hands off between AI agents and human agents, and delivers deep analytics on performance, sentiment, and resolution rates.
RevSmith is a full-stack SaaS platform that lets businesses deploy intelligent AI sales/support agents across WhatsApp, Instagram DM, Facebook Messenger, and a custom embeddable chat widget. The AI agents can:
- Hold context-aware conversations with real customers
- Execute complex tool calls (e.g., look up orders, check stock, create tickets)
- Retrieve knowledge from custom RAG-backed knowledge bases
- Automatically hand off conversations to human agents when needed
- Tag, classify, and analyze conversations with AI-driven sentiment and intent detection
This repository contains the Next.js frontend, which also serves as the backend-for-frontend (BFF) — hosting API routes, server-side services, background job handlers, and Supabase Edge Function definitions alongside the UI.
| Technology | Purpose |
|---|---|
| Next.js 14 (App Router) | Core framework — SSR, API routes, layouts |
| React 18 | Component model |
| TypeScript | Strict type safety across the entire codebase |
| Tailwind CSS v3 | Utility-first styling |
| Radix UI | Accessible, headless UI primitives (dialogs, tabs, menus, etc.) |
| shadcn/ui | Pre-built component library on top of Radix |
| Framer Motion | Animations and transitions |
| Recharts | Analytics charts and data visualizations |
| Lucide React / Phosphor Icons / Flaticon UIcons | Icon libraries |
| React Hook Form + Zod | Form state management and schema validation |
| MDX Editor / SimpleMDE | Rich markdown editors for knowledge base content |
| Embla Carousel | Carousel/slider components |
| next-themes | Dark/light mode support |
| Sonner | Toast notifications |
| cmdk | Command palette |
| date-fns / react-day-picker | Date utilities and pickers |
| react-resizable-panels | Resizable split-panel layouts |
| DOMPurify | XSS-safe HTML sanitization for AI message rendering |
| marked / markdown-it / react-markdown | Markdown rendering for chat messages |
| react-syntax-highlighter | Code block rendering in chat |
| Technology | Purpose |
|---|---|
| Supabase | PostgreSQL database, Auth, Realtime, Row-Level Security (RLS) |
Supabase SSR (@supabase/ssr) |
Server-side Supabase client for Next.js |
| Supabase Edge Functions (Deno) | Serverless functions for Stripe billing webhooks, plan fetching, and checkout |
| Supabase RLS Policies | Multi-tenant data isolation by organization_id |
| 89 SQL Migrations | Full schema versioning — tables, RPC functions, triggers, and policies |
| Redis | Caching layer for AI integration state and action lists |
| PostgreSQL RPC Functions | Complex server-side queries (conversation summaries, analytics aggregation, human handoff queues) |
Key database tables:
organizations,users— Multi-tenant org structure with role-based accessagents— AI agent configurations (prompts, knowledge base links, welcome messages)integration— Per-agent third-party app connections (Nango OAuth)conversation_details,chat_details— Full conversation history with tool call logsanalytics— AI performance, sentiment scores, resolution datahuman_handoff_queue— Queue management for human agent assignmenttags— Conversation classification labelswidget— Embeddable chat widget configurationssubscriptions,customers— Stripe billing records
| Technology | Purpose |
|---|---|
| OpenAI SDK | LLM calls for agent responses |
| Custom FastAPI Backend | Dedicated AI execution service (tool calling, RAG, agent orchestration) |
| Tool Calling | AI agents can invoke per-integration actions (e.g., Shopify order lookup, Google Calendar, HubSpot CRM) |
| Advanced RAG | Agents are linked to knowledge bases; documents are chunked, embedded, and retrieved per conversation |
| Composio | Third-party action framework for 100+ app integrations |
| Nango | OAuth connection management for external integrations |
| Custom Tool Builder | UI for defining custom tools with JSON schema inputs/outputs, docstrings, and expected outputs |
| Channel | Implementation |
|---|---|
| Official WhatsApp Business API webhooks — inbound/outbound messages, media | |
| Instagram DM | Instagram Graph API — message receive/send, account linking |
| Facebook Messenger | Meta Messenger Platform — page-level message routing |
| Chat Widget | Embeddable JS widget with fingerprinting (@fingerprintjs/fingerprintjs) for anonymous user tracking |
All channels are managed through a Consolidated Inbox — a unified interface where human agents can monitor, take over, and close conversations from any channel.
| Technology | Purpose |
|---|---|
| Inngest | Durable background function execution |
| Vercel | Hosting, Cron Jobs, Edge Functions, Analytics |
Inngest functions:
handle-whatsapp-message— Debounced per phone number (3s window), 5-min timeouthandle-instagram-message— Debounced per sender IDhandle-messenger-message— Debounced per sender IDhandle-conversation-handover— Queues conversation for human agent assignmenthandle-conversation-close— Marks conversations as resolvedhandle-conversation-follow-up— Sends follow-up messages automaticallyhandle-conversation-acceptance— Transitions conversation to human agent mode
All functions have per-key concurrency controls to prevent race conditions on the same conversation or user.
| Technology | Purpose |
|---|---|
| Stripe | Subscription billing, checkout sessions, webhooks |
| Polar.sh SDK | Alternative billing provider support |
| Supabase Edge Functions | create-checkout, get-plans, get-stripe-products, payments-webhook |
Subscription tiers gate features like the number of active tool actions per agent, with real-time capacity checks before enabling integrations.
Four analytics modules are built into the dashboard:
- Overview Tab — Conversation volumes, resolution rates, response times across all channels
- AI Metrics Tab — LLM performance metrics: token usage, response quality scores, tool call success rates
- Conversation Analysis Tab — Per-conversation sentiment analysis, intent classification, structured data extraction
- Human Agent Metrics Tab — Human agent performance: handle time, CSAT scores, handoff rates
Analytics data is aggregated via custom PostgreSQL RPC functions and visualized with Recharts.
| Feature | Implementation |
|---|---|
| Authentication | Supabase Auth (email + Google OAuth) |
| Role-Based Access | admin, agent, and custom org roles enforced at DB level via RLS |
| Multi-Tenancy | All data scoped to organization_id — full org isolation |
| User Status | Real-time presence: available, unavailable, busy, onBreak, offline |
| Email Verification | Custom email verification flow |
| Password Reset | In-dashboard password reset |
| Technology | Purpose |
|---|---|
Sentry (@sentry/nextjs) |
Error tracking, performance monitoring, source maps |
| PostHog | Product analytics, feature flags, session recording |
| Vercel Analytics | Web vitals and traffic analytics |
| next-sitemap | Automatic sitemap generation for public pages |
| Prettier | Code formatting |
src/
├── app/
│ ├── (auth)/ # Auth pages (sign-in, sign-up)
│ ├── api/ # Next.js API routes (25+ route groups)
│ │ ├── whatsapp/ # WhatsApp webhook handlers
│ │ ├── instagram/ # Instagram webhook handlers
│ │ ├── messenger/ # Messenger webhook handlers
│ │ ├── chatbot/ # Widget chatbot endpoints
│ │ ├── conversation/ # Conversation management
│ │ ├── knowledge-base/ # KB CRUD and file ingestion
│ │ ├── integration/ # Nango + Composio integration management
│ │ ├── stripe/ # Stripe checkout and webhooks
│ │ ├── human-analytics/ # Human agent analytics endpoints
│ │ └── inngest/ # Inngest function registration
│ ├── dashboard/
│ │ ├── agents/ # Agent list + per-agent config pages
│ │ │ └── [id]/
│ │ │ ├── ai3/ # AI model configuration
│ │ │ ├── channels/ # Channel assignments (WhatsApp/IG/Messenger)
│ │ │ ├── integrations/ # Tool integrations + custom tool builder
│ │ │ ├── sources/ # Knowledge base sources
│ │ │ ├── playground/ # Live agent chat testing
│ │ │ ├── analytics/ # Per-agent analytics
│ │ │ └── widget/ # Widget embed code generator
│ │ ├── consolidated-inbox/ # Unified multi-channel inbox
│ │ ├── analytics/ # Global analytics dashboard
│ │ ├── human-analytics/ # Human agent dashboard
│ │ ├── user-management/ # Org user management + role assignment
│ │ └── subscription/ # Billing and plan management
│ ├── pricing/ # Public pricing page
│ ├── widget/ # Standalone embeddable widget page
│ └── shopify-agent/ # Shopify-specific agent landing
├── components/ # Reusable React components
│ ├── analytics/ # Analytics chart components
│ ├── chat-components/ # Chat bubble, message, input components
│ ├── chat-widget/ # Embeddable widget UI
│ ├── agent-config/ # Agent configuration UI panels
│ └── ui/ # shadcn/ui base components
├── server-side-logic/
│ ├── service/ # Server-side service layer
│ │ ├── conversation.service.ts # Core conversation orchestration
│ │ ├── conversation-handoff.service.ts # Human handoff queue logic
│ │ ├── whatsapp-rest.service.ts # WhatsApp API calls
│ │ ├── instagram-rest.service.ts # Instagram Graph API calls
│ │ ├── messenger-rest.service.ts # Messenger API calls
│ │ ├── fast-api.rest-api.service.ts # AI backend proxy service
│ │ └── integration.service.ts # Nango/Composio integration calls
│ └── models/ # Data models
├── inngest/ # Background job definitions
├── contexts/ # React context providers
├── hooks/ # Custom React hooks
├── types/ # TypeScript type definitions + Supabase generated types
├── enum/ # Enums (channel types, roles, etc.)
└── utils/ # Utility functions
supabase/
├── functions/ # Deno Edge Functions (Stripe billing)
└── migrations/ # 89 versioned SQL migrations
/— Marketing landing page/pricing— Pricing tiers/about-us— About page/contact-us— Contact form/privacy— Privacy policy/terms— Terms of service/widget— Standalone embeddable chat widget
- Node.js 18+
- A Supabase project
- A Stripe account (for billing)
- Nango account (for OAuth integrations)
- Inngest account (for background jobs)
- Sentry project (for error tracking)
- PostHog project (for analytics)
npm installCopy .env.example to .env and fill in the required keys (Supabase URL/keys, Stripe keys, Nango keys, Sentry DSN, PostHog keys, WhatsApp/Instagram/Messenger app credentials).
npm run devApply migrations using the Supabase CLI:
supabase db pushnpm run buildDeployed on Vercel with:
- Automatic Vercel Cron monitor integration via Sentry
- PostHog analytics proxied through Next.js rewrites (ad-blocker bypass)
- Supabase Storage for knowledge base file uploads
- Supabase Edge Functions for payment processing