guideai-app 0.3.0 → 0.3.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.
@@ -1,321 +0,0 @@
1
- # Text Input Feature - Usage Guide
2
-
3
- ## Overview
4
-
5
- The GuideAI package now supports text input as an alternative to voice input, allowing users to type messages instead of speaking. This feature provides better accessibility and accommodates different user preferences.
6
-
7
- ## Features
8
-
9
- ✅ **Text Input Box**: Clean, modern text area for typing messages
10
- ✅ **Input Mode Toggle**: Switch between voice and text input modes
11
- ✅ **Keyboard Shortcuts**: Send messages with Enter key
12
- ✅ **Configurable Interface**: Customize placeholder text and default mode
13
- ✅ **Programmatic Control**: Global API methods to control input mode
14
- ✅ **Seamless Integration**: Works with existing conversation and transcript features
15
-
16
- ## Configuration Options
17
-
18
- ### Basic Configuration
19
-
20
- ```typescript
21
- <GuideAI
22
- organizationKey="your-org-key"
23
- input={{
24
- enableTextInput: true, // Enable text input option
25
- showInputToggle: true, // Show voice/text toggle button
26
- defaultMode: 'voice', // Start with voice (default)
27
- placeholder: "Type here..." // Custom placeholder text
28
- }}
29
- />
30
- ```
31
-
32
- ### Configuration Interface
33
-
34
- ```typescript
35
- interface InputConfig {
36
- // Whether to enable text input functionality
37
- enableTextInput?: boolean; // default: false
38
-
39
- // Whether to show the voice/text toggle button
40
- showInputToggle?: boolean; // default: true
41
-
42
- // Default input mode when conversation starts
43
- defaultMode?: 'voice' | 'text'; // default: 'voice'
44
-
45
- // Placeholder text for the text input field
46
- placeholder?: string; // default: "Type your message..."
47
- }
48
- ```
49
-
50
- ## Usage Examples
51
-
52
- ### 1. Enable Text Input with Default Settings
53
-
54
- ```typescript
55
- <GuideAI
56
- organizationKey="your-org-key"
57
- input={{
58
- enableTextInput: true
59
- }}
60
- />
61
- ```
62
-
63
- ### 2. Start with Text Input Mode
64
-
65
- ```typescript
66
- <GuideAI
67
- organizationKey="your-org-key"
68
- input={{
69
- enableTextInput: true,
70
- defaultMode: 'text',
71
- placeholder: "What can I help you with?"
72
- }}
73
- />
74
- ```
75
-
76
- ### 3. Text-Only Mode (No Voice)
77
-
78
- ```typescript
79
- <GuideAI
80
- organizationKey="your-org-key"
81
- input={{
82
- enableTextInput: true,
83
- showInputToggle: false, // Hide toggle button
84
- defaultMode: 'text'
85
- }}
86
- />
87
- ```
88
-
89
- ### 4. Custom Placeholder and Configuration
90
-
91
- ```typescript
92
- <GuideAI
93
- organizationKey="your-org-key"
94
- input={{
95
- enableTextInput: true,
96
- showInputToggle: true,
97
- defaultMode: 'voice',
98
- placeholder: "Ask me anything about your insurance policy..."
99
- }}
100
- />
101
- ```
102
-
103
- ## User Interface
104
-
105
- ### Unified Input Interface
106
-
107
- - **Display**: Single microphone button
108
- - **Action**: Click mic to start conversation and show transcript
109
- - **Text Input**: Available in the transcript box when enabled
110
- - **Voice & Text**: Both options available simultaneously once conversation starts
111
-
112
- ### Text Input Box
113
-
114
- - **Position**: Integrated at the bottom of the transcript box
115
- - **Design**: Matches transcript styling with dark theme and glass effect
116
- - **Components**:
117
- - Compact textarea (2 rows by default)
118
- - Send button with 📤 icon
119
- - Seamlessly integrated with transcript design
120
-
121
- ## User Interactions
122
-
123
- ### User Flow
124
-
125
- 1. **Click Microphone**: Click the mic button to start conversation
126
- 2. **Transcript Appears**: Conversation transcript box opens automatically
127
- 3. **Choose Input Method**:
128
- - **Voice**: Speak directly (microphone is active)
129
- - **Text**: Type in the text input area at bottom of transcript
130
- 4. **Seamless Switching**: Use voice and text interchangeably in same conversation
131
-
132
- ### Sending Text Messages
133
-
134
- 1. **Enter Key**: Press Enter to send (Shift+Enter for new line)
135
- 2. **Send Button**: Click the 📤 button
136
- 3. **Programmatically**: Use `window.GuideAI.input.sendText()`
137
-
138
- ### Visual Feedback
139
-
140
- - **Active Text Mode**: Text input appears at bottom of transcript with fade-in animation
141
- - **Button States**: Send button disabled when input is empty
142
- - **Focus States**: Enhanced border and background when textarea is focused
143
- - **Integrated Design**: Text input seamlessly blends with transcript box styling
144
-
145
- ## Programmatic Control
146
-
147
- ### Global API Methods
148
-
149
- Access input controls via `window.GuideAI.input`:
150
-
151
- ```typescript
152
- // Toggle between voice and text input
153
- window.GuideAI.input.toggleMode();
154
-
155
- // Set specific input mode
156
- window.GuideAI.input.setMode('text');
157
- window.GuideAI.input.setMode('voice');
158
-
159
- // Get current input mode
160
- const currentMode = window.GuideAI.input.getMode();
161
- console.log('Current mode:', currentMode); // 'voice' or 'text'
162
-
163
- // Send text message programmatically
164
- window.GuideAI.input.sendText("Hello, can you help me?");
165
- ```
166
-
167
- ### Integration Examples
168
-
169
- #### Custom Toggle Interface
170
-
171
- ```typescript
172
- function MyCustomControls() {
173
- const [inputMode, setInputMode] = useState('voice');
174
-
175
- const handleModeToggle = () => {
176
- window.GuideAI.input.toggleMode();
177
- setInputMode(window.GuideAI.input.getMode());
178
- };
179
-
180
- return (
181
- <div>
182
- <button onClick={handleModeToggle}>
183
- Current Mode: {inputMode}
184
- </button>
185
- </div>
186
- );
187
- }
188
- ```
189
-
190
- #### Auto-Switch to Text on Mobile
191
-
192
- ```typescript
193
- useEffect(() => {
194
- const isMobile = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
195
-
196
- if (isMobile) {
197
- // Switch to text mode on mobile devices
198
- window.GuideAI.input.setMode('text');
199
- }
200
- }, []);
201
- ```
202
-
203
- #### Keyboard Shortcuts
204
-
205
- ```typescript
206
- useEffect(() => {
207
- const handleKeyPress = (event) => {
208
- // Switch input mode with Ctrl/Cmd + I
209
- if ((event.ctrlKey || event.metaKey) && event.key === 'i') {
210
- event.preventDefault();
211
- window.GuideAI.input.toggleMode();
212
- }
213
- };
214
-
215
- document.addEventListener('keydown', handleKeyPress);
216
- return () => document.removeEventListener('keydown', handleKeyPress);
217
- }, []);
218
- ```
219
-
220
- ## Technical Implementation
221
-
222
- ### Message Flow
223
-
224
- 1. **Text Input**: User types message and presses Enter or clicks Send
225
- 2. **Message Logging**: Text is logged to conversation history
226
- 3. **AI Communication**: Message sent to AI via WebRTC data channel
227
- 4. **Response Generation**: AI processes text and generates response
228
- 5. **Audio Response**: AI responds with voice (maintains voice output)
229
-
230
- ### Data Channel Protocol
231
-
232
- Text messages use the same WebRTC protocol as voice:
233
-
234
- ```typescript
235
- // Message structure sent to AI
236
- {
237
- type: "conversation.item.create",
238
- item: {
239
- type: "message",
240
- role: "user",
241
- content: [{
242
- type: "input_text",
243
- text: "User's typed message"
244
- }]
245
- }
246
- }
247
- ```
248
-
249
- ## Styling and Customization
250
-
251
- ### CSS Classes
252
-
253
- - `.guideai-icon-wrapper` - Main microphone button
254
- - `.guideai-transcript-text-input` - Text input container integrated into transcript
255
- - `.guideai-transcript-input-field` - Textarea element
256
- - `.guideai-transcript-send-button` - Send button
257
- - `.guideai-transcript-send-icon` - Send button icon
258
-
259
- ### Custom Styling Example
260
-
261
- ```css
262
- /* Custom text input styling */
263
- .guideai-transcript-input-field {
264
- font-family: 'Your Custom Font', sans-serif;
265
- border-radius: 12px;
266
- }
267
-
268
- .guideai-transcript-send-button {
269
- background: linear-gradient(45deg, #ff6b6b, #ee5a52);
270
- }
271
- ```
272
-
273
- ## Accessibility Features
274
-
275
- - **Keyboard Navigation**: Full keyboard support
276
- - **Screen Readers**: Proper ARIA labels and semantic HTML
277
- - **Focus Management**: Clear focus indicators
278
- - **Alternative Input**: Text alternative for voice-only interface
279
-
280
- ## Best Practices
281
-
282
- ### For Implementation
283
-
284
- 1. **Test Both Modes**: Ensure voice and text modes work seamlessly
285
- 2. **Mobile Optimization**: Consider defaulting to text on mobile
286
- 3. **Clear Instructions**: Provide users with clear mode indicators
287
- 4. **Error Handling**: Handle cases where WebRTC isn't available
288
-
289
- ### For User Experience
290
-
291
- 1. **Mode Persistence**: Consider remembering user's preferred mode
292
- 2. **Visual Feedback**: Ensure users know which mode is active
293
- 3. **Quick Switching**: Make it easy to switch between modes
294
- 4. **Responsive Design**: Ensure text input works on all screen sizes
295
-
296
- ## Troubleshooting
297
-
298
- ### Text Input Not Appearing
299
-
300
- Check that:
301
- 1. `enableTextInput` is set to `true`
302
- 2. Conversation is active
303
- 3. Input mode is set to 'text'
304
- 4. CSS styles are loaded
305
-
306
- ### Toggle Button Not Showing
307
-
308
- Ensure:
309
- 1. `showInputToggle` is not set to `false`
310
- 2. `enableTextInput` is `true`
311
- 3. Conversation is active
312
-
313
- ### Messages Not Sending
314
-
315
- Verify:
316
- 1. WebRTC connection is established
317
- 2. Conversation is active
318
- 3. Input is not empty
319
- 4. No JavaScript errors in console
320
-
321
- This text input feature provides a comprehensive alternative to voice input while maintaining the seamless conversation experience that GuideAI is known for.
@@ -1,267 +0,0 @@
1
- # Transcript Toggle Feature - Usage Guide
2
-
3
- ## Overview
4
-
5
- The GuideAI package now includes a transcript toggle feature that allows users to show/hide the conversation transcript and provides programmatic control over transcript visibility.
6
-
7
- ## Features
8
-
9
- ✅ **Toggle Button**: Optional button that appears in the transcript area (bottom-right corner)
10
- ✅ **Programmatic Control**: Global API methods to control transcript visibility
11
- ✅ **Configurable Default State**: Set whether transcript shows by default
12
- ✅ **Auto-Show/Hide**: Configure whether transcript automatically appears with conversations
13
- ✅ **Visual Feedback**: Clear visual indicators for transcript state
14
-
15
- ## Configuration Options
16
-
17
- ### Basic Configuration
18
-
19
- ```typescript
20
- <GuideAI
21
- organizationKey="your-org-key"
22
- transcript={{
23
- enabled: true, // Show transcript by default (default: true)
24
- showToggleButton: true, // Show the toggle button (default: true)
25
- position: 'right' // Position of transcript (default: 'right')
26
- }}
27
- />
28
- ```
29
-
30
- ### Configuration Options
31
-
32
- ```typescript
33
- interface TranscriptConfig {
34
- // Whether to show transcript by default when conversations start
35
- enabled?: boolean; // default: true
36
-
37
- // Whether to show the toggle button near the main icon
38
- showToggleButton?: boolean; // default: true
39
-
40
- // Position of the transcript box (future enhancement)
41
- position?: 'right' | 'left' | 'top' | 'bottom'; // default: 'right'
42
- }
43
- ```
44
-
45
- ## Usage Examples
46
-
47
- ### 1. Default Configuration (Transcript Enabled)
48
-
49
- ```typescript
50
- // Transcript shows by default with toggle button
51
- <GuideAI organizationKey="your-org-key" />
52
- ```
53
-
54
- ### 2. Transcript Disabled by Default
55
-
56
- ```typescript
57
- <GuideAI
58
- organizationKey="your-org-key"
59
- transcript={{
60
- enabled: false, // Don't show by default
61
- showToggleButton: true // But provide toggle button
62
- }}
63
- />
64
- ```
65
-
66
- ### 3. No Toggle Button (Manual Control Only)
67
-
68
- ```typescript
69
- <GuideAI
70
- organizationKey="your-org-key"
71
- transcript={{
72
- enabled: true,
73
- showToggleButton: false // Hide the toggle button
74
- }}
75
- />
76
- ```
77
-
78
- ### 4. Completely Hidden Transcript
79
-
80
- ```typescript
81
- <GuideAI
82
- organizationKey="your-org-key"
83
- transcript={{
84
- enabled: false,
85
- showToggleButton: false // No button, no auto-show
86
- }}
87
- />
88
- ```
89
-
90
- ## Programmatic Control
91
-
92
- ### Global API Methods
93
-
94
- Access transcript controls via the global `window.GuideAI.transcript` object:
95
-
96
- ```typescript
97
- // Toggle transcript visibility
98
- window.GuideAI.transcript.toggle();
99
-
100
- // Show transcript
101
- window.GuideAI.transcript.show();
102
-
103
- // Hide transcript
104
- window.GuideAI.transcript.hide();
105
-
106
- // Check if transcript is currently visible
107
- const isVisible = window.GuideAI.transcript.isVisible();
108
- console.log('Transcript visible:', isVisible);
109
- ```
110
-
111
- ### Integration Examples
112
-
113
- #### Custom Toggle Button
114
-
115
- ```typescript
116
- function MyCustomControls() {
117
- const [transcriptVisible, setTranscriptVisible] = useState(false);
118
-
119
- const handleToggle = () => {
120
- window.GuideAI.transcript.toggle();
121
- setTranscriptVisible(window.GuideAI.transcript.isVisible());
122
- };
123
-
124
- return (
125
- <button onClick={handleToggle}>
126
- {transcriptVisible ? 'Hide' : 'Show'} Transcript
127
- </button>
128
- );
129
- }
130
- ```
131
-
132
- #### Keyboard Shortcuts
133
-
134
- ```typescript
135
- useEffect(() => {
136
- const handleKeyPress = (event) => {
137
- // Toggle transcript with Ctrl/Cmd + T
138
- if ((event.ctrlKey || event.metaKey) && event.key === 't') {
139
- event.preventDefault();
140
- window.GuideAI.transcript.toggle();
141
- }
142
- };
143
-
144
- document.addEventListener('keydown', handleKeyPress);
145
- return () => document.removeEventListener('keydown', handleKeyPress);
146
- }, []);
147
- ```
148
-
149
- #### Auto-Hide on Mobile
150
-
151
- ```typescript
152
- useEffect(() => {
153
- const isMobile = window.innerWidth < 768;
154
-
155
- if (isMobile) {
156
- // Hide transcript on mobile by default
157
- window.GuideAI.transcript.hide();
158
- }
159
- }, []);
160
- ```
161
-
162
- ## Visual Design
163
-
164
- ### Toggle Button
165
-
166
- - **Position**: Appears as a floating circular button in the bottom-right corner, above the transcript area
167
- - **Icons**: 📄 (when visible) / 📋 (when hidden)
168
- - **Hover Effects**: Scales up and shows tooltip
169
- - **Animation**: Smooth fade-in when conversation starts
170
- - **Design**: Dark themed button with blur effect to match transcript styling
171
-
172
- ### States
173
-
174
- - **Visible**: 📄 icon with full opacity
175
- - **Hidden**: 📋 icon with reduced opacity
176
- - **Hover**: Scale animation and enhanced shadow
177
-
178
- ## Behavior Details
179
-
180
- ### When Toggle Button Appears
181
-
182
- The toggle button only shows when:
183
- 1. `showToggleButton` is not set to `false`
184
- 2. A conversation is active (`isConversationActive === true`)
185
- 3. There are messages in the conversation (`allMessages.length > 0`)
186
-
187
- ### Auto-Show/Hide Logic
188
-
189
- - **Conversation Start**: If `enabled !== false`, transcript shows automatically
190
- - **Conversation End**: If `enabled !== false`, transcript hides automatically
191
- - **Manual Toggle**: User's manual toggle state persists until next conversation start/end
192
-
193
- ### Persistence
194
-
195
- The transcript toggle state does **not** persist across page reloads - it resets to the configured default (`enabled` setting).
196
-
197
- ## Advanced Integration
198
-
199
- ### Custom Positioning (Future Enhancement)
200
-
201
- ```typescript
202
- // Future feature - custom transcript positioning
203
- <GuideAI
204
- transcript={{
205
- position: 'left', // Position transcript on the left side
206
- enabled: true
207
- }}
208
- />
209
- ```
210
-
211
- ### Event Listeners (Future Enhancement)
212
-
213
- ```typescript
214
- // Future feature - listen to transcript visibility changes
215
- window.GuideAI.transcript.onVisibilityChange((isVisible) => {
216
- console.log('Transcript visibility changed:', isVisible);
217
- // Update your UI accordingly
218
- });
219
- ```
220
-
221
- ## Troubleshooting
222
-
223
- ### Toggle Button Not Appearing
224
-
225
- Check that:
226
- 1. `showToggleButton` is not set to `false`
227
- 2. A conversation is active
228
- 3. Messages exist in the conversation
229
- 4. CSS styles are loaded properly
230
-
231
- ### Programmatic Methods Not Working
232
-
233
- Ensure:
234
- 1. GuideAI has finished initializing
235
- 2. You're calling methods after component mount
236
- 3. The global API is available: `window.GuideAI.transcript`
237
-
238
- ### Styling Issues
239
-
240
- The toggle button uses these CSS classes:
241
- - `.guideai-transcript-toggle` - Main button container
242
- - `.guideai-transcript-icon` - Icon styling
243
- - `.guideai-transcript-icon.visible` - When transcript is visible
244
- - `.guideai-transcript-icon.hidden` - When transcript is hidden
245
-
246
- ## Migration Guide
247
-
248
- ### Existing Implementations
249
-
250
- If you're using GuideAI without transcript config, no changes needed:
251
- ```typescript
252
- // This continues to work - transcript enabled by default
253
- <GuideAI organizationKey="your-org-key" />
254
- ```
255
-
256
- ### To Disable Transcript
257
-
258
- ```typescript
259
- // Old: No way to disable
260
- // New: Explicit control
261
- <GuideAI
262
- organizationKey="your-org-key"
263
- transcript={{ enabled: false }}
264
- />
265
- ```
266
-
267
- This implementation provides flexible control over transcript visibility while maintaining backward compatibility with existing code.
package/types/index.d.ts DELETED
@@ -1,24 +0,0 @@
1
- export interface ConversationItem {
2
- event_id?: string;
3
- type: string;
4
- previous_item_id: string | null;
5
- item: Record<string, any>;
6
- timestamp: number;
7
- }
8
- export type RecordingStatus = 'idle' | 'recording' | 'processing' | 'playing' | 'initializing';
9
- export interface GuideAIProps {
10
- apiKey?: string;
11
- organizationKey: string;
12
- position?: {
13
- top?: string;
14
- right?: string;
15
- bottom?: string;
16
- left?: string;
17
- marginTop?: string;
18
- marginRight?: string;
19
- marginBottom?: string;
20
- marginLeft?: string;
21
- transform?: string;
22
- };
23
- onError?: (error: string | Error, context?: string) => void;
24
- }