# BuzzTrail Wix Integration Guide - Updated with Build System

## 🎯 **Final Implementation Overview**

This integration creates a professional video demo that embeds directly in your Wix section. Users see Tom's looping video with a "Talk to Tom" button, and when clicked, start a 60-second embedded conversation without ever leaving your website.

## 🚀 **Quick Setup (3 Steps)**

### **Step 1: Build the Code**
```bash
# From the buzztrail/extension directory
pnpm wix

# This generates: wix-custom-code-built.html (production ready)
```

### **Step 2: Add Custom Code**
1. **Go to Site Settings → Custom Code** in Wix
2. **Add Code to Pages → Body - end**
3. **Copy and paste** the entire content from `wix-custom-code-built.html`
4. **Save**

### **Step 3: Configure Section ID**
Your section ID is: `comp-mfdtv4rf5` (the code is already configured for this)

If your section has a different ID, update `VITE_SECTION_ID` in `.env.production` and rebuild with `pnpm nx build:wix demos`.

### **Step 4: Test**
Preview your page - the demo should appear in your section after 1 second.

## ✅ **How It Works**

**Landing State:**
- **Left side**: Hero text about instant demos and "Talk to Tom" button
- **Right side**: Tom's looping video (hosted on Wix)
- **Mobile**: Video stacks on top, text below

**During Conversation (60 seconds):**
- **Embedded interface**: Conversation appears in same section
- **Timer**: Visible 60-second countdown
- **End Call button**: Manual termination option
- **Stays on your domain**: No external URLs visible

**After Conversation:**
- **Returns to landing state**: Ready for next user
- **Button resets**: "Talk to Tom" available again

## 🔧 **Technical Details**

### **Character Count**
- **11,321 characters** (24% under Wix's 15,000 limit)
- **Fully minified** and optimized

### **Configuration**
- **Persona ID**: `p527c5d8b826` 
- **Replica ID**: `rca8a38779a8`
- **Duration**: 60 seconds (server-enforced)
- **Video**: Your Wix-hosted Tom video

### **Responsive Design**
- **Desktop**: Side-by-side layout (text | video)
- **Tablet (≤768px)**: Stacked layout (video on top, text below)
- **Phone (≤480px)**: Optimized spacing and full-width button

## 🎨 **Design Features**

### **Landing Page**
- **Typography**: Clean system fonts with proper hierarchy
- **Colors**: BuzzTrail purple gradient button with hover effects
- **Video**: Tom's loop with subtle overlay gradient
- **Footer**: "This isn't just about AI Avatars" tagline

### **Conversation Interface**
- **Header**: Black overlay with "🤖 Talking with Tom" and countdown
- **Timer**: Green → red color change at 10 seconds
- **End Call**: Red button for manual termination
- **Container**: Rounded corners, professional appearance

## 🔒 **Privacy & Security**

### **No External Branding**
- ✅ **Users never see** `tavus.daily.co` URLs
- ✅ **Stays on your domain** throughout entire experience
- ✅ **Professional appearance** with your branding only

### **Permissions**
- **Camera/Microphone**: Embedded iframe has full permissions
- **No popups**: Everything happens in-page
- **HTTPS required**: For camera access

## 📱 **Mobile Experience**

### **Landing Page Mobile**
- **Video height**: 300px on tablet, 250px on phone
- **Text spacing**: Optimized for small screens
- **Button**: Full width on phones
- **Typography**: Responsive sizing (3.5rem → 1.8rem)

### **Conversation Mobile**
- **Interface**: Full responsive embed
- **Timer**: Visible and appropriately sized
- **Controls**: Touch-friendly button sizes

## 🚨 **Troubleshooting**

### **Demo Doesn't Appear**
- **Check section ID**: Must be `comp-mfdtv4rf5` (update in code if different)
- **Check custom code**: Ensure pasted in "Head" section
- **Check console**: Look for "🚀 BuzzTrail Demo initialized"

### **Video Doesn't Load**
- **Check video URL**: Must be publicly accessible Wix video
- **Check network**: Ensure video hosting is working
- **Check console**: Look for video loading errors

### **Conversation Doesn't Start**
- **Check proxy service**: Visit `https://buzztrail-proxy.vercel.app/api/health`
- **Check network**: Ensure API calls can reach proxy
- **Check console**: Look for conversation creation errors

### **Camera Doesn't Work**
- **Check HTTPS**: Camera requires secure connection
- **Check permissions**: Allow when browser prompts
- **Check iframe**: Ensure iframe loads properly

### **Different Section ID**
If your section has a different ID:
1. **Right-click your section** → Inspect Element
2. **Find the section ID** (looks like `comp-xxxxxxxx`)
3. **Replace `comp-mfdtv4rf5`** with your ID in the custom code

## 📊 **Performance**

### **Loading Time**
- **1-second delay**: Waits for Wix to fully load
- **Fast initialization**: Minimal JavaScript execution
- **Optimized CSS**: All styles are minified

### **Resource Usage**
- **Small footprint**: 11KB of compressed code
- **No external dependencies**: Self-contained
- **Efficient updates**: Only updates timer every second

## 🎯 **Success Metrics to Track**

- **Landing views**: How many users see the demo
- **Button clicks**: How many start conversations
- **Completion rate**: How many complete 60 seconds
- **Return rate**: How many return to use it again

## 🔄 **Updates & Maintenance**

### **To Update Video**
1. **Upload new video** to Wix Media Manager
2. **Copy new video URL**
3. **Replace video URL** in the custom code
4. **Save and republish**

### **To Change Duration**
Change `conversation_duration_seconds: 60` to desired seconds in the code.

### **To Update Text**
Modify the HTML content in the `section.innerHTML` part of the code.

## 🏆 **Final Result**

A completely branded, embedded video demo experience that:
- ✅ **Keeps users on your domain**
- ✅ **Provides professional first impression**
- ✅ **Delivers 60-second qualified conversations**
- ✅ **Works perfectly on mobile**
- ✅ **Requires zero maintenance**

Your prospects will have a seamless experience from landing page to conversation, all within your Wix website!