ttp-agent-sdk 2.2.1 → 2.2.3
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/WORDPRESS_WIX_GUIDE.md +281 -0
- package/dist/agent-widget.js +1 -1
- package/dist/agent-widget.js.map +1 -1
- package/dist/examples/test-agent-app.html +123 -1
- package/dist/examples/test-text-chat.html +356 -0
- package/dist/examples/test.html +8 -0
- package/examples/test-agent-app.html +123 -1
- package/examples/test-text-chat.html +356 -0
- package/examples/test.html +8 -0
- package/package.json +3 -2
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# WordPress & Wix Integration Guide
|
|
2
|
+
|
|
3
|
+
Integrating the TTP Agent SDK into WordPress or Wix is straightforward! The SDK works with just a simple script tag - no build process needed.
|
|
4
|
+
|
|
5
|
+
## Quick Overview
|
|
6
|
+
|
|
7
|
+
✅ **No build tools required**
|
|
8
|
+
✅ **Works with script tag**
|
|
9
|
+
✅ **Zero configuration** (if using direct agent/app ID)
|
|
10
|
+
✅ **Customizable via simple JavaScript**
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## WordPress Integration
|
|
15
|
+
|
|
16
|
+
### Method 1: Using Custom HTML Block (Easiest)
|
|
17
|
+
|
|
18
|
+
1. **Edit your WordPress page/post**
|
|
19
|
+
2. **Add a "Custom HTML" block**
|
|
20
|
+
3. **Paste this code:**
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<!-- Load TTP Agent SDK -->
|
|
24
|
+
<script src="https://unpkg.com/ttp-agent-sdk@2.2.2/dist/agent-widget.js"></script>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
// Initialize the widget when page loads
|
|
28
|
+
window.addEventListener('DOMContentLoaded', function() {
|
|
29
|
+
new TTPAgentSDK.AgentWidget({
|
|
30
|
+
agentId: 'your_agent_id',
|
|
31
|
+
appId: 'your_app_id',
|
|
32
|
+
|
|
33
|
+
// Optional: Customize appearance
|
|
34
|
+
primaryColor: '#10B981',
|
|
35
|
+
position: 'bottom-right',
|
|
36
|
+
|
|
37
|
+
// Optional: Custom icon
|
|
38
|
+
icon: {
|
|
39
|
+
type: 'custom',
|
|
40
|
+
customImage: 'https://yourwebsite.com/logo.png',
|
|
41
|
+
size: 'medium'
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
// Optional: Custom header
|
|
45
|
+
header: {
|
|
46
|
+
title: 'Support Assistant',
|
|
47
|
+
backgroundColor: '#10B981'
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
</script>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Method 2: Using Theme's Footer (Site-Wide)
|
|
55
|
+
|
|
56
|
+
1. **Go to Appearance → Theme Editor → Footer (footer.php)**
|
|
57
|
+
2. **Add the code before `</body>` tag:**
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<script src="https://unpkg.com/ttp-agent-sdk@2.2.2/dist/agent-widget.js"></script>
|
|
61
|
+
<script>
|
|
62
|
+
new TTPAgentSDK.AgentWidget({
|
|
63
|
+
agentId: 'your_agent_id',
|
|
64
|
+
appId: 'your_app_id',
|
|
65
|
+
header: { title: 'Get Help' }
|
|
66
|
+
});
|
|
67
|
+
</script>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Method 3: Using a Plugin
|
|
71
|
+
|
|
72
|
+
Create a simple plugin to add the SDK site-wide:
|
|
73
|
+
|
|
74
|
+
**File: `wp-content/plugins/ttp-voice-agent/ttp-voice-agent.php`**
|
|
75
|
+
|
|
76
|
+
```php
|
|
77
|
+
<?php
|
|
78
|
+
/**
|
|
79
|
+
* Plugin Name: TTP Voice Agent
|
|
80
|
+
* Description: Add TTP Voice Agent widget to your WordPress site
|
|
81
|
+
* Version: 1.0
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
function ttp_voice_agent_script() {
|
|
85
|
+
?>
|
|
86
|
+
<script src="https://unpkg.com/ttp-agent-sdk@2.2.2/dist/agent-widget.js"></script>
|
|
87
|
+
<script>
|
|
88
|
+
new TTPAgentSDK.AgentWidget({
|
|
89
|
+
agentId: '<?php echo esc_js(get_option('ttp_agent_id', '')); ?>',
|
|
90
|
+
appId: '<?php echo esc_js(get_option('ttp_app_id', '')); ?>',
|
|
91
|
+
header: { title: '<?php echo esc_js(get_option('ttp_header_title', 'Voice Assistant')); ?>' }
|
|
92
|
+
});
|
|
93
|
+
</script>
|
|
94
|
+
<?php
|
|
95
|
+
}
|
|
96
|
+
add_action('wp_footer', 'ttp_voice_agent_script');
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Wix Integration
|
|
102
|
+
|
|
103
|
+
### Method 1: Using HTML Code Element (Easiest)
|
|
104
|
+
|
|
105
|
+
1. **Edit your Wix site**
|
|
106
|
+
2. **Add → Embed → Custom Code (HTML iframe)**
|
|
107
|
+
3. **Or Add → Embed → HTML Code**
|
|
108
|
+
4. **Paste this code:**
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<script src="https://unpkg.com/ttp-agent-sdk@2.2.2/dist/agent-widget.js"></script>
|
|
112
|
+
<script>
|
|
113
|
+
new TTPAgentSDK.AgentWidget({
|
|
114
|
+
agentId: 'your_agent_id',
|
|
115
|
+
appId: 'your_app_id',
|
|
116
|
+
position: 'bottom-right',
|
|
117
|
+
header: { title: 'Support Chat' }
|
|
118
|
+
});
|
|
119
|
+
</script>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Method 2: Using Site Settings → Custom Code
|
|
123
|
+
|
|
124
|
+
1. **Settings → Custom Code**
|
|
125
|
+
2. **Add Code → Body - Start**
|
|
126
|
+
3. **Paste the script tags:**
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<script src="https://unpkg.com/ttp-agent-sdk@2.2.2/dist/agent-widget.js"></script>
|
|
130
|
+
<script>
|
|
131
|
+
window.addEventListener('DOMContentLoaded', function() {
|
|
132
|
+
new TTPAgentSDK.AgentWidget({
|
|
133
|
+
agentId: 'your_agent_id',
|
|
134
|
+
appId: 'your_app_id'
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
</script>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Important for Wix:
|
|
141
|
+
- The code must be added to **Body - Start** or in an **HTML Code element**
|
|
142
|
+
- Some Wix templates may require placing it in the **Footer** section
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Production Setup (Recommended)
|
|
147
|
+
|
|
148
|
+
For production, use **signed links** instead of exposing agent IDs. Here's how:
|
|
149
|
+
|
|
150
|
+
### WordPress / Wix with Signed Links
|
|
151
|
+
|
|
152
|
+
```html
|
|
153
|
+
<script src="https://unpkg.com/ttp-agent-sdk@2.2.2/dist/agent-widget.js"></script>
|
|
154
|
+
<script>
|
|
155
|
+
new TTPAgentSDK.AgentWidget({
|
|
156
|
+
agentId: 'your_agent_id',
|
|
157
|
+
appId: 'your_app_id',
|
|
158
|
+
|
|
159
|
+
// Use your backend to generate signed URLs
|
|
160
|
+
getSessionUrl: async ({ agentId, appId, variables }) => {
|
|
161
|
+
const response = await fetch('https://your-backend.com/api/get-session', {
|
|
162
|
+
method: 'POST',
|
|
163
|
+
headers: { 'Content-Type': 'application/json' },
|
|
164
|
+
body: JSON.stringify({ agentId, appId, variables })
|
|
165
|
+
});
|
|
166
|
+
const data = await response.json();
|
|
167
|
+
return data.signedUrl;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
</script>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Note:** This requires a backend endpoint that generates signed URLs. Contact TTP support for backend integration assistance.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Full Customization Example
|
|
178
|
+
|
|
179
|
+
Here's a complete example with all customization options:
|
|
180
|
+
|
|
181
|
+
```html
|
|
182
|
+
<script src="https://unpkg.com/ttp-agent-sdk@2.2.2/dist/agent-widget.js"></script>
|
|
183
|
+
<script>
|
|
184
|
+
new TTPAgentSDK.AgentWidget({
|
|
185
|
+
agentId: 'your_agent_id',
|
|
186
|
+
appId: 'your_app_id',
|
|
187
|
+
|
|
188
|
+
// Colors
|
|
189
|
+
primaryColor: '#10B981',
|
|
190
|
+
|
|
191
|
+
// Position
|
|
192
|
+
position: 'bottom-right', // or 'bottom-left', 'top-right', 'top-left'
|
|
193
|
+
|
|
194
|
+
// Icon
|
|
195
|
+
icon: {
|
|
196
|
+
type: 'custom',
|
|
197
|
+
customImage: 'https://yourwebsite.com/logo.png',
|
|
198
|
+
size: 'medium',
|
|
199
|
+
backgroundColor: '#FFFFFF'
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
// Floating Button
|
|
203
|
+
button: {
|
|
204
|
+
backgroundColor: '#FFFFFF',
|
|
205
|
+
hoverColor: '#E5E7EB',
|
|
206
|
+
size: 'medium',
|
|
207
|
+
shape: 'circle'
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
// Header
|
|
211
|
+
header: {
|
|
212
|
+
title: 'TTP Support',
|
|
213
|
+
backgroundColor: '#10B981',
|
|
214
|
+
textColor: '#FFFFFF'
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
// Panel/Mic Button
|
|
218
|
+
panel: {
|
|
219
|
+
micButtonColor: '#E5E7EB',
|
|
220
|
+
micButtonActiveColor: '#EF4444',
|
|
221
|
+
micButtonHint: {
|
|
222
|
+
text: 'Click to start voice conversation',
|
|
223
|
+
color: '#6B7280',
|
|
224
|
+
fontSize: '12px'
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
// Text Direction (for RTL languages)
|
|
229
|
+
direction: 'ltr', // or 'rtl' for Hebrew, Arabic, etc.
|
|
230
|
+
|
|
231
|
+
// Pass custom variables
|
|
232
|
+
variables: {
|
|
233
|
+
page: 'contact',
|
|
234
|
+
userId: 'user123'
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
</script>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Troubleshooting
|
|
243
|
+
|
|
244
|
+
### Widget not appearing?
|
|
245
|
+
|
|
246
|
+
1. **Check browser console** for JavaScript errors
|
|
247
|
+
2. **Verify script loads**: Check Network tab to see if `agent-widget.js` loaded
|
|
248
|
+
3. **Check agent/app IDs**: Make sure they're correct
|
|
249
|
+
4. **Z-index issues**: The widget uses `z-index: 10000` - if your theme has higher z-index, you may need to adjust
|
|
250
|
+
|
|
251
|
+
### Mobile issues?
|
|
252
|
+
|
|
253
|
+
- The widget is mobile-responsive by default
|
|
254
|
+
- Make sure your theme doesn't hide elements on mobile with CSS
|
|
255
|
+
- Check that the script tag is in the `<body>` or `wp_footer` hook
|
|
256
|
+
|
|
257
|
+
### WordPress Security Plugins?
|
|
258
|
+
|
|
259
|
+
Some security plugins may block external scripts. You may need to:
|
|
260
|
+
- Whitelist `unpkg.com` in your security plugin
|
|
261
|
+
- Or download the SDK file and host it on your own server
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Hosting Your Own SDK File
|
|
266
|
+
|
|
267
|
+
If you prefer to host the SDK file yourself:
|
|
268
|
+
|
|
269
|
+
1. Download: `https://unpkg.com/ttp-agent-sdk@2.2.2/dist/agent-widget.js`
|
|
270
|
+
2. Upload to your WordPress media library or Wix assets
|
|
271
|
+
3. Update the script `src` to point to your hosted file
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Support
|
|
276
|
+
|
|
277
|
+
For questions or issues:
|
|
278
|
+
- Check the [GitHub Repository](https://github.com/yinon11/ttp-sdk-front)
|
|
279
|
+
- See [GETTING_STARTED.md](./GETTING_STARTED.md) for more examples
|
|
280
|
+
- See [ENHANCED_WIDGET_GUIDE.md](./ENHANCED_WIDGET_GUIDE.md) for all options
|
|
281
|
+
|