# Telnyx Demo Widget Integration Research
## Date: 2026-02-18 | Status: Research Complete

### EXECUTIVE SUMMARY

The demo.html chat widget is currently **simulated** (scripted responses). To connect to live Telnyx AI:

- **Effort**: ~50 lines of code changes, 1-2 days
- **Approach**: Add Telnyx WebRTC SDK, reuse existing AIVA assistant
- **Cost per demo**: ~$0.17-$0.43 (at $0.087/min)
- **No new assistants needed** — use AIVA + industry-specific system prompts

### CURRENT STATE

demo.html (1,070 lines) has:
- URL input form + 4 industry demo modals (Plumber, Electrician, HVAC, Landscaper)
- Simulated chat with `appendAIMessage()` / `appendUserMessage()` functions
- Quick-reply buttons with hardcoded responses
- Shows "+61 7 3130 4377" in footer

### WHAT'S NEEDED

#### 1. Add Telnyx WebRTC SDK
```html
<script src="https://cdn.telnyx.com/webrtc/telnyx-webrtc-client.min.js"></script>
```

#### 2. Replace Simulated Responses with Real Voice
```javascript
// Industry-specific prompts (no separate assistants needed)
const industryPrompts = {
  plumber: "You are an AI receptionist for a plumbing business...",
  electrician: "You are an AI receptionist for an electrical service...",
  hvac: "You are an AI receptionist for HVAC services...",
  landscaper: "You are an AI receptionist for landscaping..."
};

function initiateVoiceCall(industry) {
  telnyx.call({
    to: '+61731304377',  // AIVA
    metadata: { system_prompt: industryPrompts[industry] }
  });
}
```

#### 3. Telnyx Configuration Required
- Create WebRTC application in Telnyx Console
- Configure CORS for demo domain
- Generate auth token for browser connection

### ASSISTANT STRATEGY

**Reuse existing AIVA** (assistant-696799a5-e994-4ac1-8f26-7b0923aee682):
- Already production-tested (Kinan 30-min call)
- Voice: eucalyptus (Australian Female)
- Model: Gemini 2.5 Flash
- Cost: $0.087/min shared across all users

**Industry specialization via prompt switching**, not separate assistants.

### ARCHITECTURE

```
Browser (demo.html)
  → Telnyx WebRTC Client (new ~50 lines)
  → Telnyx WebRTC Server (wss://)
  → AIVA Voice Assistant (Gemini 2.5 Flash)
  → Two-way audio + transcribed text in chat window
```

### IMPLEMENTATION PHASES

1. **Setup** (1-2 hours): Telnyx credentials, CORS, WebRTC app
2. **Code Changes** (2-3 hours): SDK import, voice call function, UI indicators
3. **Testing** (2-3 hours): Browser WebRTC, voice quality, industry prompts, mobile
4. **Deployment** (1 hour): Push to VPS, verify CORS, monitor

### COST ANALYSIS

- Telnyx WebRTC: Free (included with account)
- Voice calls: $0.087/minute
- Estimated 20-50 demos/day × 2-5 min = $3-20/day ($90-600/mo)
- Each demo = potential $197-$597/mo customer → 100-1000x ROI

### DEPENDENCIES

- Browser WebRTC support (all modern browsers)
- Microphone permission from user
- Telnyx account with WebRTC enabled
- AIVA assistant pre-configured (DONE)

### NEXT STEPS

1. Get Telnyx WebRTC credentials from Console (5 min)
2. Update demo.html with ~50 lines of Telnyx code (2-3 hours)
3. Deploy and test from live domain (1 hour)
4. Monitor call completion rates and costs
