ai-sales-agent-sdk 0.1.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 +568 -0
- package/examples/01-basic-usage/index.js +166 -0
- package/package.json +65 -0
- package/src/adapters/base/CustomerAdapter.js +41 -0
- package/src/adapters/base/OrderAdapter.js +56 -0
- package/src/adapters/base/PaymentAdapter.js +36 -0
- package/src/adapters/base/ProductAdapter.js +51 -0
- package/src/adapters/base/index.js +4 -0
- package/src/adapters/implementations/SQLiteClient.js +94 -0
- package/src/adapters/implementations/SQLiteCustomerAdapter.js +157 -0
- package/src/adapters/implementations/SQLiteOrderAdapter.js +244 -0
- package/src/adapters/implementations/SQLitePaymentAdapter.js +91 -0
- package/src/adapters/implementations/SQLiteProductAdapter.js +131 -0
- package/src/adapters/implementations/index.js +5 -0
- package/src/adapters/implementations/sqlite-schema.sql +75 -0
- package/src/adapters/index.js +8 -0
- package/src/core/ActionExecutor.js +306 -0
- package/src/core/Agent.js +170 -0
- package/src/core/ContextManager.js +107 -0
- package/src/core/IntentDetector.js +107 -0
- package/src/core/ResponseGenerator.js +115 -0
- package/src/core/index.js +5 -0
- package/src/index.js +15 -0
- package/src/llm/base/LLMProvider.js +36 -0
- package/src/llm/base/index.js +1 -0
- package/src/llm/index.js +2 -0
- package/src/llm/providers/ClaudeProvider.js +20 -0
- package/src/llm/providers/OllamaProvider.js +84 -0
- package/src/llm/providers/OpenAIProvider.js +20 -0
- package/src/llm/providers/index.js +3 -0
- package/src/middleware/ErrorHandler.js +11 -0
- package/src/middleware/Logger.js +43 -0
- package/src/middleware/RateLimiter.js +25 -0
- package/src/middleware/index.js +3 -0
- package/src/session/MemorySessionStore.js +54 -0
- package/src/session/RedisSessionStore.js +61 -0
- package/src/session/SessionStore.js +42 -0
- package/src/session/index.js +3 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
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,568 @@
|
|
|
1
|
+
# AI Sales Agent SDK
|
|
2
|
+
|
|
3
|
+
> Framework-agnostic conversational commerce engine for building AI-powered sales chatbots
|
|
4
|
+
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
|
|
8
|
+
**AI Sales Agent SDK** is a production-ready JavaScript SDK that enables developers to integrate intelligent conversational commerce capabilities into any e-commerce platform, POS system, or custom application.
|
|
9
|
+
|
|
10
|
+
## β¨ Features
|
|
11
|
+
|
|
12
|
+
- ποΈ **Conversational Commerce Engine** - Browse, cart, checkout via natural language
|
|
13
|
+
- π **Adapter Pattern** - Plug into any backend (WooCommerce, Shopify, Odoo, custom APIs)
|
|
14
|
+
- π€ **Multi-LLM Support** - Works with Ollama, OpenAI, Claude, or custom models
|
|
15
|
+
- π― **Intent Detection** - Automatically understands user intent and extracts entities
|
|
16
|
+
- πΎ **Flexible Session Storage** - In-memory (dev) or Redis (production)
|
|
17
|
+
- π‘οΈ **Production-Ready** - Rate limiting, error handling, structured logging built-in
|
|
18
|
+
- π **Framework-Agnostic** - No Express/Fastify/Koa dependency
|
|
19
|
+
- π¦ **Zero Config** - Works out of the box with SQLite reference implementation
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## π¦ Installation
|
|
24
|
+
|
|
25
|
+
### Option 1: Clone from GitHub
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/mmad2021/ai-sales-agent-sdk.git
|
|
29
|
+
cd ai-sales-agent-sdk
|
|
30
|
+
npm install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Option 2: Add to your project
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Coming soon: npm install ai-sales-agent-sdk
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For now, you can use it as a git submodule or copy the `src/` directory into your project.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## π Quick Start
|
|
44
|
+
|
|
45
|
+
### Run the Example
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run example:basic
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This runs a complete demo showing:
|
|
52
|
+
- Product browsing
|
|
53
|
+
- Adding items to cart
|
|
54
|
+
- Viewing cart
|
|
55
|
+
- Checkout flow
|
|
56
|
+
|
|
57
|
+
### Basic Usage
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
import {
|
|
61
|
+
AISalesAgent,
|
|
62
|
+
OllamaProvider,
|
|
63
|
+
MemorySessionStore,
|
|
64
|
+
SQLiteProductAdapter,
|
|
65
|
+
SQLiteOrderAdapter,
|
|
66
|
+
SQLiteCustomerAdapter,
|
|
67
|
+
SQLitePaymentAdapter,
|
|
68
|
+
SQLiteClient
|
|
69
|
+
} from './src/index.js';
|
|
70
|
+
|
|
71
|
+
// 1. Setup database (SQLite example)
|
|
72
|
+
const dbClient = new SQLiteClient({ dbPath: ':memory:' });
|
|
73
|
+
await dbClient.init();
|
|
74
|
+
|
|
75
|
+
// 2. Configure adapters
|
|
76
|
+
const adapters = {
|
|
77
|
+
products: new SQLiteProductAdapter(dbClient),
|
|
78
|
+
orders: new SQLiteOrderAdapter(dbClient),
|
|
79
|
+
customers: new SQLiteCustomerAdapter(dbClient),
|
|
80
|
+
payments: new SQLitePaymentAdapter(dbClient)
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// 3. Choose LLM provider
|
|
84
|
+
const llmProvider = new OllamaProvider({
|
|
85
|
+
baseUrl: 'http://localhost:11434',
|
|
86
|
+
model: 'qwen2.5-coder:14b'
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// 4. Setup session storage
|
|
90
|
+
const sessionStore = new MemorySessionStore();
|
|
91
|
+
|
|
92
|
+
// 5. Create agent
|
|
93
|
+
const agent = new AISalesAgent({
|
|
94
|
+
llmProvider,
|
|
95
|
+
sessionStore,
|
|
96
|
+
adapters
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// 6. Process messages
|
|
100
|
+
const response = await agent.processMessage({
|
|
101
|
+
userId: 'user123',
|
|
102
|
+
message: 'Show me black t-shirts under $30'
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
console.log(response.text); // Natural language response
|
|
106
|
+
console.log(response.data); // Structured data (products, cart, etc.)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## ποΈ Architecture
|
|
112
|
+
|
|
113
|
+
### Core Components
|
|
114
|
+
|
|
115
|
+
| Component | Purpose |
|
|
116
|
+
|-----------|---------|
|
|
117
|
+
| **Agent** | Main orchestrator - coordinates all operations |
|
|
118
|
+
| **IntentDetector** | Analyzes messages, extracts intent + entities |
|
|
119
|
+
| **ResponseGenerator** | Creates natural language responses |
|
|
120
|
+
| **ActionExecutor** | Executes business actions (add_to_cart, checkout) |
|
|
121
|
+
| **ContextManager** | Manages conversation context and state |
|
|
122
|
+
|
|
123
|
+
### Adapters
|
|
124
|
+
|
|
125
|
+
Implement these interfaces to connect your backend:
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
// Product operations
|
|
129
|
+
class ProductAdapter {
|
|
130
|
+
async findProducts(filters) { /* ... */ }
|
|
131
|
+
async getProductById(id) { /* ... */ }
|
|
132
|
+
async checkStock(productId, quantity) { /* ... */ }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Order management
|
|
136
|
+
class OrderAdapter {
|
|
137
|
+
async createOrder(userId, items) { /* ... */ }
|
|
138
|
+
async getOrder(orderId) { /* ... */ }
|
|
139
|
+
async getUserOrders(userId) { /* ... */ }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Customer data
|
|
143
|
+
class CustomerAdapter {
|
|
144
|
+
async getCustomer(userId) { /* ... */ }
|
|
145
|
+
async createCustomer(data) { /* ... */ }
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Payment processing
|
|
149
|
+
class PaymentAdapter {
|
|
150
|
+
async verifyPayment(paymentData) { /* ... */ }
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Reference implementations included:**
|
|
155
|
+
- β
SQLite adapters (use as-is or as reference)
|
|
156
|
+
- π WooCommerce adapters (coming soon)
|
|
157
|
+
- π Shopify adapters (coming soon)
|
|
158
|
+
|
|
159
|
+
### LLM Providers
|
|
160
|
+
|
|
161
|
+
Built-in support for:
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
// Local models (Ollama)
|
|
165
|
+
const llm = new OllamaProvider({
|
|
166
|
+
baseUrl: 'http://localhost:11434',
|
|
167
|
+
model: 'qwen2.5-coder:14b'
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// OpenAI
|
|
171
|
+
const llm = new OpenAIProvider({
|
|
172
|
+
apiKey: 'sk-...',
|
|
173
|
+
model: 'gpt-4'
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Claude
|
|
177
|
+
const llm = new ClaudeProvider({
|
|
178
|
+
apiKey: 'sk-ant-...',
|
|
179
|
+
model: 'claude-3-sonnet'
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Or implement your own
|
|
183
|
+
class CustomLLMProvider extends LLMProvider {
|
|
184
|
+
async complete(prompt) { /* ... */ }
|
|
185
|
+
async completeJSON(prompt) { /* ... */ }
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## π Detailed Usage
|
|
192
|
+
|
|
193
|
+
### 1. Using with WooCommerce (custom adapter)
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
import axios from 'axios';
|
|
197
|
+
import { ProductAdapter } from './src/adapters/base/index.js';
|
|
198
|
+
|
|
199
|
+
class WooCommerceProductAdapter extends ProductAdapter {
|
|
200
|
+
constructor({ siteUrl, consumerKey, consumerSecret }) {
|
|
201
|
+
super();
|
|
202
|
+
this.api = axios.create({
|
|
203
|
+
baseURL: `${siteUrl}/wp-json/wc/v3`,
|
|
204
|
+
auth: { username: consumerKey, password: consumerSecret }
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async findProducts(filters) {
|
|
209
|
+
const params = {};
|
|
210
|
+
if (filters.category) params.category = filters.category;
|
|
211
|
+
if (filters.maxPrice) params.max_price = filters.maxPrice;
|
|
212
|
+
if (filters.search) params.search = filters.search;
|
|
213
|
+
|
|
214
|
+
const response = await this.api.get('/products', { params });
|
|
215
|
+
return response.data.map(p => ({
|
|
216
|
+
id: p.id,
|
|
217
|
+
name: p.name,
|
|
218
|
+
description: p.description,
|
|
219
|
+
price: parseFloat(p.price),
|
|
220
|
+
stock: p.stock_quantity,
|
|
221
|
+
category: p.categories[0]?.name,
|
|
222
|
+
image: p.images[0]?.src
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async getProductById(id) {
|
|
227
|
+
const response = await this.api.get(`/products/${id}`);
|
|
228
|
+
const p = response.data;
|
|
229
|
+
return {
|
|
230
|
+
id: p.id,
|
|
231
|
+
name: p.name,
|
|
232
|
+
price: parseFloat(p.price),
|
|
233
|
+
stock: p.stock_quantity
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
async checkStock(productId, quantity) {
|
|
238
|
+
const product = await this.getProductById(productId);
|
|
239
|
+
return product.stock >= quantity;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Use it
|
|
244
|
+
const products = new WooCommerceProductAdapter({
|
|
245
|
+
siteUrl: 'https://your-store.com',
|
|
246
|
+
consumerKey: 'ck_...',
|
|
247
|
+
consumerSecret: 'cs_...'
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const agent = new AISalesAgent({ adapters: { products }, /* ... */ });
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### 2. Using with Redis Sessions (production)
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
import { RedisSessionStore } from './src/session/index.js';
|
|
257
|
+
|
|
258
|
+
const sessionStore = new RedisSessionStore({
|
|
259
|
+
host: 'localhost',
|
|
260
|
+
port: 6379,
|
|
261
|
+
db: 0,
|
|
262
|
+
password: 'your-redis-password', // optional
|
|
263
|
+
ttl: 3600 // session TTL in seconds
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
const agent = new AISalesAgent({
|
|
267
|
+
sessionStore,
|
|
268
|
+
// ... other config
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### 3. Using Middleware
|
|
273
|
+
|
|
274
|
+
```javascript
|
|
275
|
+
import { RateLimiter, Logger, ErrorHandler } from './src/middleware/index.js';
|
|
276
|
+
|
|
277
|
+
// Rate limiting (10 requests per minute per user)
|
|
278
|
+
const rateLimiter = new RateLimiter({
|
|
279
|
+
maxRequests: 10,
|
|
280
|
+
windowMs: 60000
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// Structured logging
|
|
284
|
+
const logger = new Logger({ level: 'info' });
|
|
285
|
+
|
|
286
|
+
// Error recovery
|
|
287
|
+
const errorHandler = new ErrorHandler({
|
|
288
|
+
fallbackMessage: 'Sorry, something went wrong. Please try again.'
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
// Apply to agent
|
|
292
|
+
const agent = new AISalesAgent({
|
|
293
|
+
middleware: [rateLimiter, logger, errorHandler],
|
|
294
|
+
// ... other config
|
|
295
|
+
});
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### 4. Handling Responses
|
|
299
|
+
|
|
300
|
+
```javascript
|
|
301
|
+
const response = await agent.processMessage({
|
|
302
|
+
userId: 'user123',
|
|
303
|
+
message: 'Add black t-shirt to cart'
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
console.log(response);
|
|
307
|
+
// {
|
|
308
|
+
// text: "I've added the black t-shirt to your cart.",
|
|
309
|
+
// data: {
|
|
310
|
+
// intent: 'add_to_cart',
|
|
311
|
+
// confidence: 0.93,
|
|
312
|
+
// entities: { product_type: 't-shirt', color: 'black' },
|
|
313
|
+
// cart: [{ productId: 1, name: 'Black T-Shirt', quantity: 1, price: 25.00 }],
|
|
314
|
+
// action: 'item_added'
|
|
315
|
+
// },
|
|
316
|
+
// metadata: {
|
|
317
|
+
// userId: 'user123',
|
|
318
|
+
// timestamp: '2026-02-21T10:30:00Z',
|
|
319
|
+
// processingTime: 234
|
|
320
|
+
// }
|
|
321
|
+
// }
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## π― Use Cases
|
|
327
|
+
|
|
328
|
+
### E-commerce Chatbots
|
|
329
|
+
- WhatsApp Shopping for online stores
|
|
330
|
+
- Telegram product catalog bot
|
|
331
|
+
- Web chat widget for product discovery
|
|
332
|
+
|
|
333
|
+
### Point of Sale (POS)
|
|
334
|
+
- In-store kiosk with voice/chat interface
|
|
335
|
+
- Mobile sales assistant app
|
|
336
|
+
- Inventory lookup tool
|
|
337
|
+
|
|
338
|
+
### Custom Integrations
|
|
339
|
+
- Internal sales tools
|
|
340
|
+
- B2B order management
|
|
341
|
+
- Multi-channel commerce (web + messaging apps)
|
|
342
|
+
|
|
343
|
+
### Rapid Prototyping
|
|
344
|
+
- Build conversational commerce MVP in hours
|
|
345
|
+
- Test AI sales flows before full integration
|
|
346
|
+
- Demo to stakeholders
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## π Project Structure
|
|
351
|
+
|
|
352
|
+
```
|
|
353
|
+
ai-sales-agent-sdk/
|
|
354
|
+
βββ src/
|
|
355
|
+
β βββ core/ # Core engine
|
|
356
|
+
β β βββ Agent.js # Main orchestrator
|
|
357
|
+
β β βββ IntentDetector.js # Intent classification
|
|
358
|
+
β β βββ ResponseGenerator.js # Natural language generation
|
|
359
|
+
β β βββ ActionExecutor.js # Business logic executor
|
|
360
|
+
β β βββ ContextManager.js # Conversation context
|
|
361
|
+
β β
|
|
362
|
+
β βββ adapters/
|
|
363
|
+
β β βββ base/ # Base interfaces
|
|
364
|
+
β β β βββ ProductAdapter.js
|
|
365
|
+
β β β βββ OrderAdapter.js
|
|
366
|
+
β β β βββ CustomerAdapter.js
|
|
367
|
+
β β β βββ PaymentAdapter.js
|
|
368
|
+
β β βββ implementations/ # SQLite reference
|
|
369
|
+
β β βββ SQLiteProductAdapter.js
|
|
370
|
+
β β βββ SQLiteOrderAdapter.js
|
|
371
|
+
β β βββ SQLiteCustomerAdapter.js
|
|
372
|
+
β β βββ SQLitePaymentAdapter.js
|
|
373
|
+
β β βββ SQLiteClient.js
|
|
374
|
+
β β
|
|
375
|
+
β βββ llm/
|
|
376
|
+
β β βββ base/
|
|
377
|
+
β β β βββ LLMProvider.js # Base LLM interface
|
|
378
|
+
β β βββ providers/
|
|
379
|
+
β β βββ OllamaProvider.js
|
|
380
|
+
β β βββ OpenAIProvider.js
|
|
381
|
+
β β βββ ClaudeProvider.js
|
|
382
|
+
β β
|
|
383
|
+
β βββ session/
|
|
384
|
+
β β βββ SessionStore.js # Base interface
|
|
385
|
+
β β βββ MemorySessionStore.js
|
|
386
|
+
β β βββ RedisSessionStore.js
|
|
387
|
+
β β
|
|
388
|
+
β βββ middleware/
|
|
389
|
+
β βββ RateLimiter.js
|
|
390
|
+
β βββ Logger.js
|
|
391
|
+
β βββ ErrorHandler.js
|
|
392
|
+
β
|
|
393
|
+
βββ examples/
|
|
394
|
+
β βββ 01-basic-usage/
|
|
395
|
+
β βββ index.js # Working demo
|
|
396
|
+
β
|
|
397
|
+
βββ package.json
|
|
398
|
+
βββ LICENSE
|
|
399
|
+
βββ README.md
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## π§ Configuration
|
|
405
|
+
|
|
406
|
+
### Agent Options
|
|
407
|
+
|
|
408
|
+
```javascript
|
|
409
|
+
const agent = new AISalesAgent({
|
|
410
|
+
// Required
|
|
411
|
+
llmProvider: new OllamaProvider({ /* ... */ }),
|
|
412
|
+
sessionStore: new MemorySessionStore(),
|
|
413
|
+
adapters: {
|
|
414
|
+
products: new SQLiteProductAdapter(/* ... */),
|
|
415
|
+
orders: new SQLiteOrderAdapter(/* ... */),
|
|
416
|
+
customers: new SQLiteCustomerAdapter(/* ... */),
|
|
417
|
+
payments: new SQLitePaymentAdapter(/* ... */)
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
// Optional
|
|
421
|
+
middleware: [rateLimiter, logger, errorHandler],
|
|
422
|
+
|
|
423
|
+
// Context options
|
|
424
|
+
contextWindow: 10, // Number of messages to keep in context
|
|
425
|
+
|
|
426
|
+
// Intent detection options
|
|
427
|
+
intentThreshold: 0.7, // Minimum confidence for intent detection
|
|
428
|
+
|
|
429
|
+
// Response options
|
|
430
|
+
responseFormat: 'conversational', // 'conversational' | 'structured'
|
|
431
|
+
language: 'en', // Response language
|
|
432
|
+
|
|
433
|
+
// Error handling
|
|
434
|
+
maxRetries: 3, // Max retry attempts on LLM failures
|
|
435
|
+
timeout: 30000 // Request timeout in ms
|
|
436
|
+
});
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## π§ͺ Testing
|
|
442
|
+
|
|
443
|
+
```bash
|
|
444
|
+
# Run all tests (coming soon)
|
|
445
|
+
npm test
|
|
446
|
+
|
|
447
|
+
# Run specific test suite
|
|
448
|
+
npm test -- --grep "IntentDetector"
|
|
449
|
+
|
|
450
|
+
# Run with coverage
|
|
451
|
+
npm run test:coverage
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## π οΈ Development
|
|
457
|
+
|
|
458
|
+
### Running Examples Locally
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
# Basic usage example
|
|
462
|
+
npm run example:basic
|
|
463
|
+
|
|
464
|
+
# WooCommerce example (coming soon)
|
|
465
|
+
npm run example:woocommerce
|
|
466
|
+
|
|
467
|
+
# Telegram bot example (coming soon)
|
|
468
|
+
npm run example:telegram
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Building Custom Adapters
|
|
472
|
+
|
|
473
|
+
1. Extend the base adapter class
|
|
474
|
+
2. Implement required methods
|
|
475
|
+
3. Handle errors appropriately
|
|
476
|
+
4. Return data in expected format
|
|
477
|
+
|
|
478
|
+
See `src/adapters/implementations/` for reference implementations.
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## π Requirements
|
|
483
|
+
|
|
484
|
+
- **Node.js:** >= 16.0.0
|
|
485
|
+
- **Dependencies:**
|
|
486
|
+
- `redis` (^4.6.12) - only if using RedisSessionStore
|
|
487
|
+
- `sql.js` (^1.14.0) - only if using SQLite adapters
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
## πΊοΈ Roadmap
|
|
492
|
+
|
|
493
|
+
### Phase 1: Core SDK β
(Complete)
|
|
494
|
+
- [x] Core conversational engine
|
|
495
|
+
- [x] Adapter pattern
|
|
496
|
+
- [x] Multi-LLM support
|
|
497
|
+
- [x] Session management
|
|
498
|
+
- [x] Middleware stack
|
|
499
|
+
- [x] SQLite reference implementations
|
|
500
|
+
- [x] Basic example
|
|
501
|
+
|
|
502
|
+
### Phase 2: Enhancements (In Progress)
|
|
503
|
+
- [ ] Vision support (image product search)
|
|
504
|
+
- [ ] Sentiment analysis
|
|
505
|
+
- [ ] Multi-language support
|
|
506
|
+
- [ ] Conversation summarization
|
|
507
|
+
|
|
508
|
+
### Phase 3: Real-World Integrations
|
|
509
|
+
- [ ] WooCommerce adapters
|
|
510
|
+
- [ ] Shopify adapters
|
|
511
|
+
- [ ] Odoo ERP adapters
|
|
512
|
+
- [ ] WhatsApp Business API connector
|
|
513
|
+
- [ ] Telegram Bot API connector
|
|
514
|
+
|
|
515
|
+
### Phase 4: Testing & Documentation
|
|
516
|
+
- [ ] Unit tests (Jest)
|
|
517
|
+
- [ ] Integration tests
|
|
518
|
+
- [ ] API documentation (JSDoc)
|
|
519
|
+
- [ ] Tutorial videos
|
|
520
|
+
|
|
521
|
+
### Phase 5: Distribution
|
|
522
|
+
- [ ] Publish to npm
|
|
523
|
+
- [ ] CDN version
|
|
524
|
+
- [ ] Docker images
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
## π€ Contributing
|
|
529
|
+
|
|
530
|
+
Contributions are welcome! Please:
|
|
531
|
+
|
|
532
|
+
1. Fork the repository
|
|
533
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
534
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
535
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
536
|
+
5. Open a Pull Request
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
## π License
|
|
541
|
+
|
|
542
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
543
|
+
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
## π Credits
|
|
547
|
+
|
|
548
|
+
**Architecture:** Adapter pattern, Dependency Injection, Interface Segregation
|
|
549
|
+
**Implementation:** Automated extraction with GPT-5.3 Codex
|
|
550
|
+
**Original Project:** [ai-sales-agent](https://github.com/mmad2021/ai-sales-agent)
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
## π Support
|
|
555
|
+
|
|
556
|
+
- **Issues:** [GitHub Issues](https://github.com/mmad2021/ai-sales-agent-sdk/issues)
|
|
557
|
+
- **Discussions:** [GitHub Discussions](https://github.com/mmad2021/ai-sales-agent-sdk/discussions)
|
|
558
|
+
- **Email:** mmad2021@users.noreply.github.com
|
|
559
|
+
|
|
560
|
+
---
|
|
561
|
+
|
|
562
|
+
## π Star History
|
|
563
|
+
|
|
564
|
+
If you find this project useful, please consider giving it a star! β
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
**Built with β€οΈ for the conversational commerce community**
|