@snf/access-qa-bot 2.1.0-rc.7 → 2.3.0-beta.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,8 +1,6 @@
1
- # Q&A Bot
1
+ # ACCESS Q&A Bot
2
2
 
3
- A React component for integrating the Q&A Bot into your application. The bot can operate in two modes: **floating** (chat button that opens/closes a window) or **embedded** (always visible inline).
4
-
5
- **Architecture**: Everything is React-backed for consistency and simplicity. HTML/plain JS usage loads a React-based standalone bundle.
3
+ A React component for integrating the ACCESS Q&A Bot into your application. Features intelligent Q&A responses, support ticket creation with ProForma integration, and user feedback collection. Also includes a standalone bundle for plain HTML/JS usage.
6
4
 
7
5
  ## Installation
8
6
 
@@ -27,106 +25,64 @@ npm run build
27
25
  npx serve
28
26
  ```
29
27
 
30
- ### Floating vs Embedded Modes
28
+ ## Features
29
+
30
+ - **🤖 Intelligent Q&A**: AI-powered responses to user questions about ACCESS
31
+ - **🎫 Support Tickets**: Create help tickets for general support, ACCESS login issues, and resource provider login problems
32
+ - **📝 Feedback Collection**: Gather user feedback and suggestions
33
+ - **👤 User Pre-population**: Auto-fill forms with user info when logged in
34
+ - **🎨 Rich Formatting**: Support for HTML and Markdown in responses
35
+ - **♿ Accessibility**: Full screen reader support and keyboard navigation
36
+ - **📱 Responsive**: Works on desktop and mobile devices
37
+
38
+ ### Display Modes
31
39
 
32
40
  The Q&A Bot supports two display modes:
33
41
 
34
42
  - **Floating Mode** (default): Shows a chat button that opens/closes a floating chat window
35
43
  - **Embedded Mode**: Always visible, embedded directly in the page content
36
44
 
37
- **All integration methods support both modes**, but have different defaults:
38
-
39
- | Method | Default Mode | Override |
40
- |--------|--------------|----------|
41
- | Element ID (`#qa-bot`) | Floating | Set `embedded: true` |
42
- | CSS Class (`.embedded-qa-bot`) | Embedded | n/a |
43
- | JavaScript API | Floating | Set `embedded: true` |
45
+ ## Available Flows
46
+
47
+ The bot supports several conversation flows:
48
+
49
+ ### 🤖 Q&A Flow
50
+ - Ask questions about ACCESS resources, services, and documentation
51
+ - Receive AI-powered responses with HTML and Markdown formatting
52
+ - Built-in feedback system with thumbs up/down options after each response
53
+ - Automatic feedback tracking and analytics
54
+ - Users can provide feedback or continue asking questions immediately
55
+ - Negative feedback offers direct path to support ticket creation
56
+ - Requires user to be logged in
57
+
58
+ ### 🎫 Support Ticket Flows
59
+ - **General Help**: Create support tickets for any ACCESS-related issues
60
+ - **ACCESS Login**: Get help with ACCESS website login problems
61
+ - **Resource Login**: Get help with resource provider login issues
62
+ - All flows support file attachments and are integrated with JSM ProForma
63
+
64
+ ### 📝 Feedback Flow
65
+ - Collect user feedback and suggestions
66
+ - Optional file attachments for screenshots or documents
67
+
68
+ ### 🔒 Security Incident Flow
69
+ - Report security issues, vulnerabilities, and incidents
70
+ - Dedicated priority levels: Critical, High, Medium, Low
71
+ - Direct routing to ACCESS cybersecurity team (Service Desk ID: 3)
72
+ - Support for file attachments (screenshots, logs, evidence)
73
+ - Professional incident tracking with ticket reference links
74
+ - User contact information pre-population when logged in
44
75
 
45
76
  ## Integration Methods
46
77
 
47
- ### Method 1: Auto-Detection by Element ID (Floating by Default)
48
-
49
- Simply add a div with id `qa-bot` to your HTML:
50
-
51
- ```html
52
- <script src="https://unpkg.com/@snf/access-qa-bot@0.2.0/dist/access-qa-bot.standalone.js"></script>
53
-
54
- <!-- Automatically creates a floating chat button -->
55
- <div id="qa-bot"></div>
56
- ```
57
-
58
- ### Method 2: Auto-Detection by CSS Class (Embedded by Default)
59
-
60
- Use the `embedded-qa-bot` class with optional data attributes:
61
-
62
- ```html
63
- <script src="https://unpkg.com/@snf/access-qa-bot@0.2.0/dist/access-qa-bot.standalone.js"></script>
64
-
65
- <!-- Automatically creates an embedded chat widget -->
66
- <div class="embedded-qa-bot"
67
- data-welcome="Hello!"></div>
68
- ```
69
-
70
- ### Method 3: Programmatic JavaScript API (Floating by Default)
71
-
72
- Call the `qaBot()` function with full control:
73
-
74
- ```html
75
- <script src="https://unpkg.com/@snf/access-qa-bot@0.2.0/dist/access-qa-bot.standalone.js"></script>
78
+ The QABot can be integrated using a standalone javascript function, or as a react/preact component.
76
79
 
77
- <div id="my-bot-container"></div>
80
+ ### React Component
78
81
 
79
- <script>
80
- // Check if user is logged in by looking for auth cookie
81
- function isUserLoggedIn() {
82
- return document.cookie.split(';').some(cookie => {
83
- return cookie.trim().startsWith('SESSaccesscisso=');
84
- });
85
- }
86
-
87
- window.addEventListener('load', function() {
88
- const botController = qaBot({
89
- target: document.getElementById('my-bot-container'),
90
- embedded: false, // false = floating (default), true = embedded
91
- welcome: "Custom welcome message!",
92
- isLoggedIn: isUserLoggedIn(),
93
- defaultOpen: false,
94
- });
95
-
96
- // Use the controller to interact with the bot
97
- botController.addMessage("Hello from JavaScript!");
98
- botController.openChat(); // Only works in floating mode
99
- });
100
- </script>
101
- ```
102
-
103
- ## Programmatic Control
104
-
105
- When using the JavaScript API in plain HTML/JS (requires standalone bundle), you get a controller object with these methods:
106
-
107
- ```javascript
108
- const botController = qaBot({...});
109
-
110
- // Add a message to the chat
111
- botController.addMessage("Hello World!");
112
-
113
- // Set user login status
114
- botController.setBotIsLoggedIn(true);
115
-
116
- // Control chat window (floating mode only)
117
- botController.openChat();
118
- botController.closeChat();
119
- botController.toggleChat();
120
-
121
- // Cleanup
122
- botController.destroy();
123
- ```
124
-
125
- **Note**: The `qaBot()` function requires the standalone bundle (`access-qa-bot.standalone.js`) to be loaded first. React/Preact applications should use the `<QABot />` component instead.
126
-
127
- ## As a React Component
128
-
129
- For React applications, import and use the component directly. If you want to be able to imperatively add a message to the chat, you can use the ref to do so.
82
+ For React applications, import and use the component directly.
83
+ - To control the chat programmatically, manage `open` and `isLoggedIn` state in your parent component.
84
+ - Use `onOpenChange` to keep your state in sync with user interactions.
85
+ - You can imperatively add a message to the bot using the `addMessage` function
130
86
 
131
87
  ```jsx
132
88
  import React, { useRef, useState } from 'react';
@@ -166,8 +122,8 @@ function MyApp() {
166
122
  </button>
167
123
 
168
124
  <QABot
169
- ref={botRef} // This is only needed if you want to add a message from outside the flow
170
- embedded={false} // true for embedded, false for floating
125
+ ref={botRef} // only needed if you want use the addMessage function
126
+ embedded={false}
171
127
  isLoggedIn={isLoggedIn}
172
128
  open={chatOpen}
173
129
  onOpenChange={setChatOpen}
@@ -179,28 +135,78 @@ function MyApp() {
179
135
  }
180
136
  ```
181
137
 
182
- **React Component Notes:**
183
- - Uses **controlled component pattern**: manage `open` and `isLoggedIn` state in your parent component
184
- - `onOpenChange` callback receives the new open state when user interacts with chat
185
- - For programmatic message injection, use the ref: `botRef.current?.addMessage("Hello!")`
186
- - `defaultOpen` prop not available - use `open` prop with `useState` instead
187
- - For state management (login, chat open/close), use props and state instead of imperative methods
188
-
189
- ## Configuration Properties
190
-
191
- | Property | Type | Description |
192
- |----------|------|-------------|
193
- | `apiKey` / `api-key` | string | API key for authentication (defaults to demo key) |
194
- | `defaultOpen` / `default-open` | boolean | Whether floating chat opens initially (ignored in embedded mode) **React Component: Use `open` prop instead** |
195
- | `embedded` | boolean | **false** = floating mode, **true** = embedded mode |
196
- | `isLoggedIn` / `is-logged-in` | boolean | Sets initial login state and reacts to changes |
197
- | `loginUrl` / `login-url` | string | URL to redirect for login (default: '/login') |
198
- | `open` | boolean | **React Component only**: Controls chat window open state (floating mode only) |
199
- | `onOpenChange` | function | **React Component only**: Callback when chat window open state changes |
200
- | `ringEffect` / `ring-effect` | boolean | Enable phone ring animation on tooltip (floating mode only) |
201
- | `welcome` | string | Welcome message shown to the user |
202
-
203
- **Note**: The React component uses a controlled component pattern with `open`/`onOpenChange`, while the JavaScript API uses `defaultOpen` for initial state.
138
+ #### React Component Props
139
+
140
+ | Property | Type | Default | Description |
141
+ |----------|------|---------|-------------|
142
+ | `apiKey` | string | `"demo-key"` | API key for authentication |
143
+ | `embedded` | boolean | `false` | Floating or embedded mode |
144
+ | `isLoggedIn` | boolean | `false` | User login state |
145
+ | `loginUrl` | string | `"/login"` | Login redirect URL |
146
+ | `open` | boolean | - | Controls chat window (floating mode only) |
147
+ | `onOpenChange` | function | - | Chat window state change callback |
148
+ | `ringEffect` | boolean | `false` | Phone ring animation on tooltip |
149
+ | `welcome` | string | - | Welcome message |
150
+ | `userEmail` | string | - | User's email (pre-populates ticket forms when logged in) |
151
+ | `userName` | string | - | User's display name (pre-populates ticket forms when logged in) |
152
+ | `username` | string | - | User's username/ACCESS ID (pre-populates ticket forms when logged in) |
153
+
154
+ ### Standalone Javascript
155
+
156
+ ```html
157
+ <script src="https://unpkg.com/@snf/access-qa-bot@2.x/dist/access-qa-bot.standalone.js"></script>
158
+
159
+ <div id="qa-bot"></div>
160
+
161
+ <script>
162
+ qaBot({
163
+ target: document.getElementById('qa-bot'),
164
+ embedded: false,
165
+ welcome: "Custom welcome message!",
166
+ defaultOpen: false,
167
+ });
168
+ </script>
169
+ ```
170
+
171
+ #### Programmatic Control
172
+
173
+ When using the JavaScript API in plain HTML/JS (requires standalone bundle), you get a controller object with imperative methods:
174
+
175
+ ```javascript
176
+ const botController = qaBot({
177
+ target: document.getElementById('qa-bot'),
178
+ embedded: false,
179
+ welcome: "Custom welcome message!",
180
+ defaultOpen: false,
181
+ });
182
+
183
+ botController.addMessage("Hello World!");
184
+ botController.setBotIsLoggedIn(true);
185
+ // (floating mode only)
186
+ botController.openChat();
187
+ botController.closeChat();
188
+ botController.toggleChat();
189
+ // Cleanup
190
+ botController.destroy();
191
+ ```
192
+
193
+ #### JavaScript API Configuration
194
+
195
+ | Property | Type | Default | Description |
196
+ |----------|------|---------|-------------|
197
+ | `target` | HTMLElement | - | **Required**: DOM element to render into |
198
+ | `apiKey` | string | `"demo-key"` | API key for authentication |
199
+ | `defaultOpen` | boolean | `false` | Initial chat window state |
200
+ | `embedded` | boolean | `false` | Floating or embedded mode |
201
+ | `isLoggedIn` | boolean | `false` | User login state |
202
+ | `loginUrl` | string | `"/login"` | Login redirect URL |
203
+ | `ringEffect` | boolean | `false` | Phone ring animation on tooltip |
204
+ | `welcome` | string | - | Welcome message |
205
+ | `userEmail` | string | - | User's email (pre-populates ticket forms when logged in) |
206
+ | `userName` | string | - | User's display name (pre-populates ticket forms when logged in) |
207
+ | `username` | string | - | User's username/ACCESS ID (pre-populates ticket forms when logged in) |
208
+
209
+ > **More Examples**: See `index.html` in this repository for examples including login state management, embedded mode, and programmatic control. Run the react app to see the same in a react context.
204
210
 
205
211
  ### CSS Custom Properties (Theming)
206
212
 
@@ -214,77 +220,169 @@ Customize the appearance by setting CSS custom properties on the container:
214
220
  "></div>
215
221
  ```
216
222
 
217
- ## Direct CDN Deployment
223
+ ## Configuration
218
224
 
219
- For websites that don't use npm, include directly via CDN:
225
+ ### Environment Variables
220
226
 
221
- ```html
222
- <!-- CSS (optional, for embedded styling) -->
223
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/necyberteam/qa-bot@v0.2.0/build/static/css/main.css">
224
-
225
- <!-- JavaScript -->
226
- <script src="https://cdn.jsdelivr.net/gh/necyberteam/qa-bot@v0.2.0/dist/access-qa-bot.standalone.js"></script>
227
+ For React applications, you can set these environment variables:
227
228
 
228
- <!-- Your content -->
229
- <div id="qa-bot"></div>
229
+ ```bash
230
+ REACT_APP_API_KEY=your-api-key-here
230
231
  ```
231
232
 
232
- ## Development and Testing
233
+ ### API Integration
234
+
235
+ The bot integrates with the ACCESS Q&A API and JSM (Jira Service Management) for ticket creation. Configure your backend endpoints to handle:
236
+
237
+ - Q&A queries with streaming responses
238
+ - Support ticket creation with ProForma field mapping
239
+ - File upload processing
240
+ - User authentication and session management
241
+
242
+ ## Development & Release
243
+
244
+ ### Building the Library
245
+
246
+ To build the distributable library files:
233
247
 
234
- ### Development Server (React Implementation)
235
248
  ```bash
236
- npm start
237
- # Opens http://localhost:3000 with React dev server
249
+ npm run build:lib
238
250
  ```
239
251
 
240
- ### Testing Standalone Integration
252
+ This creates the distribution files in the `dist/` directory:
253
+ - `access-qa-bot.js` (ES module)
254
+ - `access-qa-bot.umd.cjs` (UMD/CommonJS)
255
+ - `access-qa-bot.standalone.js` (Standalone version)
256
+
257
+ ### NPM Beta Release
258
+
259
+ To release a beta version:
260
+
241
261
  ```bash
242
- # Build the library and project
262
+ # 1. Update version to beta (without git operations)
263
+ npm version 2.2.0-beta.0 --no-git-tag-version
264
+
265
+ # 2. Build the library distribution files
243
266
  npm run build:lib
244
- npm run build
245
267
 
246
- # Serve the standalone demo files
247
- npx serve
268
+ # 3. Publish to npm with beta tag
269
+ npm publish --tag beta
248
270
 
249
- # Then visit:
250
- # http://localhost:3000/index.html (integration demos)
271
+ # 4. Create meaningful git commit and tag
272
+ git add package.json
273
+ git commit -m "Release v2.2.0-beta.0: Add keyboard accessibility for checkboxes
274
+
275
+ - Implement full keyboard navigation for feedback form checkboxes
276
+ - Fix focus persistence issues between questions
277
+ - Add consistent styling across all interactive elements
278
+ - Enhance screen reader support with ARIA attributes"
279
+
280
+ # 5. Create git tag and push
281
+ git tag v2.2.0-beta.0
282
+ git push origin main --tags
251
283
  ```
252
284
 
253
- ## File Structure Guide
285
+ ### Installing Beta Versions
286
+
287
+ Users can install beta versions with:
288
+
289
+ ```bash
290
+ # Install latest beta
291
+ npm install @snf/access-qa-bot@beta
292
+
293
+ # Install specific beta version
294
+ npm install @snf/access-qa-bot@2.2.0-beta.0
295
+ ```
254
296
 
255
- - **`index.html`** - Main demo showing all integration methods
256
- - **`public/index.html`** - React app template (Create React App)
257
- - **`build/index.html`** - Built React app
258
- - **`src/`** - Source code
259
- - **`components/QABot.js`** - Main React component
260
- - **`lib.js`** - React-backed implementation for all usage patterns
297
+ ### Promoting Beta to Stable
261
298
 
262
- ## Important Notes
299
+ After testing and validation:
263
300
 
264
- 1. **React-Backed Architecture**:
265
- - Everything uses React components internally for consistency
266
- - HTML/plain JS usage loads a React-based standalone bundle
267
- - Single implementation reduces complexity and bugs
301
+ ```bash
302
+ # Option A: Promote existing beta to latest
303
+ npm dist-tag add @snf/access-qa-bot@2.2.0-beta.0 latest
268
304
 
269
- 2. **Embedded vs Floating**:
270
- - Embedded mode is always visible and ignores `defaultOpen`
271
- - Floating mode shows a chat button; `defaultOpen` controls initial state
272
- - Chat window controls (`openChat`, `closeChat`, `toggleChat`) only work in floating mode
305
+ # Option B: Release new stable version
306
+ npm version 2.2.0 --no-git-tag-version
307
+ npm run build:lib
308
+ npm publish
309
+ git add package.json
310
+ git commit -m "Release v2.2.0: Stable release with keyboard accessibility"
311
+ git tag v2.2.0
312
+ git push origin main --tags
313
+ ```
273
314
 
274
- 3. **Ring Effect**:
275
- - Only works in floating mode when the tooltip is visible
276
- - Triggers a phone-like ring animation to draw attention
277
- - Activates once when the bot is first loaded (500ms delay)
278
- - Won't repeat if user has already interacted with the chat
315
+ ### Release Verification
279
316
 
280
- 4. **Auto-Detection**: The standalone script automatically detects and initializes:
281
- - `#qa-bot` → Floating mode
282
- - `.embedded-qa-bot` → Embedded mode
317
+ Check that the release was successful:
283
318
 
284
- 5. **API Key**: Defaults to demo key if not provided
319
+ ```bash
320
+ # View all published versions
321
+ npm view @snf/access-qa-bot versions --json
285
322
 
286
- 6. **Browser Support**: Uses modern browser features; consider polyfills for older browsers
323
+ # Check beta tag specifically
324
+ npm view @snf/access-qa-bot@beta
287
325
 
288
- ## Examples Repository
326
+ # Test installation
327
+ npm install @snf/access-qa-bot@beta
328
+ ```
289
329
 
290
- See the demo files in this repository for complete working examples of all integration methods.
330
+ ## Changelog
331
+
332
+ ### Version 2.3.0
333
+
334
+ #### ✨ New Features
335
+ - **Security Incident Reporting**: Complete security incident reporting flow for cybersecurity team
336
+ - **Dedicated Security Routing**: Direct integration with ACCESS cybersecurity team (Service Desk ID: 3)
337
+ - **Professional Security Flow**: Priority levels, detailed incident tracking, and file attachments
338
+ - **Enhanced API Integration**: Expanded API endpoints for security incident submission
339
+
340
+ #### 🔧 Security & Infrastructure
341
+ - **Robust Error Handling**: Comprehensive null checks and error handling across all flows
342
+ - **Security Portal Integration**: Proper routing to dedicated security service desk
343
+ - **File Upload Support**: Attachment support for security evidence and documentation
344
+
345
+ ### Version 2.2.0
346
+
347
+ #### ✨ New Features
348
+ - **Integrated Feedback System**: Added thumbs up/down feedback collection after each Q&A response
349
+ - **Seamless User Experience**: Users can provide feedback or continue asking questions without interruption
350
+ - **Smart Flow Routing**: Negative feedback automatically offers direct path to support ticket creation
351
+ - **Feedback Analytics**: Automatic tracking of user satisfaction with API endpoint integration
352
+ - **Responsive Design**: Optimized feedback UI with hover effects and accessibility features
353
+
354
+ #### 🎨 UI/UX Improvements
355
+ - Streamlined Q&A conversation flow with optional feedback prompts
356
+ - Enhanced button styling with smooth animations and brand color consistency
357
+ - Improved input field placeholder text for better user guidance
358
+ - Fixed horizontal scroll bar issues in user message bubbles
359
+
360
+ ### Version 2.1.0
361
+
362
+ #### ✨ New Features
363
+ - **Form Context System**: Implemented React Context to solve closure issues and ensure fresh form state
364
+ - **User Info Pre-population**: Added support for pre-filling ticket forms with user email, name, and username when logged in
365
+ - **HTML & Markdown Rendering**: Added support for rich text formatting in Q&A responses
366
+ - **Enhanced Ticket Flows**: Improved all support ticket flows with better user experience
367
+
368
+ #### 🐛 Bug Fixes
369
+ - Fixed React closure issues causing stale form data in ticket summaries
370
+ - Resolved priority and ACCESS ID display issues in ticket forms
371
+ - Fixed form state management across all ticket flows
372
+
373
+ #### 🎨 UI/UX Improvements
374
+ - Updated button text: "Create XXX Ticket" → "Yes, let's create a ticket"
375
+ - Changed "New Chat" button to "Restart" for clarity
376
+ - Improved accessibility with better ARIA labels
377
+ - Enhanced responsive design for mobile devices
378
+
379
+ #### 🔧 Technical Improvements
380
+ - Removed unused helper functions (`getCurrentPriority`, `getCurrentAccessId`)
381
+ - Cleaned up debug console statements for production
382
+ - Added markdown renderer plugin alongside HTML renderer
383
+ - Improved build configuration and excluded build directory from version control
384
+
385
+ #### 📚 Documentation
386
+ - Updated README with comprehensive feature list and integration examples
387
+ - Added detailed API documentation and configuration options
388
+ - Included changelog for version tracking