Connecting
Connecting...
Please wait
Click to try
Idle
Start Conversation
Enable Microphone & Volume
Ready
2:00
End Conversation
Speak Your Question

No Time Remaining

You have used all your available talk time for this session.

Upgrade to get more time to chat or text
Cliff Bramble AI - AI Restaurant Business Mentor - "AIRealAgent"
A Trusted Human Expert Scaled By AI - Cliff's expertise is on Upscale Dining, Business Startup

Building Restaurants, Business Finance, Operations, and Marketing.

"; const timerEnabled = true; const initialTime = 90; // seconds // Timer functions using localStorage function saveRemainingTime() { try { localStorage.setItem('32d1b42418_coursini_ai_timer', remainingTime.toString()); console.log('Timer saved to localStorage:', remainingTime); } catch (e) { console.error('Failed to save timer to localStorage:', e); } } function loadRemainingTime() { try { const saved = localStorage.getItem('32d1b42418_coursini_ai_timer'); console.log('Loading timer from localStorage:', saved); if (saved && saved !== 'null') { remainingTime = parseInt(saved); console.log('Parsed remaining time:', remainingTime); } else { remainingTime = initialTime; console.log('No saved timer found, using initial time:', initialTime); } // Check if time has expired if (remainingTime <= 0) { console.log('Timer expired, showing no time message'); showNoTimeMessage(); return false; } console.log('Timer loaded successfully, remaining:', remainingTime); return true; } catch (e) { console.error('Failed to load timer from localStorage:', e); remainingTime = initialTime; return true; } } function formatTime(seconds) { const minutes = Math.floor(seconds / 60); const secs = seconds % 60; return minutes + ":" + (secs < 10 ? "0" : "") + secs; } function startTimer() { if (!timerEnabled) return; const timerElement = document.getElementById('callTimer'); if (timerElement) { timerElement.style.display = 'block'; timerElement.textContent = formatTime(remainingTime); timerInterval = setInterval(() => { remainingTime--; timerElement.textContent = formatTime(remainingTime); saveRemainingTime(); if (remainingTime <= 0) { endCall(); showNoTimeMessage(); } }, 1000); } } function stopTimer() { if (timerInterval) { clearInterval(timerInterval); timerInterval = null; } const timerElement = document.getElementById('callTimer'); if (timerElement) { timerElement.style.display = 'none'; } } function showNoTimeMessage() { console.log('showNoTimeMessage called'); const messageElement = document.getElementById('noTimeMessage'); if (messageElement) { console.log('Found noTimeMessage element, showing it'); messageElement.style.display = 'block'; } else { console.error('noTimeMessage element not found!'); } // Hide all state containers console.log('Hiding all state containers'); $(".state-container").hide(); } async function endCall() { console.log('Ending the call'); if (conversation) await conversation.endSession(); conversation = null; stopTimer(); $("#readyState").hide(); // Only show idle state if there's time remaining if (!timerEnabled || remainingTime > 0) { $("#idleState").show(); } else { showNoTimeMessage(); } console.log('Call Ended'); } async function changeAssistant(newAssistantId) { if (currentState !== "idle") { changingAssistant = newAssistantId; if (conversation) { endCall(); } } conversation = await client.Conversation.startSession({ agentId: newAssistantId, onConnect: () => callInProgress(), onDisconnect: () => endCall(), onMessage: (message) => console.log("Message received:", message), onError: (error) => console.error("Error:", error), onModeChange: (mode) => console.log("Mode changed:", mode) }); } async function callInProgress() { console.log('Call In Progress'); $(".state-container").hide(); $("#readyState").show(); if (timerEnabled) { startTimer(); } } async function callConnecting() { console.log('Call Connecting'); $(".state-container").hide(); $("#connectingState").show(); } async function handleStateChange(newState) { console.log("🔄 State Changed: " + newState); console.log("Current remaining time:", remainingTime); console.log("Timer enabled:", timerEnabled); // Check timer expiration first before any state changes if (timerEnabled && remainingTime <= 0) { console.log("❌ Timer expired, blocking state change to", newState); showNoTimeMessage(); return; } $(".state-container").hide(); // Hide no time message when changing states (only if timer not expired) const messageElement = document.getElementById('noTimeMessage'); if (messageElement) { messageElement.style.display = 'none'; } currentState = newState; if (newState === "connecting") { callConnecting(); } else if (newState === "idle") { endCall(); } else if (newState === "start") { // Double-check timer before starting call if (timerEnabled && remainingTime <= 0) { showNoTimeMessage(); return; } callConnecting(); if (!conversation) { conversation = await client.Conversation.startSession({ agentId: assistantId, onConnect: () => callInProgress(), onDisconnect: () => endCall(), onMessage: (message) => console.log("Message:", message), onError: (error) => console.error("Error:", error), onModeChange: (mode) => console.log("Mode changed:", mode) }); } } } window.onload = function () { console.log('🔄 Page loaded, initializing timer system'); console.log('Timer enabled:', timerEnabled); console.log('Initial time setting:', initialTime); // Load remaining time if timer is enabled if (timerEnabled) { console.log('Loading timer from storage...'); if (!loadRemainingTime()) { console.log('❌ Timer expired, showing no time message immediately'); showNoTimeMessage(); return; } } const checkClient = setInterval(() => { if (typeof client !== "undefined") { clearInterval(checkClient); console.log("✅ ElevenLabs client loaded successfully!"); // Check timer expiration again after client loads if (timerEnabled && remainingTime <= 0) { console.log('❌ Timer still expired after client load, showing message'); showNoTimeMessage(); } else { console.log('✅ Timer OK, switching to idle state'); handleStateChange("idle"); } } else { console.log('⏳ Waiting for ElevenLabs client...'); } }, 500); };
NATASHA
After Work Listener

Listen To How Real This Conversation Feels

Watch the video below to see how easy it is to talk to a Coursini expert. Get expert advice in seconds, and in 29 languages.

Become A Coursini Member - Try For Free