console.log('INIT ELEVENLABS') import { Conversation } from 'https://cdn.skypack.dev/@elevenlabs/client'; const callBtn = document.getElementById('callBtn'); let conversation = null; document.addEventListener('JSsucks', () => { console.log("JSsucks") callBtn.addEventListener('click', async () => { console.log('Requesting microphone access...'); try { await navigator.mediaDevices.getUserMedia({ audio: true }); } catch (error) { console.log('Microphone access denied.'); return; } console.log('Connecting to agent...'); try { const { Conversation } = window.ElevenLabs; conversation = await Conversation.startSession({ agentId: 'agent_01jx2xm2w4exwvjhbq52js687f', connectionType: 'websocket', // or "webrtc" onConnect: () => { console.log('✅ Connected to AI Agent!'); }, onDisconnect: () => { console.log('🔌 Disconnected.'); }, onError: (err) => { console.log(`❌ Error: ${err.message || err}`); }, onMessage: (msg) => { console.log('Agent:', msg); }, }); } catch (err) { console.log('Failed to start session.'); console.error(err); } }) });