ttp-agent-sdk 2.34.14 → 2.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ENHANCED_WIDGET_GUIDE.md +5 -32
- package/GETTING_STARTED.md +20 -73
- package/README.md +14 -38
- package/WORDPRESS_WIX_GUIDE.md +8 -18
- package/dist/agent-widget.dev.js +680 -307
- package/dist/agent-widget.dev.js.map +1 -1
- package/dist/agent-widget.esm.js +1 -1
- package/dist/agent-widget.esm.js.map +1 -1
- package/dist/agent-widget.js +1 -1
- package/dist/agent-widget.js.map +1 -1
- package/dist/examples/test-text-chat.html +2 -26
- package/dist/index.html +169 -439
- package/examples/test-text-chat.html +2 -26
- package/package.json +2 -2
- package/SIGNED_LINK_GUIDE.md +0 -249
- package/dist/examples/test-signed-link.html +0 -503
- package/examples/test-signed-link.html +0 -503
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
|
6
|
-
<title>Voice Agent Widget - Signed Link Test</title>
|
|
7
|
-
<style>
|
|
8
|
-
body {
|
|
9
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
10
|
-
max-width: 800px;
|
|
11
|
-
margin: 40px auto;
|
|
12
|
-
padding: 20px;
|
|
13
|
-
background: #F9FAFB;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.container {
|
|
17
|
-
background: white;
|
|
18
|
-
padding: 30px;
|
|
19
|
-
border-radius: 12px;
|
|
20
|
-
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
h1 {
|
|
24
|
-
color: #111827;
|
|
25
|
-
margin-top: 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.info {
|
|
29
|
-
background: #EFF6FF;
|
|
30
|
-
border-left: 4px solid #3B82F6;
|
|
31
|
-
padding: 16px;
|
|
32
|
-
margin: 20px 0;
|
|
33
|
-
border-radius: 4px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.config-info {
|
|
37
|
-
background: #FEF3C7;
|
|
38
|
-
border-left: 4px solid #F59E0B;
|
|
39
|
-
padding: 16px;
|
|
40
|
-
margin: 20px 0;
|
|
41
|
-
border-radius: 4px;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.status {
|
|
45
|
-
margin: 20px 0;
|
|
46
|
-
padding: 12px;
|
|
47
|
-
background: #F3F4F6;
|
|
48
|
-
border-radius: 6px;
|
|
49
|
-
font-family: monospace;
|
|
50
|
-
font-size: 14px;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.status.success {
|
|
54
|
-
background: #D1FAE5;
|
|
55
|
-
color: #065F46;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.status.error {
|
|
59
|
-
background: #FEE2E2;
|
|
60
|
-
color: #991B1B;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
button {
|
|
64
|
-
background: #4F46E5;
|
|
65
|
-
color: white;
|
|
66
|
-
border: none;
|
|
67
|
-
padding: 12px 24px;
|
|
68
|
-
border-radius: 6px;
|
|
69
|
-
cursor: pointer;
|
|
70
|
-
font-size: 16px;
|
|
71
|
-
margin: 10px 10px 10px 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
button:hover {
|
|
75
|
-
background: #4338CA;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.code-block {
|
|
79
|
-
background: #1F2937;
|
|
80
|
-
color: #F9FAFB;
|
|
81
|
-
padding: 16px;
|
|
82
|
-
border-radius: 6px;
|
|
83
|
-
font-family: monospace;
|
|
84
|
-
font-size: 12px;
|
|
85
|
-
overflow-x: auto;
|
|
86
|
-
margin: 20px 0;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.api-info {
|
|
90
|
-
background: #F0FDF4;
|
|
91
|
-
border-left: 4px solid #10B981;
|
|
92
|
-
padding: 16px;
|
|
93
|
-
margin: 20px 0;
|
|
94
|
-
border-radius: 4px;
|
|
95
|
-
}
|
|
96
|
-
</style>
|
|
97
|
-
</head>
|
|
98
|
-
<body>
|
|
99
|
-
<div class="container">
|
|
100
|
-
<h1>🎤 Voice Agent Widget - Signed Link Test</h1>
|
|
101
|
-
|
|
102
|
-
<div class="config-info">
|
|
103
|
-
<strong>📝 Configuration:</strong>
|
|
104
|
-
<ul style="margin: 10px 0 0 20px; line-height: 1.8;">
|
|
105
|
-
<li><strong>Agent ID:</strong> agent_87c4a55a1</li>
|
|
106
|
-
<li><strong>App ID:</strong> app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC</li>
|
|
107
|
-
<li><strong>Method:</strong> Signed link via backend API</li>
|
|
108
|
-
</ul>
|
|
109
|
-
</div>
|
|
110
|
-
|
|
111
|
-
<div class="api-info">
|
|
112
|
-
<strong>🔗 Backend API:</strong>
|
|
113
|
-
<ul style="margin: 10px 0 0 20px; line-height: 1.8;">
|
|
114
|
-
<li><strong>Endpoint:</strong> https://backend.talktopc.com/api/public/agents/signed-url</li>
|
|
115
|
-
<li><strong>Method:</strong> POST</li>
|
|
116
|
-
<li><strong>Purpose:</strong> Generate signed WebSocket URL for secure connection</li>
|
|
117
|
-
</ul>
|
|
118
|
-
</div>
|
|
119
|
-
|
|
120
|
-
<div class="info">
|
|
121
|
-
<strong>📝 Testing Instructions:</strong>
|
|
122
|
-
<ol style="margin: 10px 0 0 20px; line-height: 1.8;">
|
|
123
|
-
<li>Look for the floating voice button in the bottom-right corner</li>
|
|
124
|
-
<li>Click the button to open the widget</li>
|
|
125
|
-
<li>Widget will request signed URL from backend API</li>
|
|
126
|
-
<li>Click the microphone to start (will request mic permission)</li>
|
|
127
|
-
<li>Widget will connect using the signed WebSocket URL</li>
|
|
128
|
-
<li>Check the status updates below</li>
|
|
129
|
-
</ol>
|
|
130
|
-
</div>
|
|
131
|
-
|
|
132
|
-
<h2>Widget Status:</h2>
|
|
133
|
-
<div id="status" class="status">
|
|
134
|
-
Waiting for widget to load...
|
|
135
|
-
</div>
|
|
136
|
-
|
|
137
|
-
<h2>Console Log:</h2>
|
|
138
|
-
<div id="log" style="background: #1F2937; color: #F9FAFB; padding: 16px; border-radius: 6px; font-family: monospace; font-size: 12px; max-height: 300px; overflow-y: auto;">
|
|
139
|
-
Console messages will appear here...
|
|
140
|
-
</div>
|
|
141
|
-
|
|
142
|
-
<h2>Implementation Code:</h2>
|
|
143
|
-
<div class="code-block">
|
|
144
|
-
// Step 1: Get signed URL from backend
|
|
145
|
-
async function initializeWidget() {
|
|
146
|
-
const response = await fetch('https://backend.talktopc.com/api/public/agents/signed-url', {
|
|
147
|
-
method: 'POST',
|
|
148
|
-
headers: {
|
|
149
|
-
'Content-Type': 'application/json',
|
|
150
|
-
},
|
|
151
|
-
body: JSON.stringify({
|
|
152
|
-
agentId: 'agent_87c4a55a1',
|
|
153
|
-
appId: 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC',
|
|
154
|
-
variables: {
|
|
155
|
-
testMode: true,
|
|
156
|
-
userName: 'Test User',
|
|
157
|
-
page: 'test-signed-link.html'
|
|
158
|
-
}
|
|
159
|
-
})
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
if (!response.ok) {
|
|
163
|
-
throw new Error(`Backend API error: ${response.status}`);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const data = await response.json();
|
|
167
|
-
if (!data.signedUrl) {
|
|
168
|
-
throw new Error('Backend response must contain "signedUrl" field');
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Step 2: Initialize widget with signedUrl
|
|
172
|
-
const widget = new TTPAgentSDK.AgentWidget({
|
|
173
|
-
agentId: 'agent_87c4a55a1',
|
|
174
|
-
appId: 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC',
|
|
175
|
-
signedUrl: data.signedUrl, // Use signed URL from backend
|
|
176
|
-
|
|
177
|
-
variables: {
|
|
178
|
-
testMode: true,
|
|
179
|
-
userName: 'Test User',
|
|
180
|
-
page: 'test-signed-link.html'
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
primaryColor: '#F59E0B',
|
|
184
|
-
position: 'bottom-right'
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
return widget;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Initialize when ready
|
|
191
|
-
const widget = await initializeWidget();
|
|
192
|
-
</div>
|
|
193
|
-
|
|
194
|
-
<h2>Manual Tests:</h2>
|
|
195
|
-
<button onclick="testMicButton()">Test Mic Button Click</button>
|
|
196
|
-
<button onclick="testToggleVoice()">Test ToggleVoice Method</button>
|
|
197
|
-
<button onclick="checkWidgetState()">Check Widget State</button>
|
|
198
|
-
<button onclick="testMicrophone()">Test Microphone Access</button>
|
|
199
|
-
<button onclick="testBackendAPI()">Test Backend API</button>
|
|
200
|
-
<button onclick="testSignedUrlGeneration()">Test Signed URL Generation</button>
|
|
201
|
-
</div>
|
|
202
|
-
|
|
203
|
-
<!-- Load the widget -->
|
|
204
|
-
<script src="../agent-widget.js"
|
|
205
|
-
onload="console.log('Script loaded, checking TTPAgentSDK:', typeof window.TTPAgentSDK);"
|
|
206
|
-
onerror="console.error('Failed to load SDK script'); window.sdkLoadError = true;"></script>
|
|
207
|
-
|
|
208
|
-
<script>
|
|
209
|
-
// Override console.log to show in page
|
|
210
|
-
const originalLog = console.log;
|
|
211
|
-
const originalError = console.error;
|
|
212
|
-
const logDiv = document.getElementById('log');
|
|
213
|
-
|
|
214
|
-
function addLog(message, type = 'log') {
|
|
215
|
-
const time = new Date().toLocaleTimeString();
|
|
216
|
-
const color = type === 'error' ? '#EF4444' : '#10B981';
|
|
217
|
-
logDiv.innerHTML += `<div style="color: ${color};">[${time}] ${message}</div>`;
|
|
218
|
-
logDiv.scrollTop = logDiv.scrollHeight;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
console.log = (...args) => {
|
|
222
|
-
originalLog(...args);
|
|
223
|
-
addLog(args.join(' '));
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
console.error = (...args) => {
|
|
227
|
-
originalError(...args);
|
|
228
|
-
addLog(args.join(' '), 'error');
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
// Update status display
|
|
232
|
-
function updateStatus(message, type = 'info') {
|
|
233
|
-
const statusDiv = document.getElementById('status');
|
|
234
|
-
statusDiv.textContent = message;
|
|
235
|
-
statusDiv.className = 'status ' + type;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Wait for TTPAgentSDK to be available
|
|
239
|
-
function waitForSDK(callback, maxAttempts = 50) {
|
|
240
|
-
// Check if there was a load error
|
|
241
|
-
if (window.sdkLoadError) {
|
|
242
|
-
console.error('SDK script failed to load (check network tab)');
|
|
243
|
-
updateStatus('SDK script failed to load - check console for errors', 'error');
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Check if TTPAgentSDK is available
|
|
248
|
-
if (typeof window.TTPAgentSDK !== 'undefined' && window.TTPAgentSDK !== null) {
|
|
249
|
-
console.log('SDK script loaded successfully');
|
|
250
|
-
console.log('TTPAgentSDK type:', typeof window.TTPAgentSDK);
|
|
251
|
-
console.log('TTPAgentSDK keys:', Object.keys(window.TTPAgentSDK || {}).slice(0, 5));
|
|
252
|
-
callback();
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (maxAttempts <= 0) {
|
|
257
|
-
console.error('SDK failed to load after timeout');
|
|
258
|
-
console.error('window.TTPAgentSDK:', window.TTPAgentSDK);
|
|
259
|
-
console.error('Check browser console and network tab for errors');
|
|
260
|
-
updateStatus('SDK failed to load after timeout - check console', 'error');
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
setTimeout(() => waitForSDK(callback, maxAttempts - 1), 100);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Initialize the widget once SDK is loaded
|
|
268
|
-
waitForSDK(() => {
|
|
269
|
-
try {
|
|
270
|
-
console.log('Initializing widget with signed link...');
|
|
271
|
-
console.log('TTPAgentSDK available:', typeof window.TTPAgentSDK);
|
|
272
|
-
console.log('TTPAgentSDK.AgentWidget available:', typeof window.TTPAgentSDK?.AgentWidget);
|
|
273
|
-
|
|
274
|
-
if (typeof window.TTPAgentSDK === 'undefined') {
|
|
275
|
-
throw new Error('TTPAgentSDK is not defined. Check if the script loaded correctly.');
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (typeof window.TTPAgentSDK.AgentWidget === 'undefined') {
|
|
279
|
-
throw new Error('TTPAgentSDK.AgentWidget is not defined. Check the SDK build.');
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// Step 1: Get signed URL from backend
|
|
283
|
-
console.log('Requesting signed URL from backend API...');
|
|
284
|
-
updateStatus('Requesting signed URL from backend...', 'info');
|
|
285
|
-
|
|
286
|
-
const agentId = 'agent_87c4a55a1';
|
|
287
|
-
const appId = 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC';
|
|
288
|
-
const variables = {
|
|
289
|
-
testMode: true,
|
|
290
|
-
userName: 'Test User',
|
|
291
|
-
page: 'test-signed-link.html'
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
console.log('Agent ID:', agentId);
|
|
295
|
-
console.log('App ID:', appId);
|
|
296
|
-
console.log('Variables:', variables);
|
|
297
|
-
|
|
298
|
-
try {
|
|
299
|
-
const response = await fetch('https://backend.talktopc.com/api/public/agents/signed-url', {
|
|
300
|
-
method: 'POST',
|
|
301
|
-
headers: {
|
|
302
|
-
'Content-Type': 'application/json',
|
|
303
|
-
},
|
|
304
|
-
body: JSON.stringify({
|
|
305
|
-
agentId: agentId,
|
|
306
|
-
appId: appId,
|
|
307
|
-
variables: variables
|
|
308
|
-
})
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
console.log('Backend API response status:', response.status);
|
|
312
|
-
|
|
313
|
-
if (!response.ok) {
|
|
314
|
-
const errorText = await response.text();
|
|
315
|
-
throw new Error(`Backend API error: ${response.status} - ${errorText}`);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
const data = await response.json();
|
|
319
|
-
console.log('Backend API response data:', data);
|
|
320
|
-
|
|
321
|
-
// Backend must return signedUrl field
|
|
322
|
-
if (!data.signedUrl) {
|
|
323
|
-
throw new Error('Backend response must contain "signedUrl" field');
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
const signedUrl = data.signedUrl;
|
|
327
|
-
console.log('Generated signed URL:', signedUrl);
|
|
328
|
-
updateStatus('Signed URL received from backend ✓', 'success');
|
|
329
|
-
|
|
330
|
-
// Step 2: Create widget with signedUrl
|
|
331
|
-
const widget = new window.TTPAgentSDK.AgentWidget({
|
|
332
|
-
agentId: agentId,
|
|
333
|
-
appId: appId,
|
|
334
|
-
signedUrl: signedUrl, // Use signed URL from backend
|
|
335
|
-
|
|
336
|
-
// Pass some test variables
|
|
337
|
-
variables: variables,
|
|
338
|
-
|
|
339
|
-
// Customize appearance
|
|
340
|
-
primaryColor: '#F59E0B',
|
|
341
|
-
position: 'bottom-right'
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
// Store widget reference for testing
|
|
345
|
-
window.testWidget = widget;
|
|
346
|
-
|
|
347
|
-
console.log('Widget initialized successfully with signed link!');
|
|
348
|
-
console.log('Widget instance:', widget);
|
|
349
|
-
console.log('Test methods available at window.testWidget');
|
|
350
|
-
updateStatus('Widget loaded and ready ✓', 'success');
|
|
351
|
-
|
|
352
|
-
} catch (error) {
|
|
353
|
-
console.error('Failed to get signed URL or initialize widget:', error);
|
|
354
|
-
updateStatus('Failed: ' + error.message, 'error');
|
|
355
|
-
|
|
356
|
-
// Fallback to direct connection if backend fails
|
|
357
|
-
console.log('Falling back to direct connection...');
|
|
358
|
-
updateStatus('Using fallback direct connection', 'info');
|
|
359
|
-
|
|
360
|
-
const widget = new window.TTPAgentSDK.AgentWidget({
|
|
361
|
-
agentId: agentId,
|
|
362
|
-
appId: appId,
|
|
363
|
-
variables: variables,
|
|
364
|
-
primaryColor: '#F59E0B',
|
|
365
|
-
position: 'bottom-right'
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
window.testWidget = widget;
|
|
369
|
-
console.log('Widget initialized with direct connection (fallback)');
|
|
370
|
-
}
|
|
371
|
-
} catch (error) {
|
|
372
|
-
console.error('Failed to initialize widget:', error);
|
|
373
|
-
updateStatus('Failed to initialize widget: ' + error.message, 'error');
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
// Test functions (matching the working implementation)
|
|
378
|
-
function testMicButton() {
|
|
379
|
-
console.log('🎤 Testing mic button manually...');
|
|
380
|
-
const micButton = document.getElementById('agent-mic-button');
|
|
381
|
-
if (micButton) {
|
|
382
|
-
console.log('🎤 Found mic button, clicking...');
|
|
383
|
-
micButton.click();
|
|
384
|
-
} else {
|
|
385
|
-
console.log('🎤 Mic button not found');
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
function testToggleVoice() {
|
|
390
|
-
console.log('🎤 Testing toggleVoice method...');
|
|
391
|
-
if (window.testWidget && window.testWidget.toggleVoice) {
|
|
392
|
-
window.testWidget.toggleVoice();
|
|
393
|
-
} else {
|
|
394
|
-
console.log('🎤 toggleVoice method not available');
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
function checkWidgetState() {
|
|
399
|
-
console.log('🎤 Widget state:', {
|
|
400
|
-
isActive: window.testWidget?.isActive,
|
|
401
|
-
isOpen: window.testWidget?.isOpen,
|
|
402
|
-
sdk: window.testWidget?.sdk
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
async function testMicrophone() {
|
|
407
|
-
console.log('Testing microphone access...');
|
|
408
|
-
try {
|
|
409
|
-
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
410
|
-
console.log('Microphone access granted ✓');
|
|
411
|
-
stream.getTracks().forEach(track => track.stop());
|
|
412
|
-
alert('Microphone access OK!');
|
|
413
|
-
} catch (error) {
|
|
414
|
-
console.error('Microphone access denied:', error);
|
|
415
|
-
alert('Microphone access DENIED! Please allow microphone in browser settings.');
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// Manual test functions
|
|
420
|
-
async function testBackendAPI() {
|
|
421
|
-
console.log('Testing backend API connection...');
|
|
422
|
-
try {
|
|
423
|
-
const response = await fetch('https://backend.talktopc.com/api/public/agents/signed-url', {
|
|
424
|
-
method: 'POST',
|
|
425
|
-
headers: {
|
|
426
|
-
'Content-Type': 'application/json',
|
|
427
|
-
},
|
|
428
|
-
body: JSON.stringify({
|
|
429
|
-
agentId: 'agent_87c4a55a1',
|
|
430
|
-
appId: 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC',
|
|
431
|
-
variables: { testMode: true }
|
|
432
|
-
})
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
console.log('Backend API response status:', response.status);
|
|
436
|
-
|
|
437
|
-
if (response.ok) {
|
|
438
|
-
const data = await response.json();
|
|
439
|
-
console.log('Backend API response:', data);
|
|
440
|
-
alert('Backend API connection OK! Check console for response details.');
|
|
441
|
-
} else {
|
|
442
|
-
const errorText = await response.text();
|
|
443
|
-
throw new Error(`Backend returned error: ${response.status} - ${errorText}`);
|
|
444
|
-
}
|
|
445
|
-
} catch (error) {
|
|
446
|
-
console.error('Backend API test failed:', error);
|
|
447
|
-
alert('Backend API test FAILED! Check console for details.');
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
async function testSignedUrlGeneration() {
|
|
452
|
-
console.log('Testing signed URL generation...');
|
|
453
|
-
try {
|
|
454
|
-
const response = await fetch('https://backend.talktopc.com/api/public/agents/signed-url', {
|
|
455
|
-
method: 'POST',
|
|
456
|
-
headers: {
|
|
457
|
-
'Content-Type': 'application/json',
|
|
458
|
-
},
|
|
459
|
-
body: JSON.stringify({
|
|
460
|
-
agentId: 'agent_87c4a55a1',
|
|
461
|
-
appId: 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC',
|
|
462
|
-
variables: {
|
|
463
|
-
testMode: true,
|
|
464
|
-
userName: 'Test User',
|
|
465
|
-
timestamp: new Date().toISOString()
|
|
466
|
-
}
|
|
467
|
-
})
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
if (response.ok) {
|
|
471
|
-
const data = await response.json();
|
|
472
|
-
|
|
473
|
-
if (!data.signedUrl) {
|
|
474
|
-
throw new Error('Backend response must contain "signedUrl" field');
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
const signedUrl = data.signedUrl;
|
|
478
|
-
console.log('Generated signed URL:', signedUrl);
|
|
479
|
-
alert(`Signed URL generated successfully!\n\nURL: ${signedUrl.substring(0, 100)}...\n\nYou can now use this signedUrl when initializing the widget:\n\nconst widget = new TTPAgentSDK.AgentWidget({\n agentId: 'agent_87c4a55a1',\n appId: 'app_Bc01EqMQt2Euehl4qqZSi6l3FJP42Q9vJ0pC',\n signedUrl: '${signedUrl.substring(0, 50)}...'\n});`);
|
|
480
|
-
} else {
|
|
481
|
-
throw new Error(`API error: ${response.status}`);
|
|
482
|
-
}
|
|
483
|
-
} catch (error) {
|
|
484
|
-
console.error('Signed URL generation test failed:', error);
|
|
485
|
-
alert('Signed URL generation FAILED! Check console for details.');
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
async function testMicrophone() {
|
|
490
|
-
console.log('Testing microphone access...');
|
|
491
|
-
try {
|
|
492
|
-
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
493
|
-
console.log('Microphone access granted ✓');
|
|
494
|
-
stream.getTracks().forEach(track => track.stop());
|
|
495
|
-
alert('Microphone access OK!');
|
|
496
|
-
} catch (error) {
|
|
497
|
-
console.error('Microphone access denied:', error);
|
|
498
|
-
alert('Microphone access DENIED! Please allow microphone in browser settings.');
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
</script>
|
|
502
|
-
</body>
|
|
503
|
-
</html>
|