vocalia-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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 VocalIA
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,186 @@
1
+ # vocalia-widget
2
+
3
+ AI-powered voice assistant widget for websites. 40 industry personas, 5 languages (FR/EN/ES/AR/Darija), BANT lead qualification, RTL support.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install vocalia-widget
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### General purpose
14
+
15
+ ```js
16
+ import { initVocalia } from 'vocalia-widget';
17
+
18
+ initVocalia({
19
+ tenantId: 'your_tenant_id',
20
+ apiKey: 'voc_xxxxxxxxxxxx',
21
+ position: 'bottom-right',
22
+ primaryColor: '#5E6AD2',
23
+ language: 'auto',
24
+ persona: 'AGENCY'
25
+ });
26
+ ```
27
+
28
+ ### B2B (lead qualification)
29
+
30
+ ```js
31
+ import { initVocaliaB2B } from 'vocalia-widget';
32
+
33
+ initVocaliaB2B({
34
+ tenantId: 'your_tenant_id',
35
+ persona: 'SAAS'
36
+ });
37
+ ```
38
+
39
+ ### E-commerce (product catalog)
40
+
41
+ ```js
42
+ import { initVocaliaEcommerce } from 'vocalia-widget';
43
+
44
+ initVocaliaEcommerce({
45
+ tenantId: 'your_tenant_id',
46
+ persona: 'ECOMMERCE'
47
+ });
48
+ ```
49
+
50
+ ## CDN Alternative
51
+
52
+ ```html
53
+ <script>
54
+ window.VOCALIA_CONFIG = {
55
+ tenantId: 'your_tenant_id',
56
+ position: 'bottom-right',
57
+ primaryColor: '#5E6AD2'
58
+ };
59
+ </script>
60
+ <script src="https://cdn.jsdelivr.net/npm/vocalia-widget/src/voice-widget.js" defer></script>
61
+ ```
62
+
63
+ ## Configuration
64
+
65
+ | Option | Type | Default | Description |
66
+ |:-------|:-----|:--------|:------------|
67
+ | `tenantId` | string | *required* | Your VocalIA tenant identifier. |
68
+ | `apiKey` | string | — | API key for authenticated operations (BANT/CRM). |
69
+ | `position` | string | `'bottom-right'` | Widget position: `bottom-right`, `bottom-left`, `top-right`, `top-left`. |
70
+ | `primaryColor` | hex | `'#5E6AD2'` | Button and accent color. |
71
+ | `buttonSize` | number | `60` | Button diameter in pixels. |
72
+ | `language` | string | `'auto'` | Force language: `fr`, `en`, `es`, `ar`, `ary`. |
73
+ | `persona` | string | `'AGENCY'` | Initial AI personality (see Personas list). |
74
+ | `ecommerceMode` | boolean | `true` | Enable catalog search & cart intent detection. |
75
+ | `autoStart` | boolean | `false` | Start voice synthesis immediately on open. |
76
+ | `debug` | boolean | `false` | Enable console logging for voice events. |
77
+
78
+ ## Programmatic Control
79
+
80
+ The widget can be controlled programmatically via the `window.VocalIA` object:
81
+
82
+ ```js
83
+ // Open the widget
84
+ VocalIA.open();
85
+
86
+ // Close the widget
87
+ VocalIA.close();
88
+
89
+ // Toggle state
90
+ VocalIA.toggle();
91
+
92
+ // Switch persona on the fly
93
+ VocalIA.setPersona('RESTAURANT');
94
+
95
+ // Send data to the AI (e.g., current product context)
96
+ VocalIA.sendContext({
97
+ productId: '123',
98
+ price: '99.99',
99
+ currency: 'EUR'
100
+ });
101
+ ```
102
+
103
+ ## Event Hooks
104
+
105
+ Listen to widget lifecycle events to trigger custom site logic:
106
+
107
+ ```js
108
+ window.addEventListener('vocalia:ready', (e) => {
109
+ console.log('VocalIA is loaded and ready.');
110
+ });
111
+
112
+ window.addEventListener('vocalia:message', (e) => {
113
+ const { role, text } = e.detail;
114
+ console.log(`New ${role} message: ${text}`);
115
+ });
116
+
117
+ window.addEventListener('vocalia:qualify', (e) => {
118
+ const { score, bant } = e.detail;
119
+ // Trigger your own CRM conversion pixels here
120
+ console.log('Lead qualified:', bant);
121
+ });
122
+
123
+ window.addEventListener('vocalia:error', (e) => {
124
+ console.error('VocalIA Error:', e.detail.message);
125
+ });
126
+ ```
127
+
128
+ ## Advanced Customization (CSS)
129
+
130
+ The widget uses CSS Variables for style overrides. You can define these in your main stylesheet:
131
+
132
+ ```css
133
+ :root {
134
+ --vocalia-primary: #FF5733;
135
+ --vocalia-font: 'Inter', sans-serif;
136
+ --vocalia-z-index: 9999;
137
+ }
138
+ ```
139
+
140
+ ## Data Attributes
141
+
142
+ Control widget behavior without writing JavaScript using HTML data attributes:
143
+
144
+ ```html
145
+ <!-- Trigger widget open from any button -->
146
+ <button data-vocalia-action="open">Speak with AI</button>
147
+
148
+ <!-- Switch persona based on page section -->
149
+ <section data-vocalia-persona="DENTAL"> ... </section>
150
+ ```
151
+
152
+ ## Personas
153
+
154
+ VocalIA includes 40 fine-tuned personas, categorized by industry:
155
+
156
+ * **Real Estate:** `PROPERTY`, `LISTINGS`, `CLIENT_RELATIONS`
157
+ * **Healthcare:** `DENTAL`, `HEALTHCARE`, `WELLNESS`
158
+ * **Professional Services:** `LAWYER`, `INSURANCE`, `FINANCE`, `AGENCY`
159
+ * **Home Services:** `CONTRACTOR`, `PLUMBING`, `ROOFING`
160
+ * **E-commerce & Retail:** `ECOMMERCE`, `RESTAURANT`, `HOTEL`, `TRAVEL`
161
+ * **Tech & Education:** `SAAS`, `EDUCATION`, `CUSTOMER_SUPPORT`
162
+
163
+ ## Languages & Localization
164
+
165
+ VocalIA is a global-first platform with deep regional intelligence:
166
+
167
+ * **RTL Support:** Automatically adjusts UI layout for Arabic and Darija.
168
+ * **Auto-Detection:** Uses sophisticated visitor logic:
169
+ * Geo: Morocco -> French (Primary) / Darija (Secondary)
170
+ * Geo: MENA -> Arabic
171
+ * Geo: Europe/Americas -> English / Local
172
+ * **Manual Override:** Set `language: 'ary'` to force Moroccan Darija specifically.
173
+
174
+ ## Requirements
175
+
176
+ * **HTTPS:** Browsers block microphone access on insecure connections.
177
+ * **Supported Browsers:** Chrome (v33+), Safari (v14.1+), Edge (v79+).
178
+ * **Network:** Access to `api.vocalia.ma` (Port 443).
179
+
180
+ ## Enterprise Support
181
+
182
+ For white-label solutions, custom personas training, or on-premise deployments, contact [enterprise@vocalia.ma](mailto:enterprise@vocalia.ma).
183
+
184
+ ## License
185
+
186
+ MIT © [Jouiet/VocalIA](https://github.com/Jouiet/VocalIA)
package/index.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ export interface VocaliaConfig {
2
+ tenantId: string;
3
+ apiKey?: string;
4
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
5
+ primaryColor?: string;
6
+ buttonSize?: number;
7
+ language?: 'auto' | 'fr' | 'en' | 'es' | 'ar' | 'ary';
8
+ persona?: string;
9
+ ecommerceMode?: boolean;
10
+ showOnMobile?: boolean;
11
+ }
12
+
13
+ export function initVocalia(config: VocaliaConfig): void;
14
+ export function initVocaliaB2B(config: VocaliaConfig): void;
15
+ export function initVocaliaEcommerce(config: VocaliaConfig): void;
package/index.js ADDED
@@ -0,0 +1,51 @@
1
+ // VocalIA Widget NPM Entry Point
2
+ // Usage: import { initVocalia, initVocaliaB2B, initVocaliaEcommerce } from 'vocalia-widget';
3
+
4
+ /**
5
+ * Initialize VocalIA Widget
6
+ * @param {object} config - Configuration object
7
+ */
8
+ export function initVocalia(config) {
9
+ if (typeof window === 'undefined') return;
10
+
11
+ // Map NPM config keys to widget SAFE_CONFIG_KEYS format
12
+ const safeConfig = {};
13
+ if (config.ecommerceMode !== undefined) safeConfig.ECOMMERCE_MODE = config.ecommerceMode;
14
+ if (config.position) safeConfig.widgetPosition = config.position;
15
+ if (config.language) safeConfig.DEFAULT_LANG = config.language === 'auto' ? undefined : config.language;
16
+ if (config.exitIntent !== undefined) safeConfig.EXIT_INTENT_ENABLED = config.exitIntent;
17
+ if (config.socialProof !== undefined) safeConfig.SOCIAL_PROOF_ENABLED = config.socialProof;
18
+ if (config.aiMode !== undefined) safeConfig.AI_MODE = config.aiMode;
19
+ if (config.apiTimeout) safeConfig.API_TIMEOUT = config.apiTimeout;
20
+
21
+ // Set safe config keys (these pass through widget H8 filter)
22
+ window.VOCALIA_CONFIG = safeConfig;
23
+
24
+ // Load Script dynamically from CDN/API (Unified V3 Kernel)
25
+ // tenantId is passed via data-vocalia-tenant attribute (widget reads this natively)
26
+ // primaryColor is applied server-side via /config endpoint based on tenant
27
+ if (!document.getElementById('vocalia-script')) {
28
+ const script = document.createElement('script');
29
+ script.id = 'vocalia-script';
30
+ script.src = `https://api.vocalia.ma/voice-assistant/voice-widget-v3.js`;
31
+ script.defer = true;
32
+ // Pass tenantId via data attribute — widget detectTenantId() reads this (line 3704)
33
+ if (config.tenantId) script.dataset.vocaliaTenant = config.tenantId;
34
+ if (config.apiKey) script.dataset.vocaliaApiKey = config.apiKey;
35
+ document.body.appendChild(script);
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Initialize B2B-specialized Widget
41
+ */
42
+ export function initVocaliaB2B(config) {
43
+ initVocalia({ ...config, ecommerceMode: false });
44
+ }
45
+
46
+ /**
47
+ * Initialize E-commerce-specialized Widget
48
+ */
49
+ export function initVocaliaEcommerce(config) {
50
+ initVocalia({ ...config, ecommerceMode: true });
51
+ }
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "vocalia-widget",
3
+ "version": "1.0.0",
4
+ "description": "AI-powered voice assistant widget for websites. 40 industry personas, 5 languages (FR/EN/ES/AR/Darija), BANT lead qualification, RTL support. Zero API cost via Web Speech API.",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "module": "index.js",
8
+ "types": "index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./index.js",
12
+ "types": "./index.d.ts"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "test": "echo \"Error: no test specified\" && exit 1"
17
+ },
18
+ "keywords": [
19
+ "voice-ai",
20
+ "vocalia",
21
+ "widget",
22
+ "voice-assistant",
23
+ "voice-commerce",
24
+ "chatbot",
25
+ "lead-qualification",
26
+ "multilingual",
27
+ "rtl",
28
+ "darija",
29
+ "morocco",
30
+ "web-speech-api"
31
+ ],
32
+ "author": "VocalIA <dev@vocalia.ma>",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/Jouiet/VocalIA.git",
37
+ "directory": "distribution/npm/vocalia-widget"
38
+ },
39
+ "homepage": "https://vocalia.ma",
40
+ "bugs": {
41
+ "url": "https://github.com/Jouiet/VocalIA/issues"
42
+ },
43
+ "engines": {
44
+ "node": ">=16.0.0"
45
+ },
46
+ "files": [
47
+ "src",
48
+ "index.js",
49
+ "index.d.ts",
50
+ "README.md",
51
+ "LICENSE"
52
+ ]
53
+ }