
Connects Claude to the Magpipe conversational platform for managing phone calls, SMS, WhatsApp, email, and web chat. You can configure AI voice agents, handle inbound and outbound calls, manage contacts and phone numbers, and orchestrate messaging across channels. Built on Supabase, SignalWire, and LiveKit with support for batch calling, conversation memory, and real-time translation. Useful when you're building workflows that need to programmatically manage telephony infrastructure or voice agents without jumping between the Magpipe dashboard and your code. The integration exposes the full stack from phone number provisioning to agent prompt configuration and conversation analytics.
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.
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
Clone the repository
git clone <repo-url>
cd pat
Install dependencies
npm install
Set up environment variables
cp .env.example .env
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
npx supabase db push
Deploy Edge Functions
export SUPABASE_ACCESS_TOKEN=your_token
npx supabase functions deploy --no-verify-jwt
Start development server
npm run dev
The app will be available at http://localhost:3000
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.
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.
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.
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.
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.
Every interaction is summarized and stored with vector embeddings. The agent retrieves relevant past context at the start of each new conversation for continuity across calls, SMS, and email.
The voice agent supports automatic translation across 30+ languages during live calls, allowing callers and agents to speak in different languages.
Real-time dashboards display call volume, sentiment analysis, and conversation trends. Organization-wide analytics are available for teams.
HubSpot (CRM), Google Workspace (Calendar, Gmail), Cal.com (booking), Apollo.io (contact enrichment), and Slack (notifications). Native tool execution via the agent chat interface.
Contacts can be whitelisted for priority handling, blocked, or given custom call rules. CSV import, Apollo.io enrichment, and automatic contact creation from calls/SMS.
All data is encrypted in transit and at rest via Supabase. Access codes, phone verification, and role-based permissions control who can access what.
The LiveKit voice agent runs on Render and connects to LiveKit Cloud, handling calls and messages around the clock without downtime.
users - User profiles, SIP credentials, preferences, credit balanceorganizations - Multi-user org managementcontacts - Contact information with enrichment fieldsagent_configs - AI agent configuration (5 types: inbound_voice, outbound_voice, text, email, chat_widget; single system_prompt with type-specific defaults; shared_memory_agent_ids for cross-agent memory sharing; voice settings, functions)call_records - Call history with purpose, goal, transcriptssms_messages - SMS message historyemail_messages - Email threads for inbox (id, user_id, agent_id, contact_id, thread_id, gmail_message_id, from/to/cc/bcc, subject, body_text, body_html, direction, status, is_ai_generated, is_read, sent_at, attachments JSONB for image metadata)agent_email_configs - Per-agent email channel config (gmail_address, agent_mode: off/draft/auto, watch_expiration, last_history_id)conversation_contexts - Conversation memory with embeddingsservice_numbers - User's phone numbers from SignalWire (agent_id for voice, text_agent_id for SMS — independent routing)support_tickets - Support ticket threads (Gmail integration, contact form feedback, ticket_ref TKT-XXXXXX, attachments JSONB for image metadata)support_ticket_notes - Internal notes on support threadssupport_email_config - Gmail connection, AI agent settings, ticket creation togglesupport-attachments (storage bucket) - Image attachments uploaded from Gmail or admin UIcredit_transactions - Billing and credit historyknowledge_sources / knowledge_chunks - RAG knowledge base (pgvector)chat_widgets / chat_sessions / chat_messages - Embeddable chat widgetbatch_calls - Batch outbound call jobs (status, scheduling, concurrency settings)batch_call_recipients - Per-recipient tracking for batch calls (status, call_record_id)referral_rewards - Referral tracking and bonus payoutssocial_listening_keywords - Tracked keywords for social monitoringsocial_listening_results - Reddit/HackerNews/Google mention resultsnpm run build
# Deploy dist/ folder to Netlify, Vercel, or similar
export SUPABASE_ACCESS_TOKEN=your_token
npx supabase functions deploy --no-verify-jwt
The agent auto-deploys from the master branch:
git push origin master
npm run dev - Start development servernpm run build - Build for productionnpm run preview - Preview production buildnpm test - Run Playwright testsnpm run lint - Lint code# Run all Playwright tests
npx playwright test
# Run specific test
npx playwright test tests/test-outbound-call.spec.js
# Run with UI
npx playwright test --ui
MIT
For issues and questions, please open a GitHub issue.
MAGPIPE_API_KEY*secretYour Magpipe API key (starts with mgp_). Get one at https://magpipe.ai/settings → API tab.