@henry-dev/botkit 1.0.0 → 1.0.1
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 +77 -0
- package/dist/index.cjs +2 -2690
- package/dist/index.js +2 -2616
- package/package.json +20 -4
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @henry-dev/botkit
|
|
2
|
+
|
|
3
|
+
A deterministic, type-safe conversational state machine framework for chatbots.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@henry-dev/botkit)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Key Features
|
|
11
|
+
|
|
12
|
+
- **Deterministic FSM Engine**: Pure, 100% testable state transitions with automatic timeout guards and fallback recovery.
|
|
13
|
+
- **Compiled Pattern Matching**: Regex-compiled keyword normalization, word-boundary safety, and negation guards (`excludeIf`).
|
|
14
|
+
- **Durable State Persistence**: MongoDB / Mongoose adapter with Optimistic Concurrency Control (OCC) to prevent race conditions.
|
|
15
|
+
- **High-Speed Idempotency**: Redis-backed webhook deduplication and BullMQ asynchronous worker queue processing.
|
|
16
|
+
- **Analytics & Evals**: Built-in conversation trace collectors, automated evaluation suite, and node-level drop-off metrics.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @henry-dev/botkit
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or using `pnpm` or `yarn`:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm add @henry-dev/botkit
|
|
30
|
+
# or
|
|
31
|
+
yarn add @henry-dev/botkit
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quick Example
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { Bot, FSMEngine, matchesAny } from "@henry-dev/botkit";
|
|
40
|
+
|
|
41
|
+
// 1. Define the conversation flow
|
|
42
|
+
const bot = new Bot("onboarding-flow", 1);
|
|
43
|
+
|
|
44
|
+
bot.ask("What is your name?")
|
|
45
|
+
.expect(matchesAny(["jina", "naitwa", "*"]))
|
|
46
|
+
.response((answer, ctx) => {
|
|
47
|
+
ctx.set("name", answer.raw);
|
|
48
|
+
})
|
|
49
|
+
.fallback("Sorry, I didn't catch that — what should I call you?")
|
|
50
|
+
.retries(3);
|
|
51
|
+
|
|
52
|
+
const flow = bot.compile();
|
|
53
|
+
|
|
54
|
+
// 2. Instantiate and process transitions
|
|
55
|
+
const fsm = new FSMEngine(flow);
|
|
56
|
+
const state = fsm.loadState("user-123");
|
|
57
|
+
const result = await fsm.transition(state, "My name is Alex");
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Documentation & Interactive Playground
|
|
63
|
+
|
|
64
|
+
For full guides, API references, architecture deep-dives, and an interactive simulator:
|
|
65
|
+
|
|
66
|
+
- **Interactive Simulator**: Test conversational state flows live in browser
|
|
67
|
+
- **Analytics & Evals**: Track drop-offs and evaluate scenario completion rates
|
|
68
|
+
- **Full Documentation**: Explore detailed guides on matchers, persistence, webhooks, and workers
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
Released under the [MIT License](LICENSE).
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|