Magpipe - A Conversational Platform
Magpipe is a a conversational platform that manages SMS/Text messsges, Phone Calls, Email, and Web Chat. Built with vanilla JavaScript, Supabase, CPaaS, and LiveKit.
Features
- Smart Call Handling β AI answers calls, screens unknown callers, takes messages, and transfers important calls to you
- Intelligent SMS β Context-aware text responses that understand conversation history and respond appropriately
- Email AI β Automatically respond to emails with context-aware AI replies, drafts for review, or fully autonomous mode
- 24/7 Availability β Your assistant never sleeps. Handle calls and messages around the clock
- Contact Management β Whitelist VIPs, block spam, and set custom rules for different callers
- Knowledge Base β Train your assistant with custom information to answer questions accurately
- Privacy First β Your data is encrypted and secure. Full control over what information is shared
- Analytics & Insights β Real-time dashboards with call volume, sentiment analysis, and conversation trends
- Real-Time Translation β Automatic translation across 30+ languages during live calls
- Conversation Memory β Your agent remembers past interactions, caller preferences, and context across every conversation
- Integrations β Connect with HubSpot, Google Workspace, Zapier, and more. Sync contacts, log calls, and automate workflows
- Warm Transfer β Seamlessly hand off live calls to you or your team when the AI detects a conversation needs a human touch
- Social Listening β Automated monitoring of Reddit, HackerNews, and Google for keyword mentions. Email digests, admin dashboard with favorites, search, and status tracking
- Voice Library β 30 voice options (24 ElevenLabs + 6 OpenAI) with AI-generated avatars, audio previews, trait tags (accent, tone, age, use case), and multilingual support. Cloned voices use the Multilingual v2 model for natural accent preservation
- Blog & Social β Built-in blog with AI-generated featured images, Twitter/X auto-posting with image attachments, and a What's New notification card for users
Tech Stack
- Frontend: Vanilla JavaScript (ES6+), HTML5, CSS3, Vite
- Backend: Supabase (PostgreSQL, Auth, Realtime, Edge Functions β TypeScript/Deno)
- Telephony: SignalWire (PSTN calls, SMS, conference bridging)
- Voice AI: LiveKit (real-time audio), OpenAI (LLM), Deepgram (STT), ElevenLabs (TTS)
- Payments: Stripe (credits, subscriptions)
- Email: Postmark (transactional), Gmail API (support tickets, inbox email send/receive)
- Enrichment: Apollo.io (contact data)
- Social Listening: Serper.dev (Google SERP + Reddit), HN Algolia API
- Vector DB: pgvector (conversation context embeddings)
Project Structure
pat/
βββ agents/
β βββ livekit-voice-agent/ # Python LiveKit agent (deployed on Render)
β βββ agent.py # Main agent logic (~3,400 lines)
β βββ requirements.txt
β βββ render.yaml # Render deployment config
βββ public/ # Static assets
β βββ index.html
β βββ manifest.json # PWA manifest
β βββ sw.js # Service worker
β βββ styles/
βββ src/
β βββ components/ # Reusable UI components
β β βββ AdminChatInterface.js # Admin AI chat
β β βββ AdminHeader.js # Admin portal header with status dropdown
β β βββ BottomNav.js # Mobile bottom nav / desktop sidebar
β β βββ ConfirmModal.js # Custom confirm dialog
β β βββ ImpersonationBanner.js
β β βββ LowBalanceBanner.js # Low credit balance warning
β β βββ ...
β βββ lib/ # Utilities
β β βββ supabase.js # Supabase client
β βββ models/ # Data models (User, Contact, AgentConfig, etc.)
β βββ pages/ # UI pages (large pages split into subdirectories)
β β βββ admin/ # Admin portal (split from admin.js)
β β β βββ index.js # Entry point
β β β βββ support-tab.js # Support tickets, Gmail, AI settings
β β β βββ users-tab.js # User management
β β β βββ analytics-tab.js
β β β βββ kpi-tab.js
β β β βββ notifications-tab.js
β β β βββ chat-tab.js
β β β βββ global-agent-tab.js
β β β βββ styles.js
β β βββ agent-detail/ # Agent config (split from agent-detail.js)
β β β βββ index.js
β β β βββ configure-tab.js
β β β βββ prompt-tab.js
β β β βββ functions-tab.js
β β β βββ knowledge-tab.js
β β β βββ memory-tab.js
β β β βββ deployment-tab.js # Phone number assignment + inline buy-number modal
β β β βββ ...
β β βββ inbox/ # Inbox (split from inbox.js)
β β β βββ index.js
β β β βββ call-interface.js
β β β βββ listeners.js
β β β βββ messaging.js
β β β βββ views.js
β β βββ phone/ # Phone (split from phone.js)
β β β βββ index.js
β β β βββ call-handler.js
β β β βββ dialpad.js
β β β βββ number-management.js
β β βββ batch-calls.js # Batch outbound calls (CSV upload, scheduling)
β β βββ contacts.js
β β βββ settings.js
β β βββ ...
β βββ services/ # Business logic services
β β βββ unreadService.js
β β βββ pushNotifications.js
β β βββ mcpClient.js
β β βββ ...
β βββ main.js # App entry point
β βββ router.js # Client-side SPA routing
βββ supabase/
β βββ functions/ # ~160 Edge Functions (TypeScript/Deno)
β β βββ _shared/ # Shared utilities (cors, auth, balance-check)
β β βββ admin-status/
β β βββ contact-lookup/ # Apollo.io enrichment
β β βββ batch-calls/ # Batch call CRUD (create, list, get, start, cancel)
β β βββ process-batch-calls/ # Batch call worker (initiates calls per recipient)
β β βββ initiate-bridged-call/
β β βββ gmail-push-webhook/ # Gmail Pub/Sub push notifications + support ticket mirroring
β β βββ gmail-watch-renew/ # Daily Gmail watch renewal
β β βββ poll-gmail-inbox/ # Fallback email polling (30m)
β β βββ poll-gmail-tickets/
β β βββ support-tickets-api/
β β βββ webhook-inbound-call/
β β βββ webhook-inbound-sms/
β β βββ ...
β βββ migrations/ # Database migrations
βββ packages/
β βββ mcp-server/ # MCP server for AI coding tools (Claude Code, Cursor)
βββ tests/ # Playwright & contract tests
βββ specs/ # Feature specifications
Getting Started
Prerequisites
- Node.js 18+ and npm
- Supabase account & CLI
- SignalWire account (SIP endpoint, phone numbers)
- LiveKit Cloud account
- OpenAI API key
- Deepgram API key
- ElevenLabs API key
Installation
-
Clone the repository
git clone <repo-url>
cd pat
-
Install dependencies
-
Set up environment variables
Edit .env with your credentials:
# Supabase
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
# SignalWire
SIGNALWIRE_PROJECT_ID=your_project_id
SIGNALWIRE_API_TOKEN=your_api_token
SIGNALWIRE_SPACE_URL=your_space.signalwire.com
# LiveKit
LIVEKIT_URL=wss://your-project.livekit.cloud
LIVEKIT_API_KEY=your_api_key
LIVEKIT_API_SECRET=your_api_secret
# AI Services
OPENAI_API_KEY=your_openai_key
DEEPGRAM_API_KEY=your_deepgram_key
ELEVENLABS_API_KEY=your_elevenlabs_key
-
Run database migrations
-
Deploy Edge Functions
export SUPABASE_ACCESS_TOKEN=your_token
npx supabase functions deploy --no-verify-jwt
-
Start development server
The app will be available at http://localhost:3000
Architecture
Smart Call Handling
Inbound calls hit a SignalWire number, which triggers a LiveKit room. The AI agent joins, screens the caller, and decides whether to transfer, take a message, or handle the conversation. All calls are recorded with transcripts stored automatically.
Intelligent SMS
Inbound SMS triggers a webhook that retrieves conversation context (with vector embeddings), generates a context-aware AI response, and sends it via SignalWire. Full conversation history is maintained per contact.
Only agent_type = 'text' agents handle SMS. Voice agents are never routed inbound SMS. Agent selection priority: explicit text_agent_id on the service number β user's default text agent β any text agent belonging to the user. If no text agent is found, a one-time auto-reply is sent to the sender and subsequent messages from that number are silently ignored.
Loop detection prevents runaway back-and-forth: if the same message body arrives more than twice in a conversation thread, the AI reply is skipped silently. Normal replies resume as soon as the sender sends a different message.
Email AI
Gmail integration via OAuth and Pub/Sub push notifications. The agent can operate in draft mode (generates replies for review) or auto mode (sends replies autonomously). Emails are threaded and visible in the unified inbox.
Warm Transfer
During a live call, the AI can seamlessly hand off to a human. SignalWire bridges the caller to your phone while the agent briefs you, then drops off the line.
Knowledge Base
Upload documents or URLs to train your agent. Content is crawled (via Firecrawl), chunked, and embedded with OpenAI into pgvector for RAG-powered retrieval during calls and messages.