ttp-agent-sdk 2.34.14 → 2.35.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 +388 -274
- 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
package/ENHANCED_WIDGET_GUIDE.md
CHANGED
|
@@ -7,29 +7,14 @@ The `TTPChatWidget` provides extensive customization options while maintaining s
|
|
|
7
7
|
```javascript
|
|
8
8
|
import { TTPChatWidget } from 'ttp-agent-sdk';
|
|
9
9
|
|
|
10
|
-
// Minimal configuration
|
|
10
|
+
// Minimal configuration (uses all defaults)
|
|
11
11
|
new TTPChatWidget({
|
|
12
12
|
agentId: 'your_agent_id',
|
|
13
|
-
|
|
13
|
+
appId: 'your_app_id'
|
|
14
14
|
});
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```javascript
|
|
20
|
-
new TTPChatWidget({
|
|
21
|
-
agentId: 'your_agent_id',
|
|
22
|
-
signedUrl: async () => {
|
|
23
|
-
const response = await fetch('/api/get-session', {
|
|
24
|
-
method: 'POST',
|
|
25
|
-
headers: { 'Content-Type': 'application/json' },
|
|
26
|
-
body: JSON.stringify({ agentId: 'your_agent_id' })
|
|
27
|
-
});
|
|
28
|
-
const data = await response.json();
|
|
29
|
-
return data.signedUrl;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
```
|
|
17
|
+
The SDK connects directly using `agentId` + `appId`. For production, configure a domain whitelist in your TTP dashboard.
|
|
33
18
|
|
|
34
19
|
## Complete Configuration Options
|
|
35
20
|
|
|
@@ -38,14 +23,10 @@ new TTPChatWidget({
|
|
|
38
23
|
```javascript
|
|
39
24
|
{
|
|
40
25
|
agentId: 'your_agent_id', // Required: Your agent ID
|
|
41
|
-
|
|
26
|
+
appId: 'your_app_id' // Required: Your app ID
|
|
42
27
|
}
|
|
43
28
|
```
|
|
44
29
|
|
|
45
|
-
**Signed URL Options:**
|
|
46
|
-
- **Direct string**: `signedUrl: 'wss://speech.talktopc.com/ws/conv?signed_token=...'`
|
|
47
|
-
- **Function**: `signedUrl: async () => { const data = await fetch(...); return data.signedUrl; }`
|
|
48
|
-
|
|
49
30
|
### Icon/Image Configuration
|
|
50
31
|
|
|
51
32
|
```javascript
|
|
@@ -219,18 +200,10 @@ position: {
|
|
|
219
200
|
```javascript
|
|
220
201
|
import { TTPChatWidget } from 'ttp-agent-sdk';
|
|
221
202
|
|
|
222
|
-
// Get signed URL from backend
|
|
223
|
-
const response = await fetch('/api/get-session', {
|
|
224
|
-
method: 'POST',
|
|
225
|
-
headers: { 'Content-Type': 'application/json' },
|
|
226
|
-
body: JSON.stringify({ agentId: 'my_agent_123' })
|
|
227
|
-
});
|
|
228
|
-
const data = await response.json();
|
|
229
|
-
|
|
230
203
|
const widget = new TTPChatWidget({
|
|
231
204
|
// Required
|
|
232
205
|
agentId: 'my_agent_123',
|
|
233
|
-
|
|
206
|
+
appId: 'my_app_456',
|
|
234
207
|
|
|
235
208
|
// Custom icon (company logo)
|
|
236
209
|
icon: {
|
package/GETTING_STARTED.md
CHANGED
|
@@ -30,15 +30,7 @@ npm install ttp-agent-sdk
|
|
|
30
30
|
// Initialize the voice widget
|
|
31
31
|
TTPAgentSDK.AgentWidget.init({
|
|
32
32
|
agentId: 'your_agent_id',
|
|
33
|
-
|
|
34
|
-
const response = await fetch('/api/get-session', {
|
|
35
|
-
method: 'POST',
|
|
36
|
-
headers: { 'Content-Type': 'application/json' },
|
|
37
|
-
body: JSON.stringify({ agentId: 'your_agent_id' })
|
|
38
|
-
});
|
|
39
|
-
const data = await response.json();
|
|
40
|
-
return data.signedUrl;
|
|
41
|
-
}
|
|
33
|
+
appId: 'your_app_id'
|
|
42
34
|
});
|
|
43
35
|
</script>
|
|
44
36
|
</body>
|
|
@@ -96,30 +88,19 @@ const voiceSDK = new VoiceSDK({
|
|
|
96
88
|
|
|
97
89
|
**Note**: This method is unsecured as the agent ID is visible in network traffic.
|
|
98
90
|
|
|
99
|
-
### Method 2:
|
|
91
|
+
### Method 2: Domain Whitelist (Production)
|
|
100
92
|
|
|
101
|
-
For production applications, use
|
|
93
|
+
For production applications, configure a domain whitelist in your TTP dashboard to restrict which domains can use your agent:
|
|
102
94
|
|
|
103
95
|
```javascript
|
|
104
96
|
const voiceSDK = new VoiceSDK({
|
|
105
|
-
websocketUrl: 'wss://speech.
|
|
106
|
-
|
|
97
|
+
websocketUrl: 'wss://speech.talktopc.com/ws/conv',
|
|
98
|
+
agentId: 'your_agent_id',
|
|
99
|
+
appId: 'your_app_id'
|
|
107
100
|
});
|
|
108
101
|
```
|
|
109
102
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
```javascript
|
|
113
|
-
async function getSignedUrl(agentId, variables = {}) {
|
|
114
|
-
const response = await fetch('/api/get-session', {
|
|
115
|
-
method: 'POST',
|
|
116
|
-
headers: { 'Content-Type': 'application/json' },
|
|
117
|
-
body: JSON.stringify({ agentId, variables })
|
|
118
|
-
});
|
|
119
|
-
const data = await response.json();
|
|
120
|
-
return data.signedUrl;
|
|
121
|
-
}
|
|
122
|
-
```
|
|
103
|
+
The server validates the connecting domain against the configured whitelist. No backend endpoint needed.
|
|
123
104
|
|
|
124
105
|
## Configuration Options
|
|
125
106
|
|
|
@@ -143,7 +124,7 @@ const voiceSDK = new VoiceSDK({
|
|
|
143
124
|
```javascript
|
|
144
125
|
TTPAgentSDK.AgentWidget.init({
|
|
145
126
|
agentId: 'your_agent_id', // Required
|
|
146
|
-
|
|
127
|
+
appId: 'your_app_id', // Required - Your app ID
|
|
147
128
|
variables: { // Optional - dynamic variables
|
|
148
129
|
userName: 'John Doe',
|
|
149
130
|
page: 'homepage'
|
|
@@ -195,54 +176,20 @@ voiceSDK.on('error', (error) => {
|
|
|
195
176
|
});
|
|
196
177
|
```
|
|
197
178
|
|
|
198
|
-
##
|
|
179
|
+
## Security
|
|
199
180
|
|
|
200
|
-
###
|
|
181
|
+
### Domain Whitelist (Production)
|
|
201
182
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
```javascript
|
|
205
|
-
// Example Express.js endpoint
|
|
206
|
-
app.post('/api/get-session', async (req, res) => {
|
|
207
|
-
const { agentId, variables } = req.body;
|
|
208
|
-
|
|
209
|
-
// Validate user authentication
|
|
210
|
-
const user = await authenticateUser(req);
|
|
211
|
-
if (!user) {
|
|
212
|
-
return res.status(401).json({ error: 'Unauthorized' });
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Generate signed URL
|
|
216
|
-
const signedUrl = await generateSignedUrl({
|
|
217
|
-
agentId,
|
|
218
|
-
userId: user.id,
|
|
219
|
-
appId: user.appId,
|
|
220
|
-
variables
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
res.json({ signedUrl });
|
|
224
|
-
});
|
|
225
|
-
```
|
|
183
|
+
For production deployments, configure a domain whitelist in your TTP dashboard to restrict which domains can connect to your agent. The SDK connects directly using `agentId` + `appId`, and the server validates the connecting domain.
|
|
226
184
|
|
|
227
|
-
|
|
185
|
+
No backend endpoint or token generation is required.
|
|
228
186
|
|
|
229
|
-
|
|
187
|
+
### Configuration Steps
|
|
230
188
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const token = jwt.sign({
|
|
236
|
-
agentId,
|
|
237
|
-
userId,
|
|
238
|
-
appId,
|
|
239
|
-
variables,
|
|
240
|
-
exp: Math.floor(Date.now() / 1000) + (60 * 60) // 1 hour expiry
|
|
241
|
-
}, process.env.CONVERSATION_SECRET_KEY);
|
|
242
|
-
|
|
243
|
-
return `wss://speech.bidme.co.il/ws/conv?signed_token=${token}`;
|
|
244
|
-
}
|
|
245
|
-
```
|
|
189
|
+
1. Go to your TTP dashboard
|
|
190
|
+
2. Navigate to your agent settings
|
|
191
|
+
3. Add your production domain(s) to the allowed domains list
|
|
192
|
+
4. The SDK will authenticate automatically via domain validation
|
|
246
193
|
|
|
247
194
|
## Examples
|
|
248
195
|
|
|
@@ -393,9 +340,9 @@ function VoiceChat() {
|
|
|
393
340
|
- Verify audio format compatibility
|
|
394
341
|
|
|
395
342
|
4. **Authentication Errors**
|
|
396
|
-
- Verify
|
|
397
|
-
- Check
|
|
398
|
-
- Ensure
|
|
343
|
+
- Verify agent ID and app ID are correct
|
|
344
|
+
- Check domain whitelist configuration
|
|
345
|
+
- Ensure your domain is whitelisted in the TTP dashboard
|
|
399
346
|
|
|
400
347
|
### Debug Mode
|
|
401
348
|
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ A comprehensive JavaScript SDK for voice interaction with AI agents. Provides re
|
|
|
17
17
|
- ⚛️ **React Components** - Ready-to-use React components
|
|
18
18
|
- 🌐 **Vanilla JavaScript** - Works with any JavaScript framework
|
|
19
19
|
- 🎯 **Event-driven** - Comprehensive event system for all interactions
|
|
20
|
-
- 🔒 **
|
|
20
|
+
- 🔒 **Secure Authentication** - Direct agent access with domain whitelist for production
|
|
21
21
|
- 📱 **Responsive Widget** - Pre-built UI widget for quick integration
|
|
22
22
|
|
|
23
23
|
## Installation
|
|
@@ -46,17 +46,19 @@ await voiceSDK.connect();
|
|
|
46
46
|
await voiceSDK.startRecording();
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
### Method 2:
|
|
49
|
+
### Method 2: Domain Whitelist (Production)
|
|
50
|
+
|
|
51
|
+
For production, configure a domain whitelist in your TTP dashboard. The SDK uses the same `agentId` + `appId` configuration — the server validates the connecting domain.
|
|
50
52
|
|
|
51
53
|
```javascript
|
|
52
54
|
import { VoiceSDK } from 'ttp-agent-sdk';
|
|
53
55
|
|
|
54
56
|
const voiceSDK = new VoiceSDK({
|
|
55
57
|
websocketUrl: 'wss://speech.talktopc.com/ws/conv',
|
|
56
|
-
|
|
58
|
+
agentId: 'your_agent_id',
|
|
59
|
+
appId: 'your_app_id'
|
|
57
60
|
});
|
|
58
61
|
|
|
59
|
-
// Connect using signed URL
|
|
60
62
|
await voiceSDK.connect();
|
|
61
63
|
```
|
|
62
64
|
|
|
@@ -64,38 +66,10 @@ await voiceSDK.connect();
|
|
|
64
66
|
|
|
65
67
|
```html
|
|
66
68
|
<script src="https://unpkg.com/ttp-agent-sdk/dist/agent-widget.js"></script>
|
|
67
|
-
<script>
|
|
68
|
-
// Get signed URL from your backend first
|
|
69
|
-
const response = await fetch('/api/get-session', {
|
|
70
|
-
method: 'POST',
|
|
71
|
-
headers: { 'Content-Type': 'application/json' },
|
|
72
|
-
body: JSON.stringify({ agentId: 'your_agent_id' })
|
|
73
|
-
});
|
|
74
|
-
const data = await response.json();
|
|
75
|
-
|
|
76
|
-
// Use the signed URL directly
|
|
77
|
-
new TTPAgentSDK.TTPChatWidget({
|
|
78
|
-
agentId: 'your_agent_id',
|
|
79
|
-
signedUrl: data.signedUrl
|
|
80
|
-
});
|
|
81
|
-
</script>
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Or use a function to fetch the signed URL:
|
|
85
|
-
|
|
86
|
-
```html
|
|
87
69
|
<script>
|
|
88
70
|
new TTPAgentSDK.TTPChatWidget({
|
|
89
71
|
agentId: 'your_agent_id',
|
|
90
|
-
|
|
91
|
-
const response = await fetch('/api/get-session', {
|
|
92
|
-
method: 'POST',
|
|
93
|
-
headers: { 'Content-Type': 'application/json' },
|
|
94
|
-
body: JSON.stringify({ agentId: 'your_agent_id' })
|
|
95
|
-
});
|
|
96
|
-
const data = await response.json();
|
|
97
|
-
return data.signedUrl;
|
|
98
|
-
}
|
|
72
|
+
appId: 'your_app_id'
|
|
99
73
|
});
|
|
100
74
|
</script>
|
|
101
75
|
```
|
|
@@ -221,18 +195,21 @@ const voiceSDK = new VoiceSDK({
|
|
|
221
195
|
|
|
222
196
|
**Security Risk**: Agent ID is visible in network traffic.
|
|
223
197
|
|
|
224
|
-
### 2.
|
|
198
|
+
### 2. Domain Whitelist (Secured - Production)
|
|
225
199
|
|
|
226
200
|
**Use Case**: Production applications where security is critical.
|
|
227
201
|
|
|
202
|
+
Configure a domain whitelist in your TTP dashboard. The SDK uses the same `agentId` + `appId` — the server validates the connecting domain.
|
|
203
|
+
|
|
228
204
|
```javascript
|
|
229
205
|
const voiceSDK = new VoiceSDK({
|
|
230
|
-
websocketUrl: 'wss://speech.
|
|
231
|
-
|
|
206
|
+
websocketUrl: 'wss://speech.talktopc.com/ws/conv',
|
|
207
|
+
agentId: 'agent_12345',
|
|
208
|
+
appId: 'app_67890'
|
|
232
209
|
});
|
|
233
210
|
```
|
|
234
211
|
|
|
235
|
-
**Benefits**: Secure, cost-controlled, and production-ready.
|
|
212
|
+
**Benefits**: Secure, cost-controlled, and production-ready with no backend endpoint needed.
|
|
236
213
|
|
|
237
214
|
## Message Format
|
|
238
215
|
|
|
@@ -636,7 +613,6 @@ The tool checks parameters in this order:
|
|
|
636
613
|
See the `examples/` directory for complete usage examples:
|
|
637
614
|
|
|
638
615
|
- `test-text-chat.html` - TTP Chat Widget with customizable settings
|
|
639
|
-
- `test-signed-link.html` - Widget with signed link authentication
|
|
640
616
|
- `react-example.jsx` - React component usage
|
|
641
617
|
- `vanilla-example.html` - Vanilla JavaScript usage
|
|
642
618
|
|
package/WORDPRESS_WIX_GUIDE.md
CHANGED
|
@@ -161,9 +161,13 @@ add_action('wp_footer', 'ttp_voice_agent_script');
|
|
|
161
161
|
|
|
162
162
|
## Production Setup (Recommended)
|
|
163
163
|
|
|
164
|
-
For production,
|
|
164
|
+
For production, configure a **domain whitelist** in your TTP dashboard to restrict which domains can use your agent. The SDK connects directly using `agentId` + `appId` — no backend endpoint is needed.
|
|
165
165
|
|
|
166
|
-
### WordPress / Wix with
|
|
166
|
+
### WordPress / Wix with Domain Whitelist
|
|
167
|
+
|
|
168
|
+
1. Go to your TTP dashboard
|
|
169
|
+
2. Add your domain (e.g., `yourwebsite.com`) to the agent's allowed domains
|
|
170
|
+
3. Use the same widget code as above — no changes needed
|
|
167
171
|
|
|
168
172
|
```html
|
|
169
173
|
<script src="https://cdn.talktopc.com/agent-widget.js"></script>
|
|
@@ -171,26 +175,12 @@ For production, use **signed links** instead of exposing agent IDs. Here's how:
|
|
|
171
175
|
new TTPAgentSDK.TTPChatWidget({
|
|
172
176
|
agentId: 'agent_f676e962a',
|
|
173
177
|
appId: 'app_bQHDFqydfNPl75MZNijXc4dUyHGqnHeX9e5l',
|
|
174
|
-
behavior: { mode: 'unified' }
|
|
175
|
-
|
|
176
|
-
// Use signed URL from your backend
|
|
177
|
-
signedUrl: async () => {
|
|
178
|
-
const response = await fetch('https://your-backend.com/api/get-session', {
|
|
179
|
-
method: 'POST',
|
|
180
|
-
headers: { 'Content-Type': 'application/json' },
|
|
181
|
-
body: JSON.stringify({
|
|
182
|
-
agentId: 'agent_f676e962a',
|
|
183
|
-
appId: 'app_bQHDFqydfNPl75MZNijXc4dUyHGqnHeX9e5l'
|
|
184
|
-
})
|
|
185
|
-
});
|
|
186
|
-
const data = await response.json();
|
|
187
|
-
return data.signedUrl;
|
|
188
|
-
}
|
|
178
|
+
behavior: { mode: 'unified' }
|
|
189
179
|
});
|
|
190
180
|
</script>
|
|
191
181
|
```
|
|
192
182
|
|
|
193
|
-
**Note:**
|
|
183
|
+
**Note:** Domain whitelist configuration ensures only authorized domains can connect to your agent. Contact TTP support for assistance.
|
|
194
184
|
|
|
195
185
|
---
|
|
196
186
|
|