# Fix Instructions for app2.syntheon.in/voicebot

## Current Status

### ✅ Frontend (Next.js): RUNNING
- **Port**: 3000
- **Status**: Running and healthy
- **Direct Access**: `http://localhost:3000/voicebot`
- **API Routes**: Available at `/voicebot/api/*`

### ✅ Backend (LiveKit Agent): RUNNING
- **Process**: Python agent.py dev
- **Status**: Multiple agent processes running
- **Purpose**: Handles LiveKit voice agent connections (not an HTTP API)

### ❌ Apache: MISCONFIGURED
- **Problem**: Serving `/livekit_frontend/` as static directory (showing file listing)
- **Solution**: Need to proxy `/voicebot` to Next.js on port 3000

## The Problem

When you visit `https://app2.syntheon.in/livekit_frontend/`, you see:
- Directory listing with files and folders
- No UI displayed

This is because Apache is configured to serve the directory as static files instead of proxying to Next.js.

## The Solution

Run these commands to fix the Apache configuration:

### Step 1: Backup Current Config
```bash
sudo cp /etc/apache2/sites-enabled/app2.syntheon.in.conf /var/www/html/livekit_frontend/app2.syntheon.in.conf.backup
```

### Step 2: Apply New Configuration
```bash
sudo cp /var/www/html/livekit_frontend/app2-updated.conf /etc/apache2/sites-enabled/app2.syntheon.in.conf
```

### Step 3: Test Configuration
```bash
sudo apache2ctl configtest
```

### Step 4: Reload Apache (if test passes)
```bash
sudo systemctl reload apache2
```

### Step 5: Verify Next.js is Running
```bash
ss -tlnp | grep :3000
```

If port 3000 is not listening, start Next.js:
```bash
cd /var/www/html/livekit_frontend/FrontEnd/agent-starter-react/agent-starter-react
nohup npm start > /tmp/nextjs.log 2>&1 &
```

## After Applying the Fix

Once Apache is reloaded, you can access:

### Frontend UI
```
https://app2.syntheon.in/voicebot
```

### API Routes
The Next.js app includes API routes accessible at:
- `https://app2.syntheon.in/voicebot/api/connection-details` - Get LiveKit connection details
- `https://app2.syntheon.in/voicebot/api/metrics` - Get metrics
- `https://app2.syntheon.in/voicebot/api/conversation-logs` - Get conversation logs
- `https://app2.syntheon.in/voicebot/api/twilio/outbound-call` - Twilio outbound calls

## Important Notes

1. **No separate /api endpoint needed**: The Next.js app includes all API routes at `/voicebot/api/*`

2. **Backend is LiveKit Agent**: The Python backend (`agent.py`) is a LiveKit agent that connects to LiveKit rooms, not an HTTP API server.

3. **Django backend not running**: The Django backend in `/var/www/html/livekit_frontend/backend/` is not currently running and may not be needed.

## What Changed in Apache Config

**Before:**
```apache
DocumentRoot /var/www/html/livekit_frontend
<Directory /var/www/html/livekit_frontend>
    Options -Indexes +FollowSymLinks
    ...
</Directory>
```
This served the directory as static files.

**After:**
```apache
DocumentRoot /var/www/html
<Location /voicebot>
    ProxyPass http://localhost:3000/voicebot
    ProxyPassReverse http://localhost:3000/voicebot
</Location>
```
This proxies `/voicebot` to the Next.js app on port 3000.

## Verification

After applying the fix, test:
```bash
# Test frontend
curl -I https://app2.syntheon.in/voicebot

# Test API
curl -X POST https://app2.syntheon.in/voicebot/api/connection-details

# Open in browser
# https://app2.syntheon.in/voicebot
```

You should see the LiveKit Voice Agent UI instead of the directory listing.
~