@askly/widget 1.0.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/LICENSE +21 -0
- package/README.md +132 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.esm.js +147 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +147 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/widget.d.ts +31 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 StrontiumTechnologies
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Askly Widget SDK
|
|
2
|
+
|
|
3
|
+
Embeddable AI support chat widget with voice capabilities, RAG integration, and customizable themes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### NPM
|
|
8
|
+
```bash
|
|
9
|
+
npm install @askly/widget
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### CDN
|
|
13
|
+
Include the UMD build directly in your HTML:
|
|
14
|
+
```html
|
|
15
|
+
<!-- React Dependencies -->
|
|
16
|
+
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
|
17
|
+
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
|
18
|
+
|
|
19
|
+
<!-- Askly SDK -->
|
|
20
|
+
<script src="https://unpkg.com/@askly/widget@latest/dist/index.umd.js"></script>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
Initialize the widget in your application:
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
import Askly from '@askly/widget';
|
|
29
|
+
|
|
30
|
+
Askly.init({
|
|
31
|
+
orgId: "your-org-id",
|
|
32
|
+
orgServerRoute: "https://your-backend.com/api/chat",
|
|
33
|
+
organizationName: "Support",
|
|
34
|
+
themeColor: "#0f172a"
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For CDN initialization:
|
|
39
|
+
```html
|
|
40
|
+
<script>
|
|
41
|
+
Askly.init({
|
|
42
|
+
orgId: "your-org-id",
|
|
43
|
+
orgServerRoute: "https://your-backend.com/api/chat",
|
|
44
|
+
organizationName: "Support"
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Alternatively, initialize automatically via script data attributes:
|
|
50
|
+
```html
|
|
51
|
+
<script
|
|
52
|
+
src="https://unpkg.com/@askly/widget@latest/dist/index.umd.js"
|
|
53
|
+
data-org-id="your-org-id"
|
|
54
|
+
data-org-server-route="https://your-backend.com/api/chat"
|
|
55
|
+
data-org-name="Support"
|
|
56
|
+
></script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
The `Askly.init()` method accepts an object with the following configuration options:
|
|
62
|
+
|
|
63
|
+
| Option | Type | Required | Default | Description |
|
|
64
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
65
|
+
| `orgId` | `string` | Yes | - | Your organization ID. |
|
|
66
|
+
| `orgServerRoute` | `string` | Yes | - | Backend API gateway endpoint. |
|
|
67
|
+
| `organizationName` | `string` | No | `"Askly"` | Name displayed in the header. |
|
|
68
|
+
| `themeColor` | `string` | No | `"#0f172a"` | Theme color (Slate 900). |
|
|
69
|
+
| `organizationLogo` | `string` | No | - | URL of the logo image. |
|
|
70
|
+
| `position` | `"left" \| "right"` | No | `"right"` | Screen placement. |
|
|
71
|
+
| `welcomeMessage` | `string` | No | `"Hi! How can I help you today?"` | Initial greeting message. |
|
|
72
|
+
| `placeholderText` | `string` | No | `"Type your message..."` | Input placeholder. |
|
|
73
|
+
| `enableVoiceChat` | `boolean` | No | `false` | Enable Web Speech input/output. |
|
|
74
|
+
| `showTimestamp` | `boolean` | No | `false` | Display timestamps in chat. |
|
|
75
|
+
| `soundEnabled` | `boolean` | No | `false` | Play synthesized audio alerts. |
|
|
76
|
+
| `soundVolume` | `number` | No | `0.4` | Sound volume (0.0 to 1.0). |
|
|
77
|
+
| `autoOpen` | `boolean` | No | `false` | Open chat on page load. |
|
|
78
|
+
| `poweredBy` | `string` | No | `"Team Askly"` | Branding attribution. |
|
|
79
|
+
| `userId` | `string` | No | - | Authenticated user ID. |
|
|
80
|
+
| `timestamp` | `number` | No | - | Request signature timestamp. |
|
|
81
|
+
| `signature` | `string` | No | - | HMAC request signature. |
|
|
82
|
+
| `turnstileSiteKey` | `string` | No | - | Cloudflare Turnstile key. |
|
|
83
|
+
| `excludePaths` | `string[]` | No | `[]` | URL path prefixes to exclude widget. |
|
|
84
|
+
|
|
85
|
+
## Lifecycle Callbacks
|
|
86
|
+
|
|
87
|
+
Attach listeners to widget events:
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
Askly.init({
|
|
91
|
+
orgId: "your-org-id",
|
|
92
|
+
orgServerRoute: "https://your-backend.com/api/chat",
|
|
93
|
+
onMessageSent: (message) => console.log("Sent:", message),
|
|
94
|
+
onMessageReceived: (reply) => console.log("Received:", reply),
|
|
95
|
+
onChatOpened: () => console.log("Opened"),
|
|
96
|
+
onChatClosed: () => console.log("Closed"),
|
|
97
|
+
onEscalation: (data) => console.log("Escalated to agent:", data)
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Backend Integration
|
|
102
|
+
|
|
103
|
+
Your `orgServerRoute` endpoint must accept a `POST` request with the following JSON body:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"message": "User's message",
|
|
108
|
+
"orgId": "your-org-id"
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The response must return the reply:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"reply": "Agent response text"
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Development
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Install dependencies
|
|
124
|
+
npm install
|
|
125
|
+
|
|
126
|
+
# Compile production bundles
|
|
127
|
+
npm run build
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface AsklyConfig {
|
|
2
|
+
orgId: string;
|
|
3
|
+
orgServerRoute: string;
|
|
4
|
+
organizationName?: string;
|
|
5
|
+
position?: "left" | "right";
|
|
6
|
+
themeColor?: string;
|
|
7
|
+
enableVoiceChat?: boolean;
|
|
8
|
+
welcomeMessage?: string;
|
|
9
|
+
placeholderText?: string;
|
|
10
|
+
organizationLogo?: string;
|
|
11
|
+
buttonIcon?: string;
|
|
12
|
+
autoOpen?: boolean;
|
|
13
|
+
showTimestamp?: boolean;
|
|
14
|
+
soundEnabled?: boolean;
|
|
15
|
+
soundVolume?: number;
|
|
16
|
+
poweredBy?: string;
|
|
17
|
+
userId?: string;
|
|
18
|
+
timestamp?: number;
|
|
19
|
+
signature?: string;
|
|
20
|
+
turnstileSiteKey?: string;
|
|
21
|
+
excludePaths?: string[];
|
|
22
|
+
onMessageSent?: (message: string) => void;
|
|
23
|
+
onMessageReceived?: (reply: string) => void;
|
|
24
|
+
onChatOpened?: () => void;
|
|
25
|
+
onChatClosed?: () => void;
|
|
26
|
+
onEscalation?: (data: any) => void;
|
|
27
|
+
}
|
|
28
|
+
declare const Askly: {
|
|
29
|
+
init: (config: AsklyConfig) => void;
|
|
30
|
+
};
|
|
31
|
+
export default Askly;
|