@blockspark/chat-widget 1.0.2 → 1.0.4
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 +106 -17
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -33,9 +33,18 @@ npm install /path/to/blockspark-chat-widget
|
|
|
33
33
|
|
|
34
34
|
## Usage
|
|
35
35
|
|
|
36
|
+
Use **camelCase** for all props in every environment (React, Next.js, Vue, and CDN). Examples: `dfProjectId`, `serviceAccountKey`, `languageCode`.
|
|
37
|
+
|
|
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:
|
|
39
|
+
|
|
40
|
+
- `import '@blockspark/chat-widget/dist/styles.css';`
|
|
41
|
+
- `import '@blockspark/chat-widget/styles.css';`
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
36
45
|
### React
|
|
37
46
|
|
|
38
|
-
Import the component and the default styles, then render with your config.
|
|
47
|
+
Import the component and the default styles, then render with your config. Copy the props below and replace the placeholder values with yours.
|
|
39
48
|
|
|
40
49
|
```tsx
|
|
41
50
|
import ChatWidget from '@blockspark/chat-widget';
|
|
@@ -50,9 +59,21 @@ function App() {
|
|
|
50
59
|
dfLocation="us-central1"
|
|
51
60
|
dfAgentId="your-agent-id"
|
|
52
61
|
serviceAccountKey={serviceAccountKey}
|
|
62
|
+
// accessToken="your-token" // use instead of serviceAccountKey if you have a token
|
|
53
63
|
languageCode="en"
|
|
54
|
-
title="💬
|
|
64
|
+
title="💬 BlockSpark AI Assistant"
|
|
55
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"
|
|
56
77
|
/>
|
|
57
78
|
);
|
|
58
79
|
}
|
|
@@ -89,6 +110,19 @@ export default function Page() {
|
|
|
89
110
|
dfAgentId="your-agent-id"
|
|
90
111
|
serviceAccountKey={serviceAccountKey}
|
|
91
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"
|
|
92
126
|
/>
|
|
93
127
|
</div>
|
|
94
128
|
);
|
|
@@ -107,13 +141,30 @@ const ChatWidget = dynamic(
|
|
|
107
141
|
);
|
|
108
142
|
|
|
109
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
|
+
|
|
110
148
|
return (
|
|
111
149
|
<ChatWidget
|
|
112
150
|
dfProjectId="your-project-id"
|
|
113
151
|
dfLocation="us-central1"
|
|
114
152
|
dfAgentId="your-agent-id"
|
|
115
|
-
serviceAccountKey={
|
|
153
|
+
serviceAccountKey={serviceAccountKey}
|
|
116
154
|
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!"
|
|
160
|
+
showWelcomePopup={true}
|
|
161
|
+
welcomePopupDelay={1500}
|
|
162
|
+
fallbackWelcomeMessage="Hello! I'm BlockSpark AI Assistant. How can I help you today?"
|
|
163
|
+
inputPlaceholder="Type your message..."
|
|
164
|
+
emptyStateMessage="Hi! I'm BlockSpark AI Assistant. How can I help you today?"
|
|
165
|
+
debug={false}
|
|
166
|
+
backendBaseUrl="http://localhost:8012"
|
|
167
|
+
backendWsUrl="ws://localhost:8012"
|
|
117
168
|
/>
|
|
118
169
|
);
|
|
119
170
|
}
|
|
@@ -138,16 +189,29 @@ app.use(BlockSparkChatWidget); // registers <BlockSparkChatWidget>
|
|
|
138
189
|
app.mount('#app');
|
|
139
190
|
```
|
|
140
191
|
|
|
141
|
-
Then in any template:
|
|
192
|
+
Then in any template (copy and replace the placeholder values):
|
|
142
193
|
|
|
143
194
|
```vue
|
|
144
195
|
<template>
|
|
145
196
|
<BlockSparkChatWidget
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
:
|
|
150
|
-
|
|
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"
|
|
151
215
|
/>
|
|
152
216
|
</template>
|
|
153
217
|
```
|
|
@@ -164,17 +228,28 @@ import serviceAccountKey from './path/to/service-account-key.json';
|
|
|
164
228
|
|
|
165
229
|
<template>
|
|
166
230
|
<BlockSparkChatWidgetVue
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
:
|
|
171
|
-
|
|
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"
|
|
172
249
|
/>
|
|
173
250
|
</template>
|
|
174
251
|
```
|
|
175
252
|
|
|
176
|
-
Use **kebab-case** for props in templates (e.g. `df-project-id`, `service-account-key`). All props from the Props table below are supported.
|
|
177
|
-
|
|
178
253
|
### CDN (script tag, no build step)
|
|
179
254
|
|
|
180
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.
|
|
@@ -213,9 +288,21 @@ Replace `1.0.1` with the version you want (or use `latest` for the latest releas
|
|
|
213
288
|
dfLocation: 'us-central1',
|
|
214
289
|
dfAgentId: 'your-agent-id',
|
|
215
290
|
serviceAccountKey: { /* your service account key object */ },
|
|
291
|
+
// accessToken: 'your-token', // use instead of serviceAccountKey if you have a token
|
|
216
292
|
languageCode: 'en',
|
|
217
293
|
title: '💬 BlockSpark AI Assistant',
|
|
218
|
-
subtitle: "We're here to help"
|
|
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'
|
|
219
306
|
};
|
|
220
307
|
|
|
221
308
|
if (ReactDOM.createRoot) {
|
|
@@ -257,6 +344,8 @@ The widget shows mode and connection status in the chat header.
|
|
|
257
344
|
|
|
258
345
|
## Props
|
|
259
346
|
|
|
347
|
+
All props use **camelCase** in every framework (React, Next.js, Vue, CDN).
|
|
348
|
+
|
|
260
349
|
| Prop | Type | Required | Default | Description |
|
|
261
350
|
|------|------|----------|---------|-------------|
|
|
262
351
|
| `dfProjectId` | `string` | Yes | - | Dialogflow project ID |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockspark/chat-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "BlockSpark Chat Widget - Reusable chat for React, Next.js, Vue 3, and CDN",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -67,6 +67,8 @@
|
|
|
67
67
|
"import": "./dist/vue.js",
|
|
68
68
|
"require": "./dist/vue.js",
|
|
69
69
|
"types": "./types/vue.d.ts"
|
|
70
|
-
}
|
|
70
|
+
},
|
|
71
|
+
"./dist/styles.css": "./dist/styles.css",
|
|
72
|
+
"./styles.css": "./dist/styles.css"
|
|
71
73
|
}
|
|
72
74
|
}
|