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.
package/README.md CHANGED
@@ -1,202 +1,321 @@
1
- # Guide AI
1
+ # GuideAI - AI-Powered Guide Component
2
2
 
3
- A React component that provides AI-powered guidance with voice interaction, text input, and element highlighting capabilities.
3
+ A React component that provides an AI-powered guide assistant for any webpage. Features voice and text conversation, element highlighting, and conversation persistence.
4
4
 
5
- ## Installation
5
+ ## 🚀 Quick Start
6
+
7
+ ### 1. Install the Package
6
8
 
7
9
  ```bash
8
10
  npm install guideai-app
9
- # or
10
- yarn add guideai-app
11
11
  ```
12
12
 
13
- ## Usage
13
+ ### 2. Environment Variables (Optional)
14
+
15
+ If you plan to use Gemini AI features, set the following environment variable:
16
+
17
+ ```bash
18
+ # In your .env file or environment
19
+ GEMINI_API_KEY=your_gemini_api_key_here
20
+ ```
21
+
22
+ **Note**: The package will work without this key, but some AI features may be limited.
23
+
24
+ ### 3. Basic Usage
14
25
 
15
26
  ```jsx
27
+ import React from 'react';
16
28
  import GuideAI from 'guideai-app';
17
29
 
18
30
  function App() {
19
31
  return (
20
32
  <div>
33
+ <h1>My Website</h1>
34
+ <p>Welcome to my site!</p>
35
+
21
36
  <GuideAI
22
37
  organizationKey="your-organization-key"
23
- position={{ bottom: '2rem', right: '2rem' }}
24
- onError={(error) => console.error(error)}
38
+ onError={(error, context) => console.error('GuideAI Error:', error, context)}
25
39
  />
26
40
  </div>
27
41
  );
28
42
  }
29
43
  ```
30
44
 
31
- ## Props
32
-
33
- | Prop | Type | Required | Description |
34
- |------|------|----------|-------------|
35
- | `organizationKey` | `string` | Yes | Your organization key for workflows |
36
- | `position` | `object` | No | Positioning configuration for the component |
37
- | `onError` | `function` | No | Error handler callback |
38
- | `transcript` | `object` | No | Transcript feature configuration |
39
- | `input` | `object` | No | Input mode configuration (voice/text) |
45
+ ### 4. Advanced Configuration
40
46
 
41
- ### Position Object
47
+ ```jsx
48
+ import React from 'react';
49
+ import GuideAI from 'guideai-app';
42
50
 
43
- The `position` prop accepts an object with CSS positioning properties:
44
-
45
- ```typescript
46
- position?: {
47
- top?: string;
48
- right?: string;
49
- bottom?: string;
50
- left?: string;
51
- marginTop?: string;
52
- marginRight?: string;
53
- marginBottom?: string;
54
- marginLeft?: string;
55
- transform?: string;
51
+ function App() {
52
+ return (
53
+ <div>
54
+ <h1>My Website</h1>
55
+
56
+ <GuideAI
57
+ organizationKey="your-organization-key"
58
+ position={{
59
+ bottom: '20px',
60
+ right: '20px'
61
+ }}
62
+ onError={(error, context) => console.error('GuideAI Error:', error, context)}
63
+ transcript={{
64
+ enabled: true,
65
+ showToggleButton: true
66
+ }}
67
+ input={{
68
+ defaultMode: 'voice', // 'voice' or 'text'
69
+ enableTextInput: true,
70
+ placeholder: "Type your message..."
71
+ }}
72
+ metadata={{
73
+ initialUserData: {
74
+ userId: 'user123',
75
+ organizationKey: 'your-org',
76
+ userType: 'customer'
77
+ },
78
+ config: {
79
+ trackVisits: true,
80
+ trackInteractions: true
81
+ }
82
+ }}
83
+ />
84
+ </div>
85
+ );
56
86
  }
57
87
  ```
58
88
 
59
- ### Transcript Configuration Object
89
+ ## 📋 Props Reference
60
90
 
61
- ```typescript
62
- transcript?: {
63
- enabled?: boolean; // Show transcript (default: true)
64
- showToggleButton?: boolean; // Show transcript toggle (default: true)
65
- position?: 'right' | 'left' | 'top' | 'bottom'; // Transcript position
66
- }
67
- ```
91
+ ### Required Props
68
92
 
69
- ### Input Configuration Object
93
+ | Prop | Type | Description |
94
+ |------|------|-------------|
95
+ | `organizationKey` | `string` | Your organization's unique identifier |
70
96
 
71
- ```typescript
72
- input?: {
73
- enableTextInput?: boolean; // Enable text input (default: true)
74
- showInputToggle?: boolean; // Show mode toggle button (default: true)
75
- defaultMode?: 'voice' | 'text'; // Default input mode (default: 'voice')
76
- placeholder?: string; // Text input placeholder
77
- }
97
+ ### Optional Props
98
+
99
+ | Prop | Type | Default | Description |
100
+ |------|------|---------|-------------|
101
+ | `position` | `object` | `{ bottom: '20px', right: '20px' }` | CSS positioning for the component |
102
+ | `onError` | `function` | `console.error` | Error handler function |
103
+ | `transcript` | `object` | `{ enabled: true, showToggleButton: true }` | Transcript display options |
104
+ | `input` | `object` | `{ defaultMode: 'voice', enableTextInput: true }` | Input mode configuration |
105
+ | `metadata` | `object` | `{}` | User metadata and tracking options |
106
+
107
+ ### Position Object
108
+
109
+ ```jsx
110
+ position={{
111
+ top?: string, // e.g., '20px'
112
+ right?: string, // e.g., '20px'
113
+ bottom?: string, // e.g., '20px'
114
+ left?: string, // e.g., '20px'
115
+ marginTop?: string, // e.g., '10px'
116
+ marginRight?: string,
117
+ marginBottom?: string,
118
+ marginLeft?: string,
119
+ transform?: string // e.g., 'translateY(-50%)'
120
+ }}
78
121
  ```
79
122
 
80
- ### Examples
123
+ ### Transcript Options
81
124
 
82
- **Basic usage:**
83
125
  ```jsx
84
- <GuideAI
85
- organizationKey="your-org-key"
86
- position={{ bottom: '4rem', left: '50%', marginLeft: '-30px' }}
87
- />
126
+ transcript={{
127
+ enabled: boolean, // Show transcript by default
128
+ showToggleButton: boolean // Show toggle button for transcript
129
+ }}
88
130
  ```
89
131
 
90
- **With text input enabled by default:**
132
+ ### Input Options
133
+
91
134
  ```jsx
92
- <GuideAI
93
- organizationKey="your-org-key"
94
- position={{ top: '20px', right: '20px' }}
95
- input={{
96
- defaultMode: 'text',
97
- placeholder: "Ask me anything..."
98
- }}
99
- />
135
+ input={{
136
+ defaultMode: 'voice' | 'text', // Default input mode
137
+ enableTextInput: boolean, // Enable text input option
138
+ placeholder: string // Text input placeholder
139
+ }}
100
140
  ```
101
141
 
102
- **Full configuration:**
142
+ ### Metadata Options
143
+
103
144
  ```jsx
104
- <GuideAI
105
- organizationKey="your-organization-key"
106
- position={{ bottom: '2rem', right: '2rem' }}
107
- transcript={{
108
- enabled: true,
109
- showToggleButton: true
110
- }}
111
- input={{
112
- enableTextInput: true,
113
- defaultMode: 'voice',
114
- placeholder: "Type your message..."
115
- }}
116
- onError={(error) => console.error(error)}
117
- />
145
+ metadata={{
146
+ initialUserData: {
147
+ userId: string, // User identifier
148
+ organizationKey: string, // Organization key
149
+ userType: string // User type (e.g., 'customer', 'admin')
150
+ },
151
+ config: {
152
+ trackVisits: boolean, // Track page visits
153
+ trackInteractions: boolean // Track user interactions
154
+ }
155
+ }}
118
156
  ```
119
157
 
120
- ## Text Input Feature
158
+ ## 🎯 Features
121
159
 
122
- GuideAI now supports both voice and text input modes, giving users flexible ways to interact with the AI assistant.
160
+ ### Voice & Text Conversation
161
+ - **Voice Mode**: Click the microphone to start voice conversation
162
+ - **Text Mode**: Type messages directly in the text input
163
+ - **Toggle**: Switch between voice and text modes
123
164
 
124
- ### Features
165
+ ### Conversation Persistence
166
+ - Conversations are automatically saved and restored on page refresh
167
+ - Messages persist for 30 minutes by default
168
+ - Seamless conversation continuation
125
169
 
126
- - **Dual Input Modes**: Switch seamlessly between voice and text input
127
- - **Text Input Interface**: Clean text area integrated into the transcript box
128
- - **Input Mode Toggle**: Dedicated button to switch between voice and text modes
129
- - **Real-time Text Chat**: Type messages and receive AI responses instantly
130
- - **Keyboard Shortcuts**: Press Enter to send messages quickly
131
- - **Auto-enabled**: Text input is enabled by default for better accessibility
170
+ ### Element Highlighting
171
+ - AI can highlight and interact with page elements
172
+ - Visual cursor guidance for user actions
173
+ - Support for CSS selectors and XPath
132
174
 
133
- ### Input Props
175
+ ### Transcript Display
176
+ - Real-time conversation transcript
177
+ - Toggle visibility with the transcript button
178
+ - Message timestamps and sender identification
134
179
 
135
- | Prop | Type | Default | Description |
136
- |------|------|---------|-------------|
137
- | `enableTextInput` | boolean | `true` | Enable text input functionality |
138
- | `showInputToggle` | boolean | `true` | Show the voice/text mode toggle button |
139
- | `defaultMode` | `'voice' \| 'text'` | `'voice'` | Default input mode when conversation starts |
140
- | `placeholder` | string | `"Type your message..."` | Placeholder text for the text input field |
180
+ ### User Tracking
181
+ - Visit tracking and analytics
182
+ - User interaction monitoring
183
+ - Metadata collection and syncing
184
+
185
+ ## 🔧 API Methods
186
+
187
+ The component exposes several methods through the global `window.GuideAI` object:
188
+
189
+ ### Transcript Control
190
+ ```javascript
191
+ // Toggle transcript visibility
192
+ window.GuideAI.transcript.toggle();
193
+
194
+ // Show transcript
195
+ window.GuideAI.transcript.show();
196
+
197
+ // Hide transcript
198
+ window.GuideAI.transcript.hide();
199
+
200
+ // Check if transcript is visible
201
+ const isVisible = window.GuideAI.transcript.isVisible();
202
+ ```
203
+
204
+ ### Metadata Tracking
205
+ ```javascript
206
+ // Track user login
207
+ window.GuideAI.metadata.trackLogin({
208
+ userId: 'user123',
209
+ userType: 'customer'
210
+ });
211
+
212
+ // Update user information
213
+ window.GuideAI.metadata.updateUserInfo({
214
+ userId: 'user123',
215
+ preferences: { theme: 'dark' }
216
+ });
217
+
218
+ // Track custom events
219
+ window.GuideAI.metadata.trackCustomEvent('button_click', {
220
+ buttonId: 'submit',
221
+ page: 'checkout'
222
+ });
223
+
224
+ // Get current metadata
225
+ const metadata = window.GuideAI.metadata.getMetadata();
226
+
227
+ // Force sync metadata
228
+ await window.GuideAI.metadata.syncMetadata();
229
+
230
+ // Reset session tracking (call on login)
231
+ window.GuideAI.metadata.resetSessionVisitTracking();
232
+
233
+ // Manually track a visit
234
+ window.GuideAI.metadata.trackVisitManually();
235
+ ```
236
+
237
+ ## 🎨 Styling
238
+
239
+ The component includes its own styles and will automatically inject them. The component uses fixed positioning by default and will appear in the bottom-right corner.
240
+
241
+ ### Custom Positioning Examples
242
+
243
+ ```jsx
244
+ // Top-right corner
245
+ <GuideAI
246
+ organizationKey="your-key"
247
+ position={{ top: '20px', right: '20px' }}
248
+ />
141
249
 
142
- ### How to Use Text Input
250
+ // Bottom-left corner
251
+ <GuideAI
252
+ organizationKey="your-key"
253
+ position={{ bottom: '20px', left: '20px' }}
254
+ />
143
255
 
144
- 1. **Start a Conversation**: Click the GuideAI button to begin
145
- 2. **Switch to Text Mode**: Click the toggle button next to the main GuideAI button
146
- 3. **Type Your Message**: Use the text area at the bottom of the transcript box
147
- 4. **Send Message**: Press Enter or click the send button
148
- 5. **Switch Back**: Click the toggle button again to return to voice mode
256
+ // Centered on the right
257
+ <GuideAI
258
+ organizationKey="your-key"
259
+ position={{
260
+ top: '50%',
261
+ right: '20px',
262
+ transform: 'translateY(-50%)'
263
+ }}
264
+ />
265
+ ```
149
266
 
150
- ### Accessibility Features
267
+ ## 🚨 Error Handling
151
268
 
152
- - **Keyboard Navigation**: Full keyboard support for text input
153
- - **Default Enabled**: Text input works out of the box without configuration
154
- - **Fallback Support**: Automatically enables text mode if microphone access is denied
155
- - **Visual Indicators**: Clear visual feedback for active input mode
269
+ The component includes comprehensive error handling:
156
270
 
157
- ## Transcript Feature
271
+ ```jsx
272
+ <GuideAI
273
+ organizationKey="your-key"
274
+ onError={(error, context) => {
275
+ console.error('GuideAI Error:', error);
276
+ console.log('Context:', context);
277
+
278
+ // Send to your error tracking service
279
+ // analytics.track('guideai_error', { error, context });
280
+ }}
281
+ />
282
+ ```
158
283
 
159
- GuideAI includes a beautiful transcript interface that displays conversations between users and the AI in a transparent Apple-style box.
284
+ ## 🔒 Security
160
285
 
161
- ### Features
286
+ - All API calls are made to secure endpoints
287
+ - User data is handled according to privacy standards
288
+ - No sensitive information is logged or stored locally
289
+ - Conversations are encrypted in transit
162
290
 
163
- - **Glassmorphism Design**: Transparent background with backdrop blur effects
164
- - **Apple-style Interface**: Clean, modern design inspired by Apple's UI principles
165
- - **Real-time Updates**: Messages appear as they're exchanged
166
- - **Timestamps**: Each message shows when it was sent
167
- - **Auto-scroll**: Automatically scrolls to the latest messages
168
- - **Responsive**: Works perfectly on all device sizes
291
+ ## 📱 Browser Support
169
292
 
170
- ### How to Use
293
+ - Chrome 88+
294
+ - Firefox 85+
295
+ - Safari 14+
296
+ - Edge 88+
171
297
 
172
- 1. Start a conversation with GuideAI by clicking the microphone button
173
- 2. The transcript automatically appears as an overlay when the conversation begins
174
- 3. The transcript shows all messages with clear visual distinction between user and AI messages
175
- 4. Messages appear in real-time as the conversation progresses
176
- 5. Click the "×" button or click outside the transcript to close it
177
- 6. The transcript automatically closes when the conversation ends
298
+ ## 🛠️ Development
178
299
 
179
- ### Transcript Interface
300
+ ### Building from Source
180
301
 
181
- The transcript interface includes:
182
- - **Header**: Shows "Conversation Transcript" with a close button
183
- - **Messages**: Chat-like interface with different styles for user and AI messages
184
- - **Timestamps**: Each message displays the time it was sent
185
- - **Footer**: Shows the total number of messages in the conversation
302
+ ```bash
303
+ git clone <repository>
304
+ cd guide-ai-package
305
+ npm install
306
+ npm run build
307
+ ```
308
+
309
+ ### Testing
186
310
 
187
- ### Styling
311
+ ```bash
312
+ npm run dev # Start development server
313
+ ```
188
314
 
189
- The transcript uses modern CSS features including:
190
- - `backdrop-filter: blur()` for the glassmorphism effect
191
- - CSS animations for smooth transitions
192
- - Responsive design that adapts to different screen sizes
193
- - Custom scrollbar styling for a polished look
315
+ ## 📄 License
194
316
 
195
- ## Migration from Voice-Only Versions
317
+ ISC License
196
318
 
197
- If you're upgrading from a voice-only version:
319
+ ## 🤝 Support
198
320
 
199
- - **No Breaking Changes**: Existing implementations continue to work unchanged
200
- - **Text Input Enabled**: Text input is now available by default
201
- - **Disable if Needed**: Set `input={{ enableTextInput: false }}` to disable text input
202
- - **Voice Still Default**: Voice mode remains the default interaction method
321
+ For support and questions, please refer to the documentation or contact the development team.