@blockspark/chat-widget 1.0.4 → 1.0.5

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.
Files changed (40) hide show
  1. package/README.md +146 -291
  2. package/dist/adapters/vue/index.d.ts +7 -0
  3. package/dist/adapters/vue/index.d.ts.map +1 -0
  4. package/dist/adapters/vue/useChatMode.d.ts +21 -0
  5. package/dist/adapters/vue/useChatMode.d.ts.map +1 -0
  6. package/dist/core/stateManager.d.ts +136 -0
  7. package/dist/core/stateManager.d.ts.map +1 -0
  8. package/dist/core/types.d.ts +66 -0
  9. package/dist/core/types.d.ts.map +1 -0
  10. package/dist/entry/next.d.ts +9 -0
  11. package/dist/entry/next.d.ts.map +1 -0
  12. package/dist/entry/nuxt.d.ts +7 -0
  13. package/dist/entry/nuxt.d.ts.map +1 -0
  14. package/dist/entry/react.d.ts +10 -0
  15. package/dist/entry/react.d.ts.map +1 -0
  16. package/dist/entry/vanilla.d.ts +33 -0
  17. package/dist/entry/vanilla.d.ts.map +1 -0
  18. package/dist/entry/vite.d.ts +11 -0
  19. package/dist/entry/vite.d.ts.map +1 -0
  20. package/dist/entry/vue.d.ts +9 -0
  21. package/dist/entry/vue.d.ts.map +1 -0
  22. package/dist/index.cjs.js +2 -0
  23. package/dist/index.cjs.js.LICENSE.txt +27 -0
  24. package/dist/index.d.ts +18 -3
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.esm.js +2 -0
  27. package/dist/index.esm.js.LICENSE.txt +27 -0
  28. package/dist/index.umd.js +2 -0
  29. package/dist/index.umd.js.LICENSE.txt +27 -0
  30. package/dist/react.cjs.js +2 -0
  31. package/dist/react.cjs.js.LICENSE.txt +9 -0
  32. package/dist/react.esm.js +2 -0
  33. package/dist/react.esm.js.LICENSE.txt +9 -0
  34. package/dist/styles.css +11 -0
  35. package/dist/utils/frameworkDetector.d.ts +17 -0
  36. package/dist/utils/frameworkDetector.d.ts.map +1 -0
  37. package/dist/vue.cjs.js +1 -0
  38. package/dist/vue.esm.js +1 -0
  39. package/package.json +110 -43
  40. package/types/vue.d.ts +0 -8
package/README.md CHANGED
@@ -1,150 +1,135 @@
1
1
  # BlockSpark Chat Widget
2
2
 
3
- A reusable chat widget for **React**, **Next.js**, **Vue 3**, and **vanilla HTML (CDN)** that connects directly with Dialogflow CX no backend API required.
3
+ A reusable React chat widget component that connects directly with Dialogflow CX - no backend API required!
4
4
 
5
5
  ## Installation
6
6
 
7
- Install from npm (for React, Next.js, or Vue projects):
7
+ ### Option 1: Install from Local Path (Recommended for Development)
8
8
 
9
9
  ```bash
10
- npm install @blockspark/chat-widget
10
+ # In your website project directory
11
+ npm install /path/to/blockspark-chat-widget
12
+ # or
13
+ npm install ../blockspark-chat-widget
11
14
  ```
12
15
 
13
- - **React / Next.js**: You also need `react` and `react-dom` (they are peer dependencies).
14
- - **Vue 3**: You also need `vue`. The widget bundles React internally for the Vue build, so you do **not** need to install React.
16
+ ### Option 2: Use npm link (For Development)
15
17
 
16
18
  ```bash
17
- # React or Next.js
18
- npm install @blockspark/chat-widget react react-dom
19
+ # In the blockspark-chat-widget directory
20
+ npm link
19
21
 
20
- # Vue 3 only
21
- npm install @blockspark/chat-widget vue
22
+ # In your website project directory
23
+ npm link @blockspark/chat-widget
22
24
  ```
23
25
 
24
- **Development / local testing:**
26
+ ### Option 3: Publish to npm (For Production)
25
27
 
26
28
  ```bash
27
- # From your app directory
28
- npm install /path/to/blockspark-chat-widget
29
- # or use npm link in the widget repo, then npm link @blockspark/chat-widget in your app
29
+ # Build the library first
30
+ npm run build
31
+
32
+ # Publish to npm (make sure you're logged in)
33
+ npm publish
30
34
  ```
31
35
 
32
- ---
36
+ Then install in your project:
37
+ ```bash
38
+ npm install @blockspark/chat-widget
39
+ ```
33
40
 
34
41
  ## Usage
35
42
 
36
- Use **camelCase** for all props in every environment (React, Next.js, Vue, and CDN). Examples: `dfProjectId`, `serviceAccountKey`, `languageCode`.
43
+ ### Vue.js Usage (Quick Start)
37
44
 
38
- **Import the widget styles once.** The widget’s layout and appearance live in a separate CSS file. Your app must import it so the styles are bundled and applied; otherwise the widget will render but look unstyled. Use either:
45
+ ```bash
46
+ # Install
47
+ npm install @blockspark/chat-widget
48
+ ```
39
49
 
40
- - `import '@blockspark/chat-widget/dist/styles.css';`
41
- - `import '@blockspark/chat-widget/styles.css';`
50
+ ```vue
51
+ <template>
52
+ <ChatWidget
53
+ :df-project-id="'your-project-id'"
54
+ :df-agent-id="'your-agent-id'"
55
+ :service-account-key="serviceAccountKey"
56
+ />
57
+ </template>
58
+
59
+ <script setup>
60
+ import ChatWidget from '@blockspark/chat-widget/vue';
61
+ import '@blockspark/chat-widget/dist/styles.css';
62
+ import serviceAccountKey from './service-account-key.json';
63
+ </script>
64
+ ```
65
+
66
+ **📚 For detailed Vue.js setup guide, see [VUE_INSTALLATION_GUIDE.md](./VUE_INSTALLATION_GUIDE.md)**
42
67
 
43
68
  ---
44
69
 
45
- ### React
70
+ ### React/Next.js Usage
46
71
 
47
- Import the component and the default styles, then render with your config. Copy the props below and replace the placeholder values with yours.
72
+ ### Basic Usage
48
73
 
49
74
  ```tsx
50
75
  import ChatWidget from '@blockspark/chat-widget';
51
76
  import '@blockspark/chat-widget/dist/styles.css';
52
77
 
78
+ // Load your Google Cloud service account key
53
79
  import serviceAccountKey from './path/to/service-account-key.json';
54
80
 
55
81
  function App() {
56
82
  return (
57
- <ChatWidget
58
- dfProjectId="your-project-id"
59
- dfLocation="us-central1"
60
- dfAgentId="your-agent-id"
61
- serviceAccountKey={serviceAccountKey}
62
- // accessToken="your-token" // use instead of serviceAccountKey if you have a token
63
- languageCode="en"
64
- title="💬 BlockSpark AI Assistant"
65
- subtitle="We're here to help"
66
- welcomeTitle="👋 Welcome to Blockspark"
67
- welcomeMessage="My name is BlockSpark AI Assistant and I'll guide you."
68
- welcomeCta="💬 Click here to start chatting!"
69
- showWelcomePopup={true}
70
- welcomePopupDelay={1500}
71
- fallbackWelcomeMessage="Hello! I'm BlockSpark AI Assistant. How can I help you today?"
72
- inputPlaceholder="Type your message..."
73
- emptyStateMessage="Hi! I'm BlockSpark AI Assistant. How can I help you today?"
74
- debug={false}
75
- backendBaseUrl="http://localhost:8012"
76
- backendWsUrl="ws://localhost:8012"
77
- />
83
+ <div>
84
+ <ChatWidget
85
+ dfProjectId="your-project-id"
86
+ dfLocation="us-central1"
87
+ dfAgentId="your-agent-id"
88
+ serviceAccountKey={serviceAccountKey}
89
+ languageCode="en"
90
+ />
91
+ </div>
78
92
  );
79
93
  }
80
94
  ```
81
95
 
82
- ### Next.js
96
+ ### Using Access Token (Alternative)
83
97
 
84
- The widget uses browser APIs (e.g. `localStorage`) and is intended to run on the client. Use **dynamic import with SSR disabled** so it only loads in the browser.
85
-
86
- **App Router (Next.js 13+):**
98
+ If you prefer to manage authentication yourself:
87
99
 
88
100
  ```tsx
89
- 'use client';
90
-
91
- import dynamic from 'next/dynamic';
101
+ import ChatWidget from '@blockspark/chat-widget';
92
102
  import '@blockspark/chat-widget/dist/styles.css';
93
103
 
94
- const ChatWidget = dynamic(
95
- () => import('@blockspark/chat-widget').then((mod) => mod.default),
96
- { ssr: false }
97
- );
104
+ function App() {
105
+ const [accessToken, setAccessToken] = useState<string>('');
98
106
 
99
- export default function Page() {
100
- const serviceAccountKey = {
101
- /* your key object, or load from env/server */
102
- };
107
+ // Get access token from your backend or OAuth flow
108
+ useEffect(() => {
109
+ // Your token fetching logic here
110
+ fetchAccessToken().then(setAccessToken);
111
+ }, []);
103
112
 
104
113
  return (
105
- <div>
106
- <h1>My Page</h1>
107
- <ChatWidget
108
- dfProjectId="your-project-id"
109
- dfLocation="us-central1"
110
- dfAgentId="your-agent-id"
111
- serviceAccountKey={serviceAccountKey}
112
- languageCode="en"
113
- title="💬 BlockSpark AI Assistant"
114
- subtitle="We're here to help"
115
- welcomeTitle="👋 Welcome to Blockspark"
116
- welcomeMessage="My name is BlockSpark AI Assistant and I'll guide you."
117
- welcomeCta="💬 Click here to start chatting!"
118
- showWelcomePopup={true}
119
- welcomePopupDelay={1500}
120
- fallbackWelcomeMessage="Hello! I'm BlockSpark AI Assistant. How can I help you today?"
121
- inputPlaceholder="Type your message..."
122
- emptyStateMessage="Hi! I'm BlockSpark AI Assistant. How can I help you today?"
123
- debug={false}
124
- backendBaseUrl="http://localhost:8012"
125
- backendWsUrl="ws://localhost:8012"
126
- />
127
- </div>
114
+ <ChatWidget
115
+ dfProjectId="your-project-id"
116
+ dfLocation="us-central1"
117
+ dfAgentId="your-agent-id"
118
+ accessToken={accessToken}
119
+ languageCode="en"
120
+ />
128
121
  );
129
122
  }
130
123
  ```
131
124
 
132
- **Pages Router:**
125
+ ### With Custom Configuration
133
126
 
134
127
  ```tsx
135
- import dynamic from 'next/dynamic';
128
+ import ChatWidget from '@blockspark/chat-widget';
136
129
  import '@blockspark/chat-widget/dist/styles.css';
130
+ import serviceAccountKey from './service-account-key.json';
137
131
 
138
- const ChatWidget = dynamic(
139
- () => import('@blockspark/chat-widget').then((mod) => mod.default),
140
- { ssr: false }
141
- );
142
-
143
- export default function ChatPage() {
144
- const serviceAccountKey = process.env.NEXT_PUBLIC_SERVICE_ACCOUNT_KEY_JSON
145
- ? JSON.parse(process.env.NEXT_PUBLIC_SERVICE_ACCOUNT_KEY_JSON)
146
- : undefined;
147
-
132
+ function App() {
148
133
  return (
149
134
  <ChatWidget
150
135
  dfProjectId="your-project-id"
@@ -152,200 +137,65 @@ export default function ChatPage() {
152
137
  dfAgentId="your-agent-id"
153
138
  serviceAccountKey={serviceAccountKey}
154
139
  languageCode="en"
155
- title="💬 BlockSpark AI Assistant"
156
- subtitle="We're here to help"
157
- welcomeTitle="👋 Welcome to Blockspark"
158
- welcomeMessage="My name is BlockSpark AI Assistant and I'll guide you."
159
- welcomeCta="💬 Click here to start chatting!"
140
+ title="💬 My Chat Assistant"
141
+ subtitle="How can I help you?"
142
+ welcomeTitle="👋 Welcome!"
143
+ welcomeMessage="I'm here to help you with any questions."
144
+ welcomeCta="Start chatting"
160
145
  showWelcomePopup={true}
161
- welcomePopupDelay={1500}
162
- fallbackWelcomeMessage="Hello! I'm BlockSpark AI Assistant. How can I help you today?"
146
+ welcomePopupDelay={2000}
163
147
  inputPlaceholder="Type your message..."
164
- emptyStateMessage="Hi! I'm BlockSpark AI Assistant. How can I help you today?"
148
+ emptyStateMessage="Hi! How can I help you today?"
165
149
  debug={false}
166
- backendBaseUrl="http://localhost:8012"
167
- backendWsUrl="ws://localhost:8012"
168
150
  />
169
151
  );
170
152
  }
171
153
  ```
172
154
 
173
- **Important:** Do not expose raw service account keys in client-side code in production. Prefer a backend that returns short-lived tokens or use a proxy.
174
-
175
- ### Vue 3
155
+ ### Using Environment Variables
176
156
 
177
- Use either the global plugin or the component directly.
178
-
179
- **Option A — Global plugin (e.g. `main.js` / `main.ts`):**
180
-
181
- ```js
182
- import { createApp } from 'vue';
183
- import App from './App.vue';
184
- import BlockSparkChatWidget from '@blockspark/chat-widget/vue';
185
- import '@blockspark/chat-widget/dist/styles.css';
157
+ You can configure the backend API URLs for Human Support Mode using environment variables. Create a `.env` file in the project root:
186
158
 
187
- const app = createApp(App);
188
- app.use(BlockSparkChatWidget); // registers <BlockSparkChatWidget>
189
- app.mount('#app');
190
- ```
191
-
192
- Then in any template (copy and replace the placeholder values):
193
-
194
- ```vue
195
- <template>
196
- <BlockSparkChatWidget
197
- dfProjectId="your-project-id"
198
- dfLocation="us-central1"
199
- dfAgentId="your-agent-id"
200
- :serviceAccountKey="serviceAccountKey"
201
- languageCode="en"
202
- title="💬 BlockSpark AI Assistant"
203
- subtitle="We're here to help"
204
- welcomeTitle="👋 Welcome to Blockspark"
205
- welcomeMessage="My name is BlockSpark AI Assistant and I'll guide you."
206
- welcomeCta="💬 Click here to start chatting!"
207
- :showWelcomePopup="true"
208
- :welcomePopupDelay="1500"
209
- fallbackWelcomeMessage="Hello! I'm BlockSpark AI Assistant. How can I help you today?"
210
- inputPlaceholder="Type your message..."
211
- emptyStateMessage="Hi! I'm BlockSpark AI Assistant. How can I help you today?"
212
- :debug="false"
213
- backendBaseUrl="http://localhost:8012"
214
- backendWsUrl="ws://localhost:8012"
215
- />
216
- </template>
159
+ ```bash
160
+ # .env file
161
+ REACT_APP_BACKEND_BASE_URL=http://localhost:8012
162
+ REACT_APP_BACKEND_WS_URL=ws://localhost:8012
217
163
  ```
218
164
 
219
- **Option B Component only:**
220
-
221
- ```vue
222
- <script setup>
223
- import { BlockSparkChatWidgetVue } from '@blockspark/chat-widget/vue';
224
- import '@blockspark/chat-widget/dist/styles.css';
165
+ Or pass them as props:
225
166
 
226
- import serviceAccountKey from './path/to/service-account-key.json';
227
- </script>
228
-
229
- <template>
230
- <BlockSparkChatWidgetVue
231
- dfProjectId="your-project-id"
232
- dfLocation="us-central1"
233
- dfAgentId="your-agent-id"
234
- :serviceAccountKey="serviceAccountKey"
235
- languageCode="en"
236
- title="💬 BlockSpark AI Assistant"
237
- subtitle="We're here to help"
238
- welcomeTitle="👋 Welcome to Blockspark"
239
- welcomeMessage="My name is BlockSpark AI Assistant and I'll guide you."
240
- welcomeCta="💬 Click here to start chatting!"
241
- :showWelcomePopup="true"
242
- :welcomePopupDelay="1500"
243
- fallbackWelcomeMessage="Hello! I'm BlockSpark AI Assistant. How can I help you today?"
244
- inputPlaceholder="Type your message..."
245
- emptyStateMessage="Hi! I'm BlockSpark AI Assistant. How can I help you today?"
246
- :debug="false"
247
- backendBaseUrl="http://localhost:8012"
248
- backendWsUrl="ws://localhost:8012"
249
- />
250
- </template>
251
- ```
252
-
253
- ### CDN (script tag, no build step)
254
-
255
- You can load the widget from a CDN and mount it with React (the widget is a React component). Load React, ReactDOM, the widget CSS, and the widget script, then render into a container.
256
-
257
- Replace `1.0.1` with the version you want (or use `latest` for the latest release).
258
-
259
- **Using unpkg:**
260
-
261
- ```html
262
- <!DOCTYPE html>
263
- <html lang="en">
264
- <head>
265
- <meta charset="UTF-8" />
266
- <title>BlockSpark Chat Widget</title>
267
- <!-- 1. React (required by the widget) -->
268
- <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
269
- <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
270
- <!-- 2. Widget CSS -->
271
- <link rel="stylesheet" href="https://unpkg.com/@blockspark/chat-widget@1.0.1/dist/styles.css" />
272
- </head>
273
- <body>
274
- <div id="chat-root"></div>
275
-
276
- <!-- 3. Widget script (UMD: exposes BlockSparkChatWidget) -->
277
- <script src="https://unpkg.com/@blockspark/chat-widget@1.0.1/dist/index.js"></script>
278
-
279
- <script>
280
- (function () {
281
- var container = document.getElementById('chat-root');
282
- var React = window.React;
283
- var ReactDOM = window.ReactDOM;
284
- var ChatWidget = window.BlockSparkChatWidget;
285
-
286
- var config = {
287
- dfProjectId: 'your-project-id',
288
- dfLocation: 'us-central1',
289
- dfAgentId: 'your-agent-id',
290
- serviceAccountKey: { /* your service account key object */ },
291
- // accessToken: 'your-token', // use instead of serviceAccountKey if you have a token
292
- languageCode: 'en',
293
- title: '💬 BlockSpark AI Assistant',
294
- subtitle: "We're here to help",
295
- welcomeTitle: '👋 Welcome to Blockspark',
296
- welcomeMessage: "My name is BlockSpark AI Assistant and I'll guide you.",
297
- welcomeCta: '💬 Click here to start chatting!',
298
- showWelcomePopup: true,
299
- welcomePopupDelay: 1500,
300
- fallbackWelcomeMessage: "Hello! I'm BlockSpark AI Assistant. How can I help you today?",
301
- inputPlaceholder: 'Type your message...',
302
- emptyStateMessage: "Hi! I'm BlockSpark AI Assistant. How can I help you today?",
303
- debug: false,
304
- backendBaseUrl: 'http://localhost:8012',
305
- backendWsUrl: 'ws://localhost:8012'
306
- };
307
-
308
- if (ReactDOM.createRoot) {
309
- ReactDOM.createRoot(container).render(React.createElement(ChatWidget, config));
310
- } else {
311
- ReactDOM.render(React.createElement(ChatWidget, config), container);
312
- }
313
- })();
314
- </script>
315
- </body>
316
- </html>
167
+ ```tsx
168
+ <ChatWidget
169
+ dfProjectId="your-project-id"
170
+ dfAgentId="your-agent-id"
171
+ serviceAccountKey={serviceAccountKey}
172
+ backendBaseUrl="http://your-backend-url:8012"
173
+ backendWsUrl="ws://your-backend-url:8012"
174
+ />
317
175
  ```
318
176
 
319
- **Using jsDelivr:**
320
-
321
- Use the same structure and swap the CDN base URL:
322
-
323
- - CSS: `https://cdn.jsdelivr.net/npm/@blockspark/chat-widget@1.0.1/dist/styles.css`
324
- - JS: `https://cdn.jsdelivr.net/npm/@blockspark/chat-widget@1.0.1/dist/index.js`
177
+ **Note**: Props take precedence over environment variables.
325
178
 
326
- **Notes for CDN:**
179
+ ### Human Support Mode
327
180
 
328
- - You must provide `serviceAccountKey` (or `accessToken`) in the config object. Do not hardcode real keys in production; use a backend or token endpoint.
329
- - Pin the version in the URL (e.g. `@1.0.1`) instead of `@latest` for stable behavior.
330
-
331
- ---
181
+ The widget supports automatic handoff from bot to human agents. When Dialogflow returns `{"handoff": true}`, the widget will:
332
182
 
333
- ## Human Support Mode
183
+ 1. Switch from Bot Mode to Human Support Mode
184
+ 2. Create a support chat session
185
+ 3. Connect via WebSocket for real-time messaging
186
+ 4. Load message history
187
+ 5. Route messages to the backend API instead of Dialogflow
334
188
 
335
- The widget supports automatic handoff from bot to human agents. When Dialogflow returns `{"handoff": true}`, the widget will:
189
+ The widget displays mode indicators and connection status in the chat header.
336
190
 
337
- 1. Switch from Bot Mode to Human Support Mode
338
- 2. Create a support chat session
339
- 3. Connect via WebSocket for real-time messaging
340
- 4. Load message history
341
- 5. Route messages to the backend API instead of Dialogflow
191
+ ### Import Types (TypeScript)
342
192
 
343
- The widget shows mode and connection status in the chat header.
193
+ ```tsx
194
+ import ChatWidget, { ChatWidgetProps, DialogflowConfig } from '@blockspark/chat-widget';
195
+ ```
344
196
 
345
197
  ## Props
346
198
 
347
- All props use **camelCase** in every framework (React, Next.js, Vue, CDN).
348
-
349
199
  | Prop | Type | Required | Default | Description |
350
200
  |------|------|----------|---------|-------------|
351
201
  | `dfProjectId` | `string` | Yes | - | Dialogflow project ID |
@@ -365,57 +215,62 @@ All props use **camelCase** in every framework (React, Next.js, Vue, CDN).
365
215
  | `inputPlaceholder` | `string` | No | `"Type your message..."` | Input field placeholder |
366
216
  | `emptyStateMessage` | `string` | No | `"Hi! I'm BlockSpark..."` | Empty state message |
367
217
  | `debug` | `boolean` | No | `false` | Enable debug logging |
368
- | `backendBaseUrl` | `string` | No | env or `"http://localhost:8012"` | Backend REST API base URL for Human Support Mode |
369
- | `backendWsUrl` | `string` | No | env or `"ws://localhost:8012"` | Backend WebSocket URL for Human Support Mode |
218
+ | `backendBaseUrl` | `string` | No | `process.env.REACT_APP_BACKEND_BASE_URL` or `"http://localhost:8012"` | Backend REST API base URL for Human Support Mode |
219
+ | `backendWsUrl` | `string` | No | `process.env.REACT_APP_BACKEND_WS_URL` or `"ws://localhost:8012"` | Backend WebSocket URL for Human Support Mode |
370
220
 
371
221
  \* Either `serviceAccountKey` or `accessToken` must be provided.
372
222
 
373
- ## TypeScript
374
-
375
- ```tsx
376
- import ChatWidget, { ChatWidgetProps, DialogflowConfig } from '@blockspark/chat-widget';
377
- ```
378
-
379
223
  ## How It Works
380
224
 
381
- The widget talks **directly** to Dialogflow CX via the REST API (no custom backend required for basic use):
225
+ The widget connects **directly** to Dialogflow CX using the REST API - no backend required!
382
226
 
383
- 1. **Authentication** Uses a Google Cloud service account key to obtain OAuth2 access tokens
384
- 2. **Sessions** Creates and manages Dialogflow sessions
385
- 3. **Messages** Sends user messages to Dialogflow and displays responses
386
- 4. **Rich content** Supports Dialogflow rich content (chips, cards, etc.)
227
+ 1. **Authentication**: Uses Google Cloud service account key to generate OAuth2 access tokens
228
+ 2. **Session Management**: Creates and manages Dialogflow sessions automatically
229
+ 3. **Message Handling**: Sends messages directly to Dialogflow and displays responses
230
+ 4. **Rich Content**: Supports Dialogflow rich content (chips, cards, etc.)
387
231
 
388
232
  ## Requirements
389
233
 
390
- - **React / Next.js**: React 16.8+ and React DOM
391
- - **Vue**: Vue 3.x
392
- - **CDN**: React 17 or 18 and React DOM loaded via script tags
393
- - Google Cloud project with Dialogflow API enabled and a Dialogflow CX agent
234
+ - React 16.8.0 or higher
235
+ - React DOM 16.8.0 or higher
236
+ - Google Cloud service account with Dialogflow API enabled
237
+ - Dialogflow CX agent
394
238
 
395
239
  ## Getting Your Service Account Key
396
240
 
397
- 1. Open [Google Cloud Console](https://console.cloud.google.com/) and select your project
398
- 2. Go to **IAM & Admin** → **Service Accounts**
399
- 3. Create or select a service account and create a JSON key
400
- 4. Enable **Dialogflow API** for the project
401
- 5. Grant the service account the **Dialogflow API User** role
241
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
242
+ 2. Select your project
243
+ 3. Navigate to **IAM & Admin** > **Service Accounts**
244
+ 4. Create a new service account or select an existing one
245
+ 5. Create a JSON key and download it
246
+ 6. Enable **Dialogflow API** for your project
247
+ 7. Grant the service account **Dialogflow API User** role
402
248
 
403
- ## Security
249
+ ## Security Warning ⚠️
404
250
 
405
- - **Development**: You can import or pass the service account key in code for local testing
406
- - **Production**:
407
- - **Do not** ship service account keys in client-side code or public HTML
408
- - Prefer a backend that issues short-lived tokens or proxies Dialogflow calls
409
- - Use restricted keys and minimal permissions where possible
251
+ **Important**: Service account keys contain sensitive credentials.
252
+
253
+ - **For Development**: You can import the key directly (as shown in examples)
254
+ - **For Production**:
255
+ - **DO NOT** expose service account keys in client-side code
256
+ - Use a backend proxy to handle authentication
257
+ - Or use OAuth2 flow to get access tokens securely
258
+ - Consider using restricted service account keys with minimal permissions
410
259
 
411
260
  ## Development
412
261
 
413
262
  ```bash
263
+ # Install dependencies
414
264
  npm install
415
- npm run build # production build
416
- npm run dev # watch mode
265
+
266
+ # Build for production
267
+ npm run build
268
+
269
+ # Watch mode for development
270
+ npm run dev
417
271
  ```
418
272
 
419
273
  ## License
420
274
 
421
275
  MIT
276
+ export NPM_TOKEN=your_token_here
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Vue Adapter Entry Point
3
+ * Supports Vue 2.7+ and Vue 3.x
4
+ */
5
+ export { default } from './ChatWidget.vue';
6
+ export { default as ChatWidget } from './ChatWidget.vue';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/vue/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Vue Composable for Chat Mode Management
3
+ * Equivalent to React's useChatMode hook
4
+ */
5
+ import type { ChatResponse } from '../../services/dialogflowClient';
6
+ export type ChatMode = 'BOT' | 'HUMAN';
7
+ export interface UseChatModeReturn {
8
+ currentMode: ChatMode;
9
+ switchToHumanMode: () => void;
10
+ switchToBotMode: () => void;
11
+ isHandoffTriggered: (dialogflowResponse: ChatResponse) => boolean;
12
+ chatId: string | null;
13
+ sessionId: string | null;
14
+ setChatId: (id: string | null) => void;
15
+ setSessionId: (id: string | null) => void;
16
+ }
17
+ /**
18
+ * Vue composable to manage chat mode (BOT or HUMAN)
19
+ */
20
+ export declare function useChatMode(): UseChatModeReturn;
21
+ //# sourceMappingURL=useChatMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChatMode.d.ts","sourceRoot":"","sources":["../../../src/adapters/vue/useChatMode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;AAMvC,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,QAAQ,CAAC;IACtB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,kBAAkB,EAAE,CAAC,kBAAkB,EAAE,YAAY,KAAK,OAAO,CAAC;IAClE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACvC,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3C;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,iBAAiB,CAqF/C"}