Twilio client script still not working - Follow Up Deployment
Browse files- index.html +248 -276
- prompts.txt +12 -1
index.html
CHANGED
|
@@ -1,4 +1,38 @@
|
|
| 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
|
|
@@ -8,6 +42,25 @@
|
|
| 8 |
|
| 9 |
<!DOCTYPE html>
|
| 10 |
<html lang="en">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
=======
|
| 12 |
|
| 13 |
|
|
@@ -40,58 +93,6 @@
|
|
| 40 |
=======
|
| 41 |
|
| 42 |
|
| 43 |
-
// Initialize on page load
|
| 44 |
-
document.addEventListener('DOMContentLoaded', function() {
|
| 45 |
-
// Close when clicking outside modals
|
| 46 |
-
document.querySelectorAll('.modal-overlay').forEach(modal => {
|
| 47 |
-
modal.addEventListener('click', (e) => {
|
| 48 |
-
if (e.target === modal) {
|
| 49 |
-
modal.classList.add('hidden');
|
| 50 |
-
}
|
| 51 |
-
});
|
| 52 |
-
});
|
| 53 |
-
|
| 54 |
-
// Initialize Twilio device with default settings
|
| 55 |
-
if (typeof Twilio !== 'undefined') {
|
| 56 |
-
const defaultToken = generateDefaultTwilioToken();
|
| 57 |
-
initializeTwilioDevice(defaultToken);
|
| 58 |
-
}
|
| 59 |
-
// Check for saved settings
|
| 60 |
-
const savedSettings = localStorage.getItem('aiCallSettings');
|
| 61 |
-
if (savedSettings) {
|
| 62 |
-
const config = JSON.parse(savedSettings);
|
| 63 |
-
|
| 64 |
-
// Update phone number displays
|
| 65 |
-
document.querySelectorAll('.phone-number-display').forEach(el => {
|
| 66 |
-
el.textContent = formatPhoneNumber(config.phoneNumber);
|
| 67 |
-
});
|
| 68 |
-
|
| 69 |
-
// Update stats with saved data
|
| 70 |
-
if (config.callStats) {
|
| 71 |
-
document.getElementById('callStatsCount').textContent = config.callStats;
|
| 72 |
-
}
|
| 73 |
-
if (config.textStats) {
|
| 74 |
-
document.getElementById('textStatsCount').textContent = config.textStats;
|
| 75 |
-
}
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
// Initialize Twilio device if token exists
|
| 79 |
-
const twilioSettings = localStorage.getItem('twilioSettings');
|
| 80 |
-
if (twilioSettings) {
|
| 81 |
-
const { token } = JSON.parse(twilioSettings);
|
| 82 |
-
initializeTwilioDevice(token);
|
| 83 |
-
}
|
| 84 |
-
});
|
| 85 |
-
|
| 86 |
-
function formatPhoneNumber(phoneNumberString) {
|
| 87 |
-
// Format phone number for display
|
| 88 |
-
const cleaned = ('' + phoneNumberString).replace(/\D/g, '');
|
| 89 |
-
const match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/);
|
| 90 |
-
if (match) {
|
| 91 |
-
return ['(', match[2], ') ', match[3], '-', match[4]].join('');
|
| 92 |
-
}
|
| 93 |
-
return phoneNumberString;
|
| 94 |
-
}
|
| 95 |
=======
|
| 96 |
|
| 97 |
|
|
@@ -194,8 +195,20 @@
|
|
| 194 |
<header class="flex justify-between items-center mb-6">
|
| 195 |
<h1 class="text-2xl font-bold bg-gradient-to-r from-blue-600 to-violet-600 bg-clip-text text-transparent">Call AI Pro</h1>
|
| 196 |
<div class="flex items-center space-x-3">
|
| 197 |
-
<
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
</div>
|
| 200 |
</header>
|
| 201 |
|
|
@@ -451,7 +464,7 @@
|
|
| 451 |
<div id="jitsi-container" style="display: none;"></div>
|
| 452 |
|
| 453 |
<!-- Training Modal -->
|
| 454 |
-
<div id="trainingModal" class="
|
| 455 |
<div class="bg-white rounded-xl shadow-xl w-full max-w-md max-h-screen overflow-y-auto">
|
| 456 |
<div class="p-6">
|
| 457 |
<div class="flex justify-between items-center mb-4">
|
|
@@ -567,7 +580,7 @@ You: Your order will ship within 24 hours and typically arrives in 2-3 business
|
|
| 567 |
</div>
|
| 568 |
|
| 569 |
<!-- Settings Modal -->
|
| 570 |
-
<div id="settingsModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 hidden">
|
| 571 |
<div class="bg-white rounded-xl shadow-xl w-full max-w-md max-h-screen overflow-y-auto">
|
| 572 |
<div class="p-6">
|
| 573 |
<div class="flex justify-between items-center mb-4">
|
|
@@ -664,143 +677,6 @@ You: Your order will ship within 24 hours and typically arrives in 2-3 business
|
|
| 664 |
</div>
|
| 665 |
|
| 666 |
<script>
|
| 667 |
-
// Twilio Client Setup
|
| 668 |
-
const twilioDevice = new Twilio.Device();
|
| 669 |
-
let activeConnection = null;
|
| 670 |
-
let currentCallSid = null;
|
| 671 |
-
|
| 672 |
-
// Initialize Twilio device
|
| 673 |
-
function initializeTwilioDevice(token) {
|
| 674 |
-
twilioDevice.setup(token, {
|
| 675 |
-
closeProtection: true,
|
| 676 |
-
logLevel: 1,
|
| 677 |
-
codecPreferences: ['opus', 'pcmu']
|
| 678 |
-
});
|
| 679 |
-
|
| 680 |
-
twilioDevice.on('ready', () => {
|
| 681 |
-
updateConnectionStatus('Connected', 'green-500');
|
| 682 |
-
});
|
| 683 |
-
|
| 684 |
-
twilioDevice.on('error', (error) => {
|
| 685 |
-
updateConnectionStatus(`Error: ${error.message}`, 'red-500');
|
| 686 |
-
});
|
| 687 |
-
|
| 688 |
-
twilioDevice.on('disconnect', () => {
|
| 689 |
-
updateConnectionStatus('Disconnected', 'red-500');
|
| 690 |
-
});
|
| 691 |
-
|
| 692 |
-
// Incoming call handling
|
| 693 |
-
twilioDevice.on('incoming', (connection) => {
|
| 694 |
-
incomingCall(connection);
|
| 695 |
-
});
|
| 696 |
-
}
|
| 697 |
-
|
| 698 |
-
function updateConnectionStatus(text, color) {
|
| 699 |
-
const statusEl = document.getElementById('twilioStatus');
|
| 700 |
-
const iconEl = document.getElementById('connectionStatusIcon');
|
| 701 |
-
const textEl = document.getElementById('connectionStatusText');
|
| 702 |
-
|
| 703 |
-
statusEl.classList.remove('hidden');
|
| 704 |
-
textEl.textContent = text;
|
| 705 |
-
iconEl.className = `fas fa-circle text-${color} mr-2`;
|
| 706 |
-
}
|
| 707 |
-
|
| 708 |
-
function incomingCall(connection) {
|
| 709 |
-
activeConnection = connection;
|
| 710 |
-
currentCallSid = connection.parameters.CallSid;
|
| 711 |
-
|
| 712 |
-
// Show incoming call UI
|
| 713 |
-
const callModal = document.createElement('div');
|
| 714 |
-
callModal.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50';
|
| 715 |
-
callModal.innerHTML = `
|
| 716 |
-
<div class="bg-white rounded-xl shadow-lg w-full max-w-sm">
|
| 717 |
-
<div class="p-6">
|
| 718 |
-
<div class="text-center mb-4">
|
| 719 |
-
<div class="call-animation mx-auto mb-4"></div>
|
| 720 |
-
<h3 class="text-lg font-medium text-gray-900">Incoming Call</h3>
|
| 721 |
-
<p class="text-sm text-gray-500">From: ${connection.parameters.From}</p>
|
| 722 |
-
</div>
|
| 723 |
-
|
| 724 |
-
<div class="grid grid-cols-2 gap-2">
|
| 725 |
-
<button id="answerBtn" class="py-3 bg-green-500 hover:bg-green-600 text-white rounded-lg">
|
| 726 |
-
<i class="fas fa-phone"></i> Answer
|
| 727 |
-
</button>
|
| 728 |
-
<button id="declineBtn" class="py-3 bg-red-500 hover:bg-red-600 text-white rounded-lg">
|
| 729 |
-
<i class="fas fa-phone-slash"></i> Decline
|
| 730 |
-
</button>
|
| 731 |
-
</div>
|
| 732 |
-
</div>
|
| 733 |
-
</div>
|
| 734 |
-
`;
|
| 735 |
-
|
| 736 |
-
document.body.appendChild(callModal);
|
| 737 |
-
|
| 738 |
-
// Set up button handlers
|
| 739 |
-
document.getElementById('answerBtn').addEventListener('click', () => {
|
| 740 |
-
connection.accept();
|
| 741 |
-
setupActiveCallUI(connection);
|
| 742 |
-
document.body.removeChild(callModal);
|
| 743 |
-
});
|
| 744 |
-
|
| 745 |
-
document.getElementById('declineBtn').addEventListener('click', () => {
|
| 746 |
-
connection.reject();
|
| 747 |
-
document.body.removeChild(callModal);
|
| 748 |
-
addToCallLog('Missed call from ' + connection.parameters.From);
|
| 749 |
-
});
|
| 750 |
-
}
|
| 751 |
-
|
| 752 |
-
function setupActiveCallUI(connection) {
|
| 753 |
-
const callUI = document.createElement('div');
|
| 754 |
-
callUI.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50';
|
| 755 |
-
callUI.innerHTML = `
|
| 756 |
-
<div class="bg-white rounded-xl shadow-lg w-full max-w-sm">
|
| 757 |
-
<div class="p-6">
|
| 758 |
-
<div class="text-center mb-4">
|
| 759 |
-
<h3 class="text-lg font-medium text-gray-900">Ongoing Call</h3>
|
| 760 |
-
<p class="text-sm text-gray-500" id="callStatus">Connected</p>
|
| 761 |
-
<p class="text-sm text-gray-500" id="callNumber">${connection.parameters.From}</p>
|
| 762 |
-
</div>
|
| 763 |
-
|
| 764 |
-
<div class="grid grid-cols-3 gap-2">
|
| 765 |
-
<button id="muteBtn" class="py-3 bg-gray-100 hover:bg-gray-200 rounded-lg">
|
| 766 |
-
<i class="fas fa-microphone"></i>
|
| 767 |
-
</button>
|
| 768 |
-
<button id="holdBtn" class="py-3 bg-gray-100 hover:bg-gray-200 rounded-lg">
|
| 769 |
-
<i class="fas fa-pause"></i>
|
| 770 |
-
</button>
|
| 771 |
-
<button id="endBtn" class="py-3 bg-red-500 hover:bg-red-600 text-white rounded-lg">
|
| 772 |
-
<i class="fas fa-phone-slash"></i>
|
| 773 |
-
</button>
|
| 774 |
-
</div>
|
| 775 |
-
</div>
|
| 776 |
-
</div>
|
| 777 |
-
`;
|
| 778 |
-
|
| 779 |
-
document.body.appendChild(callUI);
|
| 780 |
-
|
| 781 |
-
// Set up button handlers
|
| 782 |
-
document.getElementById('endBtn').addEventListener('click', () => {
|
| 783 |
-
connection.disconnect();
|
| 784 |
-
document.body.removeChild(callUI);
|
| 785 |
-
addToCallLog('Call with ' + connection.parameters.From + ' ended');
|
| 786 |
-
});
|
| 787 |
-
|
| 788 |
-
document.getElementById('muteBtn').addEventListener('click', (e) => {
|
| 789 |
-
if (connection.isMuted()) {
|
| 790 |
-
connection.mute(false);
|
| 791 |
-
e.target.classList.remove('bg-gray-200');
|
| 792 |
-
} else {
|
| 793 |
-
connection.mute(true);
|
| 794 |
-
e.target.classList.add('bg-gray-200');
|
| 795 |
-
}
|
| 796 |
-
});
|
| 797 |
-
|
| 798 |
-
connection.on('disconnect', () => {
|
| 799 |
-
if (document.body.contains(callUI)) {
|
| 800 |
-
document.body.removeChild(callUI);
|
| 801 |
-
}
|
| 802 |
-
});
|
| 803 |
-
}
|
| 804 |
|
| 805 |
function addToCallLog(entry) {
|
| 806 |
const callLog = document.querySelector('.space-y-3.max-h-60');
|
|
@@ -823,71 +699,6 @@ You: Your order will ship within 24 hours and typically arrives in 2-3 business
|
|
| 823 |
}
|
| 824 |
|
| 825 |
|
| 826 |
-
// Client Setup
|
| 827 |
-
let jitsiClient;
|
| 828 |
-
let callSocket;
|
| 829 |
-
let trillionClient = null;
|
| 830 |
-
|
| 831 |
-
async function initializeJitsiClient() {
|
| 832 |
-
try {
|
| 833 |
-
// Initialize Jitsi Meet API client
|
| 834 |
-
jitsiClient = {
|
| 835 |
-
makeCall: async (options) => {
|
| 836 |
-
return new Promise((resolve) => {
|
| 837 |
-
console.log('Initiating Jitsi call to:', options.to);
|
| 838 |
-
const domain = 'meet.jit.si';
|
| 839 |
-
const options = {
|
| 840 |
-
roomName: `call-${Date.now()}`,
|
| 841 |
-
parentNode: document.querySelector('#jitsi-container'),
|
| 842 |
-
userInfo: {
|
| 843 |
-
displayName: 'AI Call Manager'
|
| 844 |
-
}
|
| 845 |
-
};
|
| 846 |
-
|
| 847 |
-
// Create Jitsi Meet API instance
|
| 848 |
-
const api = new JitsiMeetExternalAPI(domain, options);
|
| 849 |
-
|
| 850 |
-
setTimeout(() => resolve({id: `jitsi-${Date.now()}`, api}), 1000);
|
| 851 |
-
});
|
| 852 |
-
}
|
| 853 |
-
};
|
| 854 |
-
|
| 855 |
-
// Use a simple WebSocket connection (you would replace with your own endpoint)
|
| 856 |
-
callSocket = new WebSocket('wss://realtime.trillion.ventures/ws');
|
| 857 |
-
setTimeout(() => {
|
| 858 |
-
if (callSocket.onopen) callSocket.onopen();
|
| 859 |
-
}, 500);
|
| 860 |
-
callSocket.onopen = () => {
|
| 861 |
-
console.log('Connected to Trillion real-time service');
|
| 862 |
-
callSocket.send(JSON.stringify({
|
| 863 |
-
type: 'authenticate',
|
| 864 |
-
token: authToken
|
| 865 |
-
}));
|
| 866 |
-
};
|
| 867 |
-
callSocket.onmessage = handleSocketMessage;
|
| 868 |
-
callSocket.onclose = () => console.log('Disconnected from real-time service');
|
| 869 |
-
|
| 870 |
-
return true;
|
| 871 |
-
} catch (error) {
|
| 872 |
-
console.error("Failed to initialize Trillion client:", error);
|
| 873 |
-
return false;
|
| 874 |
-
}
|
| 875 |
-
}
|
| 876 |
-
|
| 877 |
-
function handleSocketMessage(event) {
|
| 878 |
-
const data = JSON.parse(event.data);
|
| 879 |
-
switch(data.type) {
|
| 880 |
-
case 'call_update':
|
| 881 |
-
updateCallUI(data.status, data.transcript);
|
| 882 |
-
break;
|
| 883 |
-
case 'message':
|
| 884 |
-
console.log("New message:", data.content);
|
| 885 |
-
break;
|
| 886 |
-
case 'call_ended':
|
| 887 |
-
endCallUI(data.callId);
|
| 888 |
-
break;
|
| 889 |
-
}
|
| 890 |
-
}
|
| 891 |
|
| 892 |
async function sendSMS(to, message) {
|
| 893 |
try {
|
|
@@ -1117,11 +928,185 @@ You: Your order will ship within 24 hours and typically arrives in 2-3 business
|
|
| 1117 |
});
|
| 1118 |
|
| 1119 |
=======
|
| 1120 |
-
//
|
| 1121 |
-
function
|
| 1122 |
-
//
|
| 1123 |
-
|
| 1124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1125 |
}
|
| 1126 |
|
| 1127 |
// Training sections
|
|
@@ -1295,19 +1280,6 @@ Or contact support at help@trillion.ventures`);
|
|
| 1295 |
|
| 1296 |
// Rest of DOMContentLoaded...
|
| 1297 |
=======
|
| 1298 |
-
const savedSettings = localStorage.getItem('aiCallSettings');
|
| 1299 |
-
if (savedSettings) {
|
| 1300 |
-
const config = JSON.parse(savedSettings);
|
| 1301 |
-
|
| 1302 |
-
// Update phone number displays
|
| 1303 |
-
document.querySelectorAll('.phone-number-display').forEach(el => {
|
| 1304 |
-
el.textContent = config.twilioNum || config.phoneNum || '+1 (858) 263-4276';
|
| 1305 |
-
});
|
| 1306 |
-
|
| 1307 |
-
// Update stats section with saved data
|
| 1308 |
-
document.querySelector('#callStatsCount').textContent = localStorage.getItem('callStats') || '128';
|
| 1309 |
-
document.querySelector('#textStatsCount').textContent = localStorage.getItem('textStats') || '342';
|
| 1310 |
-
}
|
| 1311 |
});
|
| 1312 |
|
| 1313 |
// Function to update call UI with real data
|
|
|
|
| 1 |
|
| 2 |
+
<script>
|
| 3 |
+
// Initialize DOM elements after page loads
|
| 4 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 5 |
+
// Set up modals
|
| 6 |
+
const setupModal = (modalId, openBtnId, closeBtnId) => {
|
| 7 |
+
const modal = document.getElementById(modalId);
|
| 8 |
+
const openBtn = document.getElementById(openBtnId);
|
| 9 |
+
const closeBtn = document.getElementById(closeBtnId);
|
| 10 |
+
|
| 11 |
+
if (openBtn) openBtn.addEventListener('click', () => modal.classList.remove('hidden'));
|
| 12 |
+
if (closeBtn) closeBtn.addEventListener('click', () => modal.classList.add('hidden'));
|
| 13 |
+
|
| 14 |
+
// Close when clicking outside modal content
|
| 15 |
+
modal.addEventListener('click', (e) => {
|
| 16 |
+
if (e.target === modal) modal.classList.add('hidden');
|
| 17 |
+
});
|
| 18 |
+
};
|
| 19 |
+
|
| 20 |
+
setupModal('trainingModal', 'trainBtn', 'closeTraining');
|
| 21 |
+
setupModal('settingsModal', 'settingsBtn', 'closeSettings');
|
| 22 |
+
|
| 23 |
+
// Format phone numbers on page
|
| 24 |
+
document.querySelectorAll('.phone-number-display').forEach(el => {
|
| 25 |
+
const formatNumber = (num) => {
|
| 26 |
+
const cleaned = ('' + num).replace(/\D/g, '');
|
| 27 |
+
const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/);
|
| 28 |
+
return match ? `(${match[1]}) ${match[2]}-${match[3]}` : num;
|
| 29 |
+
};
|
| 30 |
+
el.textContent = formatNumber(el.textContent.trim());
|
| 31 |
+
});
|
| 32 |
+
});
|
| 33 |
+
</script>
|
| 34 |
+
|
| 35 |
+
|
| 36 |
|
| 37 |
|
| 38 |
|
|
|
|
| 42 |
|
| 43 |
<!DOCTYPE html>
|
| 44 |
<html lang="en">
|
| 45 |
+
<head>
|
| 46 |
+
<meta charset="UTF-8">
|
| 47 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 48 |
+
<title>AI Call Manager</title>
|
| 49 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 50 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 51 |
+
<!-- Load Twilio Client directly from CDN -->
|
| 52 |
+
<script src="https://sdk.twilio.com/js/client/releases/1.14.0/twilio.min.js"></script>
|
| 53 |
+
<style>
|
| 54 |
+
.call-animation {
|
| 55 |
+
animation: pulse 1.5s infinite;
|
| 56 |
+
}
|
| 57 |
+
@keyframes pulse {
|
| 58 |
+
0% { transform: scale(0.95); opacity: 0.7; }
|
| 59 |
+
70% { transform: scale(1.1); opacity: 0.3; }
|
| 60 |
+
100% { transform: scale(0.95); opacity: 0.7; }
|
| 61 |
+
}
|
| 62 |
+
</style>
|
| 63 |
+
</head>
|
| 64 |
=======
|
| 65 |
|
| 66 |
|
|
|
|
| 93 |
=======
|
| 94 |
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
=======
|
| 97 |
|
| 98 |
|
|
|
|
| 195 |
<header class="flex justify-between items-center mb-6">
|
| 196 |
<h1 class="text-2xl font-bold bg-gradient-to-r from-blue-600 to-violet-600 bg-clip-text text-transparent">Call AI Pro</h1>
|
| 197 |
<div class="flex items-center space-x-3">
|
| 198 |
+
<button id="initTwilioBtn" class="text-sm bg-blue-100 hover:bg-blue-200 text-blue-800 px-3 py-1 rounded-lg transition-all duration-300 border border-transparent">
|
| 199 |
+
<i class="fas fa-phone mr-1"></i>
|
| 200 |
+
<span>Init Twilio</span>
|
| 201 |
+
</button>
|
| 202 |
+
<button id="settingsBtn" class="text-sm bg-purple-100 hover:bg-purple-200 text-purple-800 px-3 py-1 rounded-lg">
|
| 203 |
+
<i class="fas fa-cog mr-1"></i> Settings
|
| 204 |
+
</button>
|
| 205 |
+
<button id="trainBtn" class="text-sm bg-green-100 hover:bg-green-200 text-green-800 px-3 py-1 rounded-lg">
|
| 206 |
+
<i class="fas fa-brain mr-1"></i> Train
|
| 207 |
+
</button>
|
| 208 |
+
<div id="connectionStatus" class="flex items-center hidden">
|
| 209 |
+
<i id="connectionStatusIcon" class="fas fa-circle text-gray-500 mr-2"></i>
|
| 210 |
+
<span id="connectionStatusText" class="text-sm font-medium text-gray-500">Not connected</span>
|
| 211 |
+
</div>
|
| 212 |
</div>
|
| 213 |
</header>
|
| 214 |
|
|
|
|
| 464 |
<div id="jitsi-container" style="display: none;"></div>
|
| 465 |
|
| 466 |
<!-- Training Modal -->
|
| 467 |
+
<div id="trainingModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 hidden z-50">
|
| 468 |
<div class="bg-white rounded-xl shadow-xl w-full max-w-md max-h-screen overflow-y-auto">
|
| 469 |
<div class="p-6">
|
| 470 |
<div class="flex justify-between items-center mb-4">
|
|
|
|
| 580 |
</div>
|
| 581 |
|
| 582 |
<!-- Settings Modal -->
|
| 583 |
+
<div id="settingsModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 hidden z-50">
|
| 584 |
<div class="bg-white rounded-xl shadow-xl w-full max-w-md max-h-screen overflow-y-auto">
|
| 585 |
<div class="p-6">
|
| 586 |
<div class="flex justify-between items-center mb-4">
|
|
|
|
| 677 |
</div>
|
| 678 |
|
| 679 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 680 |
|
| 681 |
function addToCallLog(entry) {
|
| 682 |
const callLog = document.querySelector('.space-y-3.max-h-60');
|
|
|
|
| 699 |
}
|
| 700 |
|
| 701 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 702 |
|
| 703 |
async function sendSMS(to, message) {
|
| 704 |
try {
|
|
|
|
| 928 |
});
|
| 929 |
|
| 930 |
=======
|
| 931 |
+
// Initialize all button handlers after DOM loads
|
| 932 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 933 |
+
// Enhanced Twilio init button
|
| 934 |
+
document.getElementById('initTwilioBtn').addEventListener('click', async function() {
|
| 935 |
+
try {
|
| 936 |
+
this.disabled = true;
|
| 937 |
+
const btnText = this.querySelector('span');
|
| 938 |
+
const originalText = btnText.textContent;
|
| 939 |
+
btnText.textContent = 'Initializing...';
|
| 940 |
+
|
| 941 |
+
if (typeof Twilio === 'undefined') {
|
| 942 |
+
throw new Error('Twilio SDK not loaded');
|
| 943 |
+
}
|
| 944 |
+
|
| 945 |
+
const twilioSettings = localStorage.getItem('twilioSettings');
|
| 946 |
+
if (!twilioSettings) {
|
| 947 |
+
throw new Error('Twilio settings not configured');
|
| 948 |
+
}
|
| 949 |
+
|
| 950 |
+
const { token } = JSON.parse(twilioSettings);
|
| 951 |
+
|
| 952 |
+
// Visual feedback
|
| 953 |
+
this.classList.remove('bg-blue-100', 'hover:bg-blue-200');
|
| 954 |
+
this.classList.add('bg-blue-200', 'animate-pulse');
|
| 955 |
+
|
| 956 |
+
// Initialize with timeout
|
| 957 |
+
await Promise.race([
|
| 958 |
+
initializeTwilioDevice(token),
|
| 959 |
+
new Promise((_, reject) =>
|
| 960 |
+
setTimeout(() => reject(new Error('Connection timeout')), 10000)
|
| 961 |
+
)
|
| 962 |
+
]);
|
| 963 |
+
|
| 964 |
+
// Update UI on success
|
| 965 |
+
this.classList.remove('bg-blue-200', 'animate-pulse');
|
| 966 |
+
this.classList.add('bg-green-100', 'border-green-300');
|
| 967 |
+
btnText.textContent = 'Connected';
|
| 968 |
+
updateConnectionStatus('Connected', 'fas fa-check-circle text-green-600');
|
| 969 |
+
|
| 970 |
+
} catch (error) {
|
| 971 |
+
console.error('Twilio init failed:', error);
|
| 972 |
+
this.classList.remove('bg-blue-200', 'animate-pulse');
|
| 973 |
+
this.classList.add('bg-red-100', 'border-red-300');
|
| 974 |
+
this.querySelector('span').textContent = 'Failed!';
|
| 975 |
+
updateConnectionStatus('Failed', 'fas fa-times-circle text-red-600');
|
| 976 |
+
|
| 977 |
+
// Show settings modal if no credentials
|
| 978 |
+
if (error.message.includes('not configured')) {
|
| 979 |
+
document.getElementById('settingsBtn').click();
|
| 980 |
+
}
|
| 981 |
+
} finally {
|
| 982 |
+
setTimeout(() => {
|
| 983 |
+
this.disabled = false;
|
| 984 |
+
this.querySelector('span').textContent = 'Init Twilio';
|
| 985 |
+
this.classList.remove('bg-red-100', 'border-red-300');
|
| 986 |
+
}, 3000);
|
| 987 |
+
}
|
| 988 |
+
});
|
| 989 |
+
|
| 990 |
+
function updateConnectionStatus(text, iconClass) {
|
| 991 |
+
const statusElement = document.getElementById('connectionStatus');
|
| 992 |
+
const iconElement = document.getElementById('connectionStatusIcon');
|
| 993 |
+
const textElement = document.getElementById('connectionStatusText');
|
| 994 |
+
|
| 995 |
+
statusElement.classList.remove('hidden');
|
| 996 |
+
iconElement.className = iconClass;
|
| 997 |
+
textElement.textContent = text;
|
| 998 |
+
}
|
| 999 |
+
|
| 1000 |
+
// Modal close handlers
|
| 1001 |
+
document.getElementById('closeTraining').addEventListener('click', () => {
|
| 1002 |
+
document.getElementById('trainingModal').classList.add('hidden');
|
| 1003 |
+
});
|
| 1004 |
+
|
| 1005 |
+
document.getElementById('closeSettings').addEventListener('click', () => {
|
| 1006 |
+
document.getElementById('settingsModal').classList.add('hidden');
|
| 1007 |
+
});
|
| 1008 |
+
|
| 1009 |
+
// Training mode buttons
|
| 1010 |
+
document.querySelectorAll('.trainingModeBtn').forEach(btn => {
|
| 1011 |
+
btn.addEventListener('click', function() {
|
| 1012 |
+
const mode = this.dataset.mode;
|
| 1013 |
+
document.querySelectorAll('.trainingSection').forEach(s =>
|
| 1014 |
+
s.classList.add('hidden')
|
| 1015 |
+
);
|
| 1016 |
+
document.getElementById(`${mode}Training`).classList.remove('hidden');
|
| 1017 |
+
|
| 1018 |
+
// Update active button style
|
| 1019 |
+
document.querySelectorAll('.trainingModeBtn').forEach(b =>
|
| 1020 |
+
b.classList.remove('bg-purple-100', 'border-purple-300', 'text-purple-800')
|
| 1021 |
+
);
|
| 1022 |
+
this.classList.add('bg-purple-100', 'border-purple-300', 'text-purple-800');
|
| 1023 |
+
});
|
| 1024 |
+
});
|
| 1025 |
+
|
| 1026 |
+
// Call purpose toggle
|
| 1027 |
+
document.getElementById('callPurpose').addEventListener('change', function() {
|
| 1028 |
+
document.getElementById('trainingOptions').style.display =
|
| 1029 |
+
this.value === 'training' ? 'block' : 'none';
|
| 1030 |
+
});
|
| 1031 |
+
});
|
| 1032 |
+
|
| 1033 |
+
document.getElementById('initSettingsBtn').addEventListener('click', function() {
|
| 1034 |
+
const savedSettings = localStorage.getItem('aiCallSettings');
|
| 1035 |
+
if (savedSettings) {
|
| 1036 |
+
const config = JSON.parse(savedSettings);
|
| 1037 |
+
|
| 1038 |
+
document.querySelectorAll('.phone-number-display').forEach(el => {
|
| 1039 |
+
el.textContent = formatPhoneNumber(config.phoneNumber);
|
| 1040 |
+
});
|
| 1041 |
+
|
| 1042 |
+
if (config.callStats) {
|
| 1043 |
+
document.getElementById('callStatsCount').textContent = config.callStats;
|
| 1044 |
+
}
|
| 1045 |
+
if (config.textStats) {
|
| 1046 |
+
document.getElementById('textStatsCount').textContent = config.textStats;
|
| 1047 |
+
}
|
| 1048 |
+
alert('Settings loaded successfully');
|
| 1049 |
+
} else {
|
| 1050 |
+
alert('No saved settings found');
|
| 1051 |
+
}
|
| 1052 |
+
});
|
| 1053 |
+
|
| 1054 |
+
// Initialize Twilio Device
|
| 1055 |
+
let twilioDevice = null;
|
| 1056 |
+
|
| 1057 |
+
function initializeTwilioDevice(token) {
|
| 1058 |
+
return new Promise((resolve, reject) => {
|
| 1059 |
+
try {
|
| 1060 |
+
// Setup Twilio Device
|
| 1061 |
+
twilioDevice = new Twilio.Device(token, {
|
| 1062 |
+
codecPreferences: ['opus', 'pcmu'],
|
| 1063 |
+
fakeLocalDTMF: true,
|
| 1064 |
+
enableRingingState: true,
|
| 1065 |
+
});
|
| 1066 |
+
|
| 1067 |
+
// Setup event handlers
|
| 1068 |
+
twilioDevice.on('ready', (device) => {
|
| 1069 |
+
console.log('Twilio device ready');
|
| 1070 |
+
resolve();
|
| 1071 |
+
});
|
| 1072 |
+
|
| 1073 |
+
twilioDevice.on('error', (error) => {
|
| 1074 |
+
console.error('Twilio device error:', error);
|
| 1075 |
+
reject(error);
|
| 1076 |
+
});
|
| 1077 |
+
|
| 1078 |
+
twilioDevice.on('disconnect', (conn) => {
|
| 1079 |
+
console.log('Call ended');
|
| 1080 |
+
updateCallUI('Disconnected', 'Call ended');
|
| 1081 |
+
});
|
| 1082 |
+
|
| 1083 |
+
// Set up incoming call handler
|
| 1084 |
+
twilioDevice.on('incoming', (conn) => {
|
| 1085 |
+
const callerId = conn.parameters.From;
|
| 1086 |
+
console.log('Incoming call from:', callerId);
|
| 1087 |
+
|
| 1088 |
+
// Show call interface
|
| 1089 |
+
const isTraining = confirm('Is this a training call?');
|
| 1090 |
+
showCallInterface(
|
| 1091 |
+
callerId,
|
| 1092 |
+
isTraining,
|
| 1093 |
+
isTraining ? 'conversation' : null,
|
| 1094 |
+
conn.parameters.CallSid
|
| 1095 |
+
);
|
| 1096 |
+
|
| 1097 |
+
// Auto-answer after delay
|
| 1098 |
+
const delay = parseInt(document.getElementById('callDelay').value) * 1000 || 30000;
|
| 1099 |
+
setTimeout(() => {
|
| 1100 |
+
conn.accept();
|
| 1101 |
+
updateCallUI('In Progress', `Connected with ${callerId}`);
|
| 1102 |
+
}, delay);
|
| 1103 |
+
});
|
| 1104 |
+
|
| 1105 |
+
twilioDevice.register();
|
| 1106 |
+
} catch (error) {
|
| 1107 |
+
reject(error);
|
| 1108 |
+
}
|
| 1109 |
+
});
|
| 1110 |
}
|
| 1111 |
|
| 1112 |
// Training sections
|
|
|
|
| 1280 |
|
| 1281 |
// Rest of DOMContentLoaded...
|
| 1282 |
=======
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1283 |
});
|
| 1284 |
|
| 1285 |
// Function to update call UI with real data
|
prompts.txt
CHANGED
|
@@ -10,4 +10,15 @@ Buttons are still broken. Remove every broken code and rework until
|
|
| 10 |
Buttons are still broken. Remove every broken code and rework until it does work. I
|
| 11 |
Remove everyone that is causing errors
|
| 12 |
Now reinstall scripts applications everything needed for this to work but remove the buttons .
|
| 13 |
-
Recode ui update all
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
Buttons are still broken. Remove every broken code and rework until it does work. I
|
| 11 |
Remove everyone that is causing errors
|
| 12 |
Now reinstall scripts applications everything needed for this to work but remove the buttons .
|
| 13 |
+
Recode ui update all
|
| 14 |
+
The whole app is now broken can you please recode with no errors insure everything is functioning and not just a simulation but a working application
|
| 15 |
+
Remove the initializing when app
|
| 16 |
+
Remove the initializing when app open but instead create working buttons that do the same thing
|
| 17 |
+
Something is still wrong because when I click the buttons you made nothing opens
|
| 18 |
+
Pass the code and figure out why the buttons are not working
|
| 19 |
+
Remove broken codes and scripts and install new . Remove everying that initializes as app opens
|
| 20 |
+
Remove broken codes and scripts and install new . Remove everying that initializes as app opens
|
| 21 |
+
The init twilio still isn’t functioning and needs to be fixed
|
| 22 |
+
Twilio client script still not working
|
| 23 |
+
Twilio client script still not working
|
| 24 |
+
Twilio client script still not working
|