Date: 2025-10-31 Task: Enable SIP outbound calling via SignalWire
✅ Code Complete - Commit 694f872
- inbox.js updated to use SIP instead of LiveKit
- Migration file created:
supabase/migrations/20251031120000_add_sip_credentials.sql
⏸️ Blocked - Need to:
- Apply database migration (add SIP credential columns)
- Provision SIP endpoints in SignalWire
- Update database with SIP credentials
-
Open Supabase SQL Editor:
https://supabase.com/dashboard/project/mtxbiyilvgwhbdptysex/sql/new -
Copy and paste this SQL:
-- Add SIP credential fields to service_numbers table ALTER TABLE service_numbers ADD COLUMN IF NOT EXISTS sip_username VARCHAR(255), ADD COLUMN IF NOT EXISTS sip_password VARCHAR(255), ADD COLUMN IF NOT EXISTS sip_domain VARCHAR(255) DEFAULT 'erik.signalwire.com', ADD COLUMN IF NOT EXISTS sip_ws_server VARCHAR(255) DEFAULT 'wss://erik.signalwire.com:7443'; -- Add comments COMMENT ON COLUMN service_numbers.sip_username IS 'SIP username for WebRTC calling'; COMMENT ON COLUMN service_numbers.sip_password IS 'SIP password (should be encrypted in production)'; COMMENT ON COLUMN service_numbers.sip_domain IS 'SIP domain (SignalWire space)'; COMMENT ON COLUMN service_numbers.sip_ws_server IS 'WebSocket server for SIP over WebRTC';
-
Click "Run" to execute
export SUPABASE_ACCESS_TOKEN=<your-token-from-supabase-dashboard>
npx supabase db pushRun this command to verify:
node scripts/check-sip-credentials.jsExpected output should show:
⚠️ 🟢 Active +1XXXXXXXXXX
❌ Missing SIP credentials
-
Log in to SignalWire Dashboard
https://erik.signalwire.com -
Navigate to SIP Section
- Click "Phone Numbers" in sidebar
- Click "SIP" tab
-
Create New SIP Endpoint
- Click "+ Add Endpoint" or similar
- Configure:
- Username: Use phone number without + (e.g.,
16042101966) - Password: Generate strong password (save it!)
- Caller ID: The phone number (e.g.,
+16042101966) - Domain:
erik.signalwire.com - WebSocket: Enable WebRTC/WebSocket support
- Username: Use phone number without + (e.g.,
-
Link to Phone Number (if needed)
- Some SignalWire interfaces require linking SIP endpoint to phone number
- Associate the endpoint with the corresponding phone number
If SignalWire dashboard doesn't have SIP endpoint UI, we may need to:
- Use SignalWire REST API to create SIP credentials
- Check SignalWire documentation for "SIP Endpoints" or "WebRTC Endpoints"
- Or configure via LaML/SWML scripts
Once you have SIP credentials from SignalWire, update the database:
-- For each service number, run:
UPDATE service_numbers SET
sip_username = '16042101966', -- Phone number without +
sip_password = 'YOUR_PASSWORD_FROM_SIGNALWIRE',
sip_domain = 'erik.signalwire.com',
sip_ws_server = 'wss://erik.signalwire.com:7443'
WHERE phone_number = '+16042101966';
-- Repeat for each numberCreate a script scripts/update-sip-credentials.js:
#!/usr/bin/env node
import { createClient } from '@supabase/supabase-js';
import dotenv from 'dotenv';
dotenv.config();
const supabase = createClient(
process.env.VITE_SUPABASE_URL,
process.env.SUPABASE_SERVICE_ROLE_KEY
);
const credentials = [
{
phone_number: '+16042101966',
sip_username: '16042101966',
sip_password: 'YOUR_PASSWORD_HERE',
sip_domain: 'erik.signalwire.com',
sip_ws_server: 'wss://erik.signalwire.com:7443'
},
// Add more numbers here
];
async function updateCredentials() {
for (const cred of credentials) {
const { error } = await supabase
.from('service_numbers')
.update({
sip_username: cred.sip_username,
sip_password: cred.sip_password,
sip_domain: cred.sip_domain,
sip_ws_server: cred.sip_ws_server
})
.eq('phone_number', cred.phone_number);
if (error) {
console.error(`Failed to update ${cred.phone_number}:`, error);
} else {
console.log(`✅ Updated ${cred.phone_number}`);
}
}
}
updateCredentials();Then run:
chmod +x scripts/update-sip-credentials.js
node scripts/update-sip-credentials.js-
Verify SIP Credentials
node scripts/check-sip-credentials.js
Should show:
✅ 🟢 Active +16042101966 SIP Username: 16042101966 SIP Domain: erik.signalwire.com WS Server: wss://erik.signalwire.com:7443 -
Open Inbox in Browser
http://localhost:3000/inbox -
Make Test Call
- Click on a contact or enter a phone number
- Click the Call button
- Watch browser console for SIP debug logs:
🔧 Initializing SIP client... 🔌 WebSocket connected successfully ✅ SIP registered successfully 📞 Call ringing... ✅ Call connected
-
Check for Issues
- SIP registration fails: Check username/password in database
- Call doesn't connect: Check SignalWire trunk configuration
- No audio: Check browser microphone permissions
- WebSocket fails: Verify wss://erik.signalwire.com:7443 is correct endpoint
- Verify username/password in database match SignalWire endpoint
- Check SignalWire endpoint is enabled
- Verify domain is correct (
erik.signalwire.com)
- SIP endpoint may not have permission to make outbound calls
- Check SignalWire trunk allows outbound calling
- Verify caller ID is authorized
- Verify WebSocket server URL is correct
- Check firewall/network allows WSS connections on port 7443
- Try alternative WebSocket endpoint if SignalWire provides one
- Check browser microphone permissions
- Verify STUN/TURN servers in sipClient.js (lines 189-193)
- Check browser console for WebRTC errors
Once basic SIP calling is working:
-
Phase 2: LiveKit Bridging (specs/Pat-AI/plan.md)
- Add CXML/SWML to bridge SIP call to LiveKit room
- Enable recording by recording LiveKit room
- Add agent to call via LiveKit agent
-
Phase 3: Speaker Labeling & Tool Tracking
- Label speakers: User, Agent, Guest
- Track tool invocations in call records
- Store in call_records table
- ✅
src/pages/inbox.js:1499-1594- initiateCall() uses SIP - ✅
src/pages/inbox.js:1447-1459- hangup uses sipClient - ✅
supabase/migrations/20251031120000_add_sip_credentials.sql- Migration - ✅
scripts/check-sip-credentials.js- Helper script - ✅
scripts/apply-sip-migration.js- Helper script (deprecated) - ✅
SESSION-NOTES.md- Updated with current progress
- Supabase Project: https://supabase.com/dashboard/project/mtxbiyilvgwhbdptysex
- SignalWire Dashboard: https://erik.signalwire.com
- JsSIP Documentation: https://jssip.net/documentation/
- Outbound Calling Design: specs/Pat-AI/plan.md (search for "Outbound Calling Design Specification")
If you encounter issues not covered here, check:
- Browser console logs (F12 → Console)
- SignalWire call logs in dashboard
- Supabase Edge Function logs for any backend errors
- SESSION-NOTES.md for historical context