guideai-app 0.2.9 → 0.3.1

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,310 @@
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. Basic Usage
14
14
 
15
15
  ```jsx
16
+ import React from 'react';
16
17
  import GuideAI from 'guideai-app';
17
18
 
18
19
  function App() {
19
20
  return (
20
21
  <div>
22
+ <h1>My Website</h1>
23
+ <p>Welcome to my site!</p>
24
+
21
25
  <GuideAI
22
26
  organizationKey="your-organization-key"
23
- position={{ bottom: '2rem', right: '2rem' }}
24
- onError={(error) => console.error(error)}
27
+ onError={(error, context) => console.error('GuideAI Error:', error, context)}
25
28
  />
26
29
  </div>
27
30
  );
28
31
  }
29
32
  ```
30
33
 
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) |
34
+ ### 3. Advanced Configuration
40
35
 
41
- ### Position Object
36
+ ```jsx
37
+ import React from 'react';
38
+ import GuideAI from 'guideai-app';
42
39
 
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;
40
+ function App() {
41
+ return (
42
+ <div>
43
+ <h1>My Website</h1>
44
+
45
+ <GuideAI
46
+ organizationKey="your-organization-key"
47
+ position={{
48
+ bottom: '20px',
49
+ right: '20px'
50
+ }}
51
+ onError={(error, context) => console.error('GuideAI Error:', error, context)}
52
+ transcript={{
53
+ enabled: true,
54
+ showToggleButton: true
55
+ }}
56
+ input={{
57
+ defaultMode: 'voice', // 'voice' or 'text'
58
+ enableTextInput: true,
59
+ placeholder: "Type your message..."
60
+ }}
61
+ metadata={{
62
+ initialUserData: {
63
+ userId: 'user123',
64
+ organizationKey: 'your-org',
65
+ userType: 'customer'
66
+ },
67
+ config: {
68
+ trackVisits: true,
69
+ trackInteractions: true
70
+ }
71
+ }}
72
+ />
73
+ </div>
74
+ );
56
75
  }
57
76
  ```
58
77
 
59
- ### Transcript Configuration Object
78
+ ## 📋 Props Reference
60
79
 
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
- ```
80
+ ### Required Props
68
81
 
69
- ### Input Configuration Object
82
+ | Prop | Type | Description |
83
+ |------|------|-------------|
84
+ | `organizationKey` | `string` | Your organization's unique identifier |
70
85
 
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
- }
86
+ ### Optional Props
87
+
88
+ | Prop | Type | Default | Description |
89
+ |------|------|---------|-------------|
90
+ | `position` | `object` | `{ bottom: '20px', right: '20px' }` | CSS positioning for the component |
91
+ | `onError` | `function` | `console.error` | Error handler function |
92
+ | `transcript` | `object` | `{ enabled: true, showToggleButton: true }` | Transcript display options |
93
+ | `input` | `object` | `{ defaultMode: 'voice', enableTextInput: true }` | Input mode configuration |
94
+ | `metadata` | `object` | `{}` | User metadata and tracking options |
95
+
96
+ ### Position Object
97
+
98
+ ```jsx
99
+ position={{
100
+ top?: string, // e.g., '20px'
101
+ right?: string, // e.g., '20px'
102
+ bottom?: string, // e.g., '20px'
103
+ left?: string, // e.g., '20px'
104
+ marginTop?: string, // e.g., '10px'
105
+ marginRight?: string,
106
+ marginBottom?: string,
107
+ marginLeft?: string,
108
+ transform?: string // e.g., 'translateY(-50%)'
109
+ }}
78
110
  ```
79
111
 
80
- ### Examples
112
+ ### Transcript Options
81
113
 
82
- **Basic usage:**
83
114
  ```jsx
84
- <GuideAI
85
- organizationKey="your-org-key"
86
- position={{ bottom: '4rem', left: '50%', marginLeft: '-30px' }}
87
- />
115
+ transcript={{
116
+ enabled: boolean, // Show transcript by default
117
+ showToggleButton: boolean // Show toggle button for transcript
118
+ }}
88
119
  ```
89
120
 
90
- **With text input enabled by default:**
121
+ ### Input Options
122
+
91
123
  ```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
- />
124
+ input={{
125
+ defaultMode: 'voice' | 'text', // Default input mode
126
+ enableTextInput: boolean, // Enable text input option
127
+ placeholder: string // Text input placeholder
128
+ }}
100
129
  ```
101
130
 
102
- **Full configuration:**
131
+ ### Metadata Options
132
+
103
133
  ```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
- />
134
+ metadata={{
135
+ initialUserData: {
136
+ userId: string, // User identifier
137
+ organizationKey: string, // Organization key
138
+ userType: string // User type (e.g., 'customer', 'admin')
139
+ },
140
+ config: {
141
+ trackVisits: boolean, // Track page visits
142
+ trackInteractions: boolean // Track user interactions
143
+ }
144
+ }}
118
145
  ```
119
146
 
120
- ## Text Input Feature
147
+ ## 🎯 Features
121
148
 
122
- GuideAI now supports both voice and text input modes, giving users flexible ways to interact with the AI assistant.
149
+ ### Voice & Text Conversation
150
+ - **Voice Mode**: Click the microphone to start voice conversation
151
+ - **Text Mode**: Type messages directly in the text input
152
+ - **Toggle**: Switch between voice and text modes
123
153
 
124
- ### Features
154
+ ### Conversation Persistence
155
+ - Conversations are automatically saved and restored on page refresh
156
+ - Messages persist for 30 minutes by default
157
+ - Seamless conversation continuation
125
158
 
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
159
+ ### Element Highlighting
160
+ - AI can highlight and interact with page elements
161
+ - Visual cursor guidance for user actions
162
+ - Support for CSS selectors and XPath
132
163
 
133
- ### Input Props
164
+ ### Transcript Display
165
+ - Real-time conversation transcript
166
+ - Toggle visibility with the transcript button
167
+ - Message timestamps and sender identification
134
168
 
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 |
169
+ ### User Tracking
170
+ - Visit tracking and analytics
171
+ - User interaction monitoring
172
+ - Metadata collection and syncing
141
173
 
142
- ### How to Use Text Input
174
+ ## 🔧 API Methods
143
175
 
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
176
+ The component exposes several methods through the global `window.GuideAI` object:
149
177
 
150
- ### Accessibility Features
178
+ ### Transcript Control
179
+ ```javascript
180
+ // Toggle transcript visibility
181
+ window.GuideAI.transcript.toggle();
151
182
 
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
183
+ // Show transcript
184
+ window.GuideAI.transcript.show();
156
185
 
157
- ## Transcript Feature
186
+ // Hide transcript
187
+ window.GuideAI.transcript.hide();
158
188
 
159
- GuideAI includes a beautiful transcript interface that displays conversations between users and the AI in a transparent Apple-style box.
189
+ // Check if transcript is visible
190
+ const isVisible = window.GuideAI.transcript.isVisible();
191
+ ```
192
+
193
+ ### Metadata Tracking
194
+ ```javascript
195
+ // Track user login
196
+ window.GuideAI.metadata.trackLogin({
197
+ userId: 'user123',
198
+ userType: 'customer'
199
+ });
200
+
201
+ // Update user information
202
+ window.GuideAI.metadata.updateUserInfo({
203
+ userId: 'user123',
204
+ preferences: { theme: 'dark' }
205
+ });
206
+
207
+ // Track custom events
208
+ window.GuideAI.metadata.trackCustomEvent('button_click', {
209
+ buttonId: 'submit',
210
+ page: 'checkout'
211
+ });
212
+
213
+ // Get current metadata
214
+ const metadata = window.GuideAI.metadata.getMetadata();
215
+
216
+ // Force sync metadata
217
+ await window.GuideAI.metadata.syncMetadata();
218
+
219
+ // Reset session tracking (call on login)
220
+ window.GuideAI.metadata.resetSessionVisitTracking();
221
+
222
+ // Manually track a visit
223
+ window.GuideAI.metadata.trackVisitManually();
224
+ ```
160
225
 
161
- ### Features
226
+ ## 🎨 Styling
162
227
 
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
228
+ 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.
229
+
230
+ ### Custom Positioning Examples
231
+
232
+ ```jsx
233
+ // Top-right corner
234
+ <GuideAI
235
+ organizationKey="your-key"
236
+ position={{ top: '20px', right: '20px' }}
237
+ />
169
238
 
170
- ### How to Use
239
+ // Bottom-left corner
240
+ <GuideAI
241
+ organizationKey="your-key"
242
+ position={{ bottom: '20px', left: '20px' }}
243
+ />
171
244
 
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
245
+ // Centered on the right
246
+ <GuideAI
247
+ organizationKey="your-key"
248
+ position={{
249
+ top: '50%',
250
+ right: '20px',
251
+ transform: 'translateY(-50%)'
252
+ }}
253
+ />
254
+ ```
178
255
 
179
- ### Transcript Interface
256
+ ## 🚨 Error Handling
180
257
 
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
258
+ The component includes comprehensive error handling:
186
259
 
187
- ### Styling
260
+ ```jsx
261
+ <GuideAI
262
+ organizationKey="your-key"
263
+ onError={(error, context) => {
264
+ console.error('GuideAI Error:', error);
265
+ console.log('Context:', context);
266
+
267
+ // Send to your error tracking service
268
+ // analytics.track('guideai_error', { error, context });
269
+ }}
270
+ />
271
+ ```
272
+
273
+ ## 🔒 Security
274
+
275
+ - All API calls are made to secure endpoints
276
+ - User data is handled according to privacy standards
277
+ - No sensitive information is logged or stored locally
278
+ - Conversations are encrypted in transit
279
+
280
+ ## 📱 Browser Support
281
+
282
+ - Chrome 88+
283
+ - Firefox 85+
284
+ - Safari 14+
285
+ - Edge 88+
286
+
287
+ ## 🛠️ Development
288
+
289
+ ### Building from Source
290
+
291
+ ```bash
292
+ git clone <repository>
293
+ cd guide-ai-package
294
+ npm install
295
+ npm run build
296
+ ```
297
+
298
+ ### Testing
299
+
300
+ ```bash
301
+ npm run dev # Start development server
302
+ ```
188
303
 
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
304
+ ## 📄 License
194
305
 
195
- ## Migration from Voice-Only Versions
306
+ ISC License
196
307
 
197
- If you're upgrading from a voice-only version:
308
+ ## 🤝 Support
198
309
 
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
310
+ For support and questions, please refer to the documentation or contact the development team.