@askly/widget 2.3.0 → 2.4.0

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
@@ -15,51 +15,38 @@ Askly is an **embeddable AI support chat widget** for React and plain HTML. Drop
15
15
  - 📚 **RAG (docs-grounded)** — replies grounded in your own documentation, not hallucinated.
16
16
  - 🎙️ **Voice chat** — customers can talk to the assistant, not just type.
17
17
  - 🙋 **Human handoff** — one-click escalation to a live agent when needed.
18
- - ⚛️ **React + CDN** — use as an npm module or a single `<script>` tag.
18
+ - ⚛️ **React + CDN** — use as an npm module, or a single `<script>` tag on any site (no React required).
19
19
  - 🎨 **Fully themeable** — colors, logo, position, and copy configured in the portal.
20
20
 
21
21
  ## Installation
22
22
 
23
- ### NPM
24
- ```bash
25
- npm install @askly/widget
26
- ```
23
+ ### Script tag (any website)
27
24
 
28
- ### CDN
29
- Include the UMD build directly in your HTML:
30
- ```html
31
- <!-- React Dependencies -->
32
- <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
33
- <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
25
+ One line, before `</body>`. The bundle is self-contained — no React or other dependencies on your page:
34
26
 
35
- <!-- Askly SDK -->
36
- <script src="https://unpkg.com/@askly/widget@latest/dist/index.umd.js"></script>
27
+ ```html
28
+ <script src="https://unpkg.com/@askly/widget@latest/dist/widget.js" data-app-id="YOUR_APP_ID" async></script>
37
29
  ```
38
30
 
39
- ## Quick Start
31
+ That's the whole install. Your branding — name, logo, theme, welcome message — loads automatically from your Askly portal settings.
40
32
 
41
- All you need is your `widgetId` — copy it from the **Widget setup** screen in your Askly tenant portal. Everything else (name, theme, logo, welcome message, voice, etc.) is configured there and loaded automatically; the init props below are optional overrides.
33
+ ### NPM (React / bundlers)
34
+
35
+ ```bash
36
+ npm install @askly/widget
37
+ ```
42
38
 
43
39
  ```javascript
44
40
  import Askly from '@askly/widget';
45
41
 
46
- Askly.init({ widgetId: "your-widget-id" });
42
+ Askly.init({ appId: "YOUR_APP_ID" });
47
43
  ```
48
44
 
49
- For CDN initialization:
50
- ```html
51
- <script>
52
- Askly.init({ widgetId: "your-widget-id" });
53
- </script>
54
- ```
45
+ The npm builds (`index.esm.js` / `index.umd.js`) treat React as a peer dependency, so your bundle isn't double-shipping it.
55
46
 
56
- Alternatively, initialize automatically via a single script tag:
57
- ```html
58
- <script
59
- src="https://unpkg.com/@askly/widget@latest/dist/index.umd.js"
60
- data-widget-id="your-widget-id"
61
- ></script>
62
- ```
47
+ ## Quick Start
48
+
49
+ All you need is your `appId` — copy it from **Widget → Install Code** in your Askly tenant portal. Everything else (name, theme, logo, welcome message, voice, etc.) is configured there and loaded automatically; the init props below are optional overrides.
63
50
 
64
51
  > The widget talks to Askly's hosted backend automatically — there is nothing else to configure.
65
52
 
@@ -69,11 +56,13 @@ The `Askly.init()` method accepts an object with the following configuration opt
69
56
 
70
57
  | Option | Type | Required | Default | Description |
71
58
  | :--- | :--- | :--- | :--- | :--- |
72
- | `widgetId` | `string` | **Yes** | - | Your widget ID, from the tenant portal's Widget setup screen. |
59
+ | `appId` | `string` | **Yes** | - | Your app ID, from the tenant portal's **Widget → Install Code** screen. Script tag: `data-app-id`. |
60
+
61
+ > `widgetId` and `orgId` are still accepted as deprecated aliases for `appId`, so existing embeds keep working.
73
62
 
74
63
  ### Configured in the portal
75
64
 
76
- The widget's appearance and behaviour — display name, logo, theme color, welcome message, position, voice, sounds, timestamps, "powered by" text, and so on — are set on the **Widget setup** screen in your Askly portal and loaded automatically by `widgetId`. **You do not pass these in code.** (They remain accepted as optional `init()` overrides for advanced cases, but the portal is the source of truth.)
65
+ The widget's appearance and behaviour — display name, logo, theme color, welcome message, position, voice, sounds, timestamps, "powered by" text, and so on — are set on the **Widget** screen in your Askly portal and loaded automatically by `appId`. Logos are uploaded right there and apply instantly. **You do not pass these in code.** (They remain accepted as optional `init()` overrides for advanced cases, but the portal is the source of truth.)
77
66
 
78
67
  ### Identifying an authenticated user
79
68
 
@@ -140,6 +129,28 @@ instead of calling `identify()` separately:
140
129
  | `timestamp` | `number` | Signature timestamp. |
141
130
  | `signature` | `string` | HMAC request signature (same value as `hash` above). |
142
131
 
132
+ ### Asking visitors for their email
133
+
134
+ Anonymous visitors can't be replied to once they close the tab — the answer just waits in a widget
135
+ they may never reopen. So the widget can ask for an email, and Askly delivers the reply there
136
+ instead when they've gone.
137
+
138
+ Configured on the **Widget** screen in your portal, not in code:
139
+
140
+ | Mode | Behaviour |
141
+ | :--- | :--- |
142
+ | **When it matters** *(default)* | A dismissible prompt after the assistant replies, and a required one only once a conversation is waiting on your team — the point where email is the only way to reach them. Barely affects how many people start a chat. |
143
+ | **Before every chat** | Nobody can send a first message without an email. Captures the most addresses, at a cost of roughly 30% fewer conversations — including ones the assistant would have resolved on its own. |
144
+ | **Never** | Visitors are never asked. |
145
+
146
+ Anyone whose address you already have — from `identify()`, a previous chat, or because they typed
147
+ it — is never asked again.
148
+
149
+ An address given this way is **not verified**: it proves the person wants replies there, not who
150
+ they are. It is never used to match them to an existing contact, so nobody can read someone else's
151
+ conversation history by typing their address. Only addresses given through this prompt are ever
152
+ emailed; one merely spotted in the text of a message is not consent to write to them.
153
+
143
154
  ### Restricting the widget to certain pages
144
155
 
145
156
  Control where the widget appears using URL **path prefixes** (matched against `window.location.pathname`).
@@ -151,10 +162,10 @@ Control where the widget appears using URL **path prefixes** (matched against `w
151
162
 
152
163
  ```javascript
153
164
  // Show ONLY on support & docs pages
154
- Askly.init({ widgetId: "your-widget-id", includePaths: ["/support", "/docs"] });
165
+ Askly.init({ appId: "YOUR_APP_ID", includePaths: ["/support", "/docs"] });
155
166
 
156
167
  // Show everywhere EXCEPT admin & checkout
157
- Askly.init({ widgetId: "your-widget-id", excludePaths: ["/admin", "/checkout"] });
168
+ Askly.init({ appId: "YOUR_APP_ID", excludePaths: ["/admin", "/checkout"] });
158
169
  ```
159
170
 
160
171
  Via script tag, use comma-separated values: `data-include-paths="/support,/docs"` or `data-exclude-paths="/admin,/checkout"`.
@@ -172,7 +183,7 @@ Callbacks are functions, so they can only be attached in code (not from the port
172
183
 
173
184
  ```javascript
174
185
  Askly.init({
175
- widgetId: "your-widget-id",
186
+ appId: "YOUR_APP_ID",
176
187
  onMessageSent: (message) => console.log("Sent:", message),
177
188
  onMessageReceived: (reply) => console.log("Received:", reply),
178
189
  onChatOpened: () => console.log("Opened"),
@@ -183,7 +194,7 @@ Askly.init({
183
194
 
184
195
  ## Backend Integration
185
196
 
186
- None required. The widget talks to Askly's hosted backend automatically — you only provide a `widgetId`.
197
+ None required. The widget talks to Askly's hosted backend automatically — you only provide an `appId`.
187
198
 
188
199
  ## Development
189
200